Concrete syntax for pattern synonym type signatures
ekmett at gmail.com
Sun Nov 9 19:42:52 UTC 2014
On Sun, Nov 9, 2014 at 2:11 PM, Simon Peyton Jones <simonpj at microsoft.com>
> On this thread:
> * I'm strongly of the opinion that pattern signatures should start
> pattern P :: ...blah...
Just like value signatures, the pattern name comes first,
> then a double colon.
This has the benefit that it lets users logically continue exporting
'pattern Foo', which is a very nice syntax.
The only downside is that the error message when users forget to turn on
pattern synonyms is somewhat more baroque than it can be with the extra
keyword shoehorned in, but the keyword is pretty awful looking.
> * One other possibility would be two => thus
> pattern P :: (Eq b) => (Num a, Eq a) => ...blha...
> If you wanted something which had a "match-required" part but no
> "match-provided" part, you'd end up with
> patter P :: () => (Num a, Eq a) => ...blah...
> which is a little odd, but perhaps no odder than
> pattern P :: ( | Num a, Eq a ) => ...blah...
The nested (=>) version has a certain appeal to it.
It already parses. The trick is just in properly interpreting it, but users
already interpret (Foo a, Bar b) => .. differently in different contexts,
e.g. in class and instance declarations. They can adapt.
> | -----Original Message-----
> | From: Dr. ERDI Gergo [mailto:gergo at erdi.hu]
> | Sent: 09 November 2014 07:56
> | To: Simon Peyton Jones
> | Cc: GHC Devs
> | Subject: RE: Concrete syntax for pattern synonym type signatures
> | On Tue, 4 Nov 2014, Simon Peyton Jones wrote:
> | > pattern P :: forall tvs. (match-provided ; match-required) => tau
> | >
> | > The "; match-required" part is optional, and the "match-provided" part
> | might be empty. So P1 and P2 would look like this:
> | >
> | > pattern P1 :: forall a. (; Num a) => b -> (a,b)
> | > pattern P2 :: forall a. (; Num a, Ord a) => a -> a
> | Doesn't the ';' look a bit like something that could be incidentially
> | introduced by some layout-aware syntax rule? Wouldn't, e.g., '|' be more
> | explicit as a separator?
> | example:
> | pattern P :: forall tvs. (Eq b | Num a, Eq a) => b -> T a
> ghc-devs mailing list
> ghc-devs at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs