@@ -57,6 +57,7 @@ defmodule Module.Types.Apply do
5757             list ( closed_map ( default:  if_set ( term ( ) ) ,  field:  atom ( ) ) ) 
5858            |>  union ( atom ( [ nil ] ) ) 
5959        ]  ++  shared_info , 
60+       # TODO: Move this to a type signature in the long term 
6061      __protocol__:  [ 
6162        module:  atom ( ) , 
6263        functions:  fas , 
@@ -1069,22 +1070,39 @@ defmodule Module.Types.Apply do
10691070  end 
10701071
10711072  defp  args_to_quoted_string ( args_types ,  domain ,  converter )  do 
1072-     ansi?  =  IO.ANSI . enabled? ( ) 
1073- 
10741073    docs  = 
10751074      Enum . zip_with ( args_types ,  domain ,  fn  actual ,  expected  -> 
1076-         doc  =  actual  |>  to_quoted ( )  |>  Code.Formatter . to_algebra ( ) 
1077- 
1078-         cond  do 
1079-           compatible? ( actual ,  expected )  ->  doc 
1080-           ansi?  ->  IA . concat ( IA . color ( doc ,  IO.ANSI . red ( ) ) ,  IA . color ( IA . empty ( ) ,  IO.ANSI . reset ( ) ) ) 
1081-           true  ->  IA . concat ( [ "-" ,  doc ,  "-" ] ) 
1075+         if  compatible? ( actual ,  expected )  do 
1076+           actual  |>  to_quoted ( )  |>  Code.Formatter . to_algebra ( ) 
1077+         else 
1078+           common  =  intersection ( actual ,  expected ) 
1079+ 
1080+           uncommon_doc  = 
1081+             difference ( actual ,  common ) 
1082+             |>  to_quoted ( ) 
1083+             |>  Code.Formatter . to_algebra ( ) 
1084+             |>  ansi_red ( ) 
1085+ 
1086+           if  empty? ( common )  do 
1087+             uncommon_doc 
1088+           else 
1089+             common_doc  =  common  |>  to_quoted ( )  |>  Code.Formatter . to_algebra ( ) 
1090+             IA . glue ( IA . concat ( uncommon_doc ,  " or" ) ,  IA . nest ( common_doc ,  2 ) ) 
1091+           end 
10821092        end 
10831093      end ) 
10841094
10851095    args_docs_to_quoted_string ( converter . ( docs ) ) 
10861096  end 
10871097
1098+   defp  ansi_red ( doc )  do 
1099+     if  IO.ANSI . enabled? ( )  do 
1100+       IA . concat ( IA . color ( doc ,  IO.ANSI . red ( ) ) ,  IA . color ( IA . empty ( ) ,  IO.ANSI . reset ( ) ) ) 
1101+     else 
1102+       IA . concat ( [ "-" ,  doc ,  "-" ] ) 
1103+     end 
1104+   end 
1105+ 
10881106  defp  args_docs_to_quoted_string ( docs )  do 
10891107    doc  =  IA . fold ( docs ,  fn  doc ,  acc  ->  IA . glue ( IA . concat ( doc ,  "," ) ,  acc )  end ) 
10901108
0 commit comments