[ghc-steering-committee] Discussion about "Type Application in Patterns" (#126)

Simon Peyton Jones simonpj at microsoft.com
Thu Aug 16 23:22:46 UTC 2018


|    pattern Ascii :: String
|    pattern Ascii <- (all isAscii -> True)
| 
| and now
| 
|    foo (Ascii @ ('X':rest)) =
| 
| is now longer as silly…

That’s a good example.  It's easy to work around:

	pattern And p q = p at q

	foo (Ascii `And` ('X' : rest)) = ..

The proposal draw attention to whether ( (K) @type ) is or is not a legal pattern type application.   I think currently it is not.   So using "significant" parentheses would be another workaround.

Neither workaround is truly satisfactory, but I think the goodness of type applications in patterns (which we know we want) is more important than truly uniform and-patterns (which no one is asking for, yet).

Simon

| -----Original Message-----
| From: ghc-steering-committee <ghc-steering-committee-bounces at haskell.org>
| On Behalf Of Joachim Breitner
| Sent: 16 August 2018 23:02
| To: ghc-steering-committee at haskell.org
| Subject: Re: [ghc-steering-committee] Discussion about "Type Application
| in Patterns" (#126)
| 
| Hi,
| 
| Am Donnerstag, den 16.08.2018, 08:46 +0000 schrieb Simon Peyton Jones
| via ghc-steering-committee:
| > What would be ambiguous is this and-pattern:
| >         Nothing @ pat
| > (i.e. with a nullary contructor as the first of p1 at p2).  But that's a
| > pretty silly and-pattern so I think we could let this ambiguous case
| > resolve as a pattern type application.
| 
| nullary constructors can be synonyms!
| 
|    pattern Ascii :: String
|    pattern Ascii <- (all isAscii -> True)
| 
| and now
| 
|    foo (Ascii @ ('X':rest)) =
| 
| is now longer as silly…
| 
| >  You could I suppose write
| > (Nothing)@pat to get the and-pattern.
| 
| Significant parenthesis? Ugh.
| 
| But yeah, maybe it is good enough™ to deal with this particular corner.
| 
| Cheers,
| Joachim
| 
| 
| 
| --
| Joachim Breitner
|   mail at joachim-breitner.de
| 
| https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.joach
| im-
| breitner.de%2F&data=02%7C01%7Csimonpj%40microsoft.com%7C36168190ebda4
| 2b8bf1408d603c3e1bc%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C63670053
| 7181819165&sdata=xoZDGIrlYH6AS3Lq7VFSCWu311UV5RMCS0ZsrhhzvwA%3D&r
| eserved=0


More information about the ghc-steering-committee mailing list