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

Christopher Allen cma at bitemyapp.com
Sat Aug 4 18:16:00 UTC 2018


Could someone give me a motivating example for what this enables?

If there is such in the paper, a link to the paper is fine.

On Sat, Aug 4, 2018 at 10:27 AM, Joachim Breitner
<mail at joachim-breitner.de> wrote:
> Hi,
>
> can we have an additional nod by someone who is not an author of the
> corresponding paper?
>
> Also, I updated the proposal to answer the disambiguation with as-
> patterns:
> https://github.com/ghc-proposals/ghc-proposals/pull/126/commits/12d64105b0979c674502c3768118b424d09a572b
> And I would like a second pair of eyes there, as this choice blocks us
> from in the future allowing patterns on both sides on @, i.e. something
> like
>
>    Just (_ :_) @ (fun -> True) @ x
>
> because
>
>    Nothing @ a
>
> would be ambiguous.
>
> Cheers,
> Joachim
>
> Am Donnerstag, den 26.07.2018, 11:08 +0300 schrieb Iavor Diatchki:
>> let's also start the discussion on feature request 126.   The idea here is that we allow the @ notation for explicit type applications to also be used on constructors in patterns.  Using @ with a constructor in a pattern has the same meaning as it does it an expression:  the provided type is used to instantiate the corresponding type parameter of the constructor.   If the type contains variables, those are treated in the same way as in #128, where "unbound" variables name the matching types.   Here are some examples:
>>
>>     f1 (Just @Int x) = x    -- This has type `Maybe Int -> Int`
>>
>>     f2 (Just @[a] x) = x == "c"   -- `a` is an alias for `Char`
>>
>>     f3 (SomeException @e ex) = ...  -- `e` is a name for the existentially hidden exception type
>>
>> Overall I think that is a simple and natural extension to the way @ already works, and I propose that we accept it.
>>
>> Thoughts?
>>
>> -Iavor
>>
>>
>> _______________________________________________
>> ghc-steering-committee mailing list
>> ghc-steering-committee at haskell.org
>> https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
> --
> Joachim Breitner
>   mail at joachim-breitner.de
>   http://www.joachim-breitner.de/
>
> _______________________________________________
> ghc-steering-committee mailing list
> ghc-steering-committee at haskell.org
> https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
>



-- 
Chris Allen
Currently working on http://haskellbook.com


More information about the ghc-steering-committee mailing list