[Haskell-cafe] Re: Scrap your rolls/unrolls

Dan Doel dan.doel at gmail.com
Fri Oct 22 17:06:56 EDT 2010


On Friday 22 October 2010 7:24:37 am Max Bolingbroke wrote:
> Ah yes, pattern synonyms. This solution is somewhat unsatisfying
> because you will also need some smart constructors:
> 
> """
> nil = Roll NilF
> cons x xs = Roll (ConsF x xs)
> """
> 
> Now the names of the smart constructors for building the data type are
> not the same as the things you pattern match on, which is a slightly
> annoying asymmetry. It's certainly less complicated than the
> TypeFamilies based solution though!

SHE's pattern synonyms also work as expressions, so there's no asymmetry. They 
work just like constructors as far as I can tell (with what little I've played 
with them); you can even partially apply them (in expressions). It doesn't do 
infix synonyms currently, though.

-- Dan


More information about the Haskell-Cafe mailing list