id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
5144	Pattern synonyms	simonpj		"Lennart would like pattern synonyms.  Something like
{{{
pattern con var1 … varN = pat
}}}
where ‘pattern` is a new keyword.  
 * Perhaps there should be a way to give a type as well, so the `con` could be `(con :: type)`.
 * The `rhs` is type checked as a usual pattern, i.e., in the global environment.  
 * The `pat` should bind exactly `var1` .. `varN`.
 * Recursive pattern synonyms are not allowed.

With `con` in scope it can be used like any other constructor in a pattern, and the semantics is simply by expansion.

It would have been very nice if `con` could be used in expressions as well, but I don’t see how that could work with view patterns.
Perhaps view patterns could be extended to make them bidirectional.

My rationale for wanting pattern synonyms is that I sometimes have pattern matching with a lot of complex repetition in them.
I’ve even resorted to using CPP in the past, and that just shows that Haskell is lacking some abstraction mechanism.

If pattern synonyms could be made to work in the presence of view pattern it would offer a mechanism for normal pattern matching on abstract types, since the abstract type could export some pattern synonyms and you’d not be able to tell of those were real constructors or not.

I’ve not tried implementing this, but I think SHE has something like it.
"	feature request	new	normal	_|_	Compiler				lennart.augustsson@… illissius@… bgamari@… cgibbard@…	Unknown/Multiple	Unknown/Multiple	None/Unknown	Unknown				
