Pattern Synonym Signature Confusion

Ganesh Sittampalam ganesh at earth.li
Thu Oct 1 17:56:40 UTC 2015


On 01/10/2015 18:12, Sven Panne wrote:
> 2015-10-01 13:23 GMT+02:00 Matthew Pickering
> <matthewtpickering at gmail.com <mailto:matthewtpickering at gmail.com>>:
> 
>     I think that the current state of pattern synonym signatures is quite
>     confusing, especially regarding the constraints. [...]
> 
> 
> Thanks to an off-list email from Matthew (thanks for that!) I found out that
> 
>    pattern FOO = 1234 :: Int
> 
> behaves differently from
> 
>    pattern FOO :: Int
>    pattern FOO = 1234
> 
> In the former case one has to use ScopedTypeVariables, in the latter
> case it works without it. This is not really intuitive, although I'll
> have to admit that I've had only a cursory look at the "Typing of
> pattern synonyms" section in the GHC manual. But even after re-reading
> it, it's not really clear where the difference in the above example
> comes from.
> 
> So in a nutshell: +1 for the "quite confusing" argument.

Isn't that consistent with patterns in general, where something like

    f (5 :: Int) = 6

is only legal with ScopedTypeVariables on?

Cheers,

Ganesh



More information about the ghc-devs mailing list