Excellent bikeshedding opportunity! Frontend syntax for pattern synonym types
Jacques Carette
carette at mcmaster.ca
Sun Dec 22 14:29:10 UTC 2013
[Superb summary of pattern synonyms omitted]
On 2013-12-22 9:09 AM, Dr. ERDI Gergo wrote:
>
> The one idea I've had so far is to separate (4), (3) and (5) with two
> double arrows:
>
> pattern P :: (Show t) => b -> T t => (Num t, Eq b)
pattern P :: (Show t) => ( (Num t, Eq b) => b -> T t )
perhaps? Given 'Show t', you get what's on the rhs of the first => ?
Another idea is
pattern P :: (Show t) ~> (Num t, Eq b) => b -> T t
which has the drawback of introducing a new 'keyword'.
>
> As an added extra problem, there are also unidirectional and
> bidirectional pattern synonyms: unidirectional ones are usable only as
> patterns, whereas bidirectional ones can also be used as expressions.
> For example:
>
> pattern Single x = [x]
> pattern Second x <- (_:x:_)
>
> in this example, `Single` is bidirectional and `Second` is
> unidirectional. As you can see, this is indicated by syntax in the
> definition (`=` vs `<-`). However, I'd like to show this in the type
> as well, since you'd need to be able to see if you can use a given
> pattern synonym as a "constructor", not just a "destructor", by just
> looking at its Haddock-generated docs.
Since the first is an iso, why not
pattern Single :: t a ~ [ a ]
or
pattern Single :: t a <-> [ a ]
? [I definitely prefer the first] Or is your 'type' for Single somehow
different than my guess?
Jacques
More information about the Glasgow-haskell-users
mailing list