[Haskell-beginners] Type Operator

Brent Yorgey byorgey at seas.upenn.edu
Wed Jan 21 22:07:00 EST 2009


On Wed, Jan 21, 2009 at 11:51:26PM +0100, Daniel Fischer wrote:
> I think you can't.
> If it's possible, the best option would be to change the order of type 
> parameters of Sample. If that's not possible, you can define
> 
>   newtype FSample b a = FS (Sample a b)
> 
> and make that an instance of Monad.

Right, Haskell doesn't allow partially applied type synonyms, but
partially applied newtypes are fine.  It will just be a bit annoying
having the FS constructor tags everywhere.  Switching the order of the
parameters to Sample would be the best option.

> Somebody remind me, why does Haskell not have type-lambdas?

Because type-lambdas would require higher-order unification during
type checking, which is in general undecidable.  Without type lambdas,
if you have to unify two type applications like

  f a == m b

then you know that f == m and a == b.  But with type lambdas this
might not be the case.  For example, you could have f == \x -> [x], a
= Int, m = \x -> x, and b = [Int].

-Brent


More information about the Beginners mailing list