[Haskell-cafe] A proposals

wren ng thornton wren at freegeek.org
Sun Sep 27 22:02:37 EDT 2009


Louis Wasserman wrote:
> I'd like to see something resembling as-patterns in type signatures.
> Specifically, there are cases where I'm inclined to use
> (m ~ pat) in a type context when m isn't otherwise constrained, just so I
> can use m as an abbreviation for pat.  To reduce these cases, I'd like to
> see the syntax m at pat allowed for use in type signatures, with m becoming
> simply an alias for pat.  Thoughts?
> 
> I've added a ticket here <http://hackage.haskell.org/trac/ghc/ticket/3545>.

+1.

I've often wanted this when doing type-level programming. Another nice 
thing this suggests is the ability to use underscore as a pattern for 
when you know the compiler will infer the type but it's too complex to 
want to write out (e.g. while experimenting). With x at _ you could even 
share the complex type in multiple places, since x will be bound to some 
actual type rather than being universally quantified. (Of course, ISTR 
someone's suggested the underscores in the past and had it rejected. Alas.)

-- 
Live well,
~wren


More information about the Haskell-Cafe mailing list