Proposal: Don't require users to use undefined

Simon Peyton-Jones simonpj at microsoft.com
Wed Oct 27 15:57:59 EDT 2010


| Drifting off-topic, but wouldn't we want to be able to use similar
| syntax to bind types too? e.g.
| 
|     f ((Just @ t) x) = (Right @ String @ t) x
| 
| but @ is unavailable in patterns.

Oh yes, good point.  It'd be particularly useful in existential patterns:

  data T where
   MkT :: forall a. a -> (a -> Int) -> T

  f (MkT @ a x g) = g (x::a)

The idea is that the pattern (MkT @ a x g) brings the type variable 'a' into scope.  As you point out, though, '@' is already used in patterns, but perhaps this use is unambiguous.  Confusing though
   f (MkS @ a x@(p,q) z) = ....

Maybe someone else can think of good syntax.

Simon


More information about the Libraries mailing list