[Haskell-cafe] (n+k) patterns

Sittampalam, Ganesh ganesh.sittampalam at credit-suisse.com
Thu Apr 23 03:26:13 EDT 2009


Richard O'Keefe wrote:
 
> The thing is that it really seems bizarre to see this one feature
> singled out for non-implementation. 
> 
> If I can do the equivalent of n+k patterns by programming in the
> *type system*, why *not* in a pattern? 

Do you mean by something like the following?

data Z = Z
data S n = S n

type Plus2 a = S (S a)

minus2 :: Plus2 a -> a
minus2 _ = undefined -- or actually use the values, or whatever

If so, I'd say that n+k patterns go well beyond this kind of "pattern
aliases", particularly since they operate on arbitrary Nums, not just an
inductively defined natural number type.

Cheers,

Ganesh

=============================================================================== 
 Please access the attached hyperlink for an important electronic communications disclaimer: 
 http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
 =============================================================================== 
 


More information about the Haskell-Cafe mailing list