[Haskell-cafe] Combine pattern synonyms and record wild cards

rowan goemans goemansrowan at gmail.com
Mon Sep 12 08:33:07 UTC 2022


Hello all,

I'm playing with pattern synonyms to create a more intuitive API. 
Essentially what I would like is to allow a record wild card through a 
pattern synonym. Allow me to illustrate with an example.

I have a data type. `data Foo a = Foo { unFoo :: a }` and a type 
`FooMaybe a = Maybe (Foo a)`. Now I have a pattern synonym `pattern 
FooJust x = Just (Foo x)`. This works and I can match on it no problem. 
But by doing this I lose the ability to use RecordWildCards. I can do 
this `myFun (Just Foo{..}) but not this `myFun FooJust{..}`. Is there 
some way to use pattern synonym while preserving the ability of using 
record wild cards?

Best regards,

Rowan Goemans



More information about the Haskell-Cafe mailing list