[Haskell-cafe] Re: Point-free style (Was: Things to avoid)

oleg at pobox.com oleg at pobox.com
Thu Feb 10 21:04:26 EST 2005


Jan-Willem Maessen wrote:
] Is it really clear or obvious what
] 
] > map . (+)
]
] means? 

Perhaps the following two examples might be more convincing:

> u=uncurry
> e=((partition $ u(==)).) . zip
> f x=(x\\).(x\\)

It is obviously clear what 'e' and 'f x' do.

The second example, which even contains the type signature to increase
comprehension:

> prod:: (MCompose a b (c -> d) e, MCompose f g (b,g) d) =>
>        (h -> a) -> (c -> f) -> h -> e
>
> prod = (. ((. (,)) . mcomp)) . mcomp

Here `prod' is indeed the categorical product. The second example is
taken from
	http://pobox.com/~oleg/ftp/Haskell/categorical-maxn.lhs
which has the following comment about that code fragment:

  The constraints in the prod's type are intricately related. The final
  expression for prod bears some similarity with Unlambda code. Perhaps
  because both Unlambda and the category theory eschew "elements" in
  favor of combinations of arrows. Probably there are other
  similarities.




More information about the Haskell-Cafe mailing list