
Simon Peyton-Jones wrote:
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.
Couldn't this work? f (MkT (x :: a) g) In theory one could imagine wanting to write data T where MkT :: forall a . Foo a => T and then some special syntax might be needed, but I can't think of any real use for this off the top of my head. But in general the idea of having a whole new syntax for passing types around makes me a bit nervous; GHC Haskell is already getting quite syntactically cluttered. We already have machinery for passing around values and abstracting over them, so if we can use a single well-known proxy value to pass around types we can reuse that machinery. Couldn't the typeOf Maybe problem be solved with polymorphic kinds, which would be nice to have anyway? =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ===============================================================================