GHC support for the new "record" package
Adam Gundry
adam at well-typed.com
Mon Jan 26 08:52:45 UTC 2015
Hi Konstantine,
On 24/01/15 11:55, Konstantine Rybnikov wrote:
> May I suggest something for a syntax (as an option, sorry if it's silly
> or not related)? I really don't like neither "@" or "#" because they
> seem too hacky, meanwhile GHC already has an "accessor" syntax with
> braces { and }, so, might it be an option to have something like:
>
> ```
> data Foo = Foo { val :: Int }
> data Bar = Bar { foo :: Foo }
>
> main = do
> let bar = Bar (Foo 10)
> print bar{foo{val}}
> let bar' = bar{foo{val}=10}
> return ()
>
> ```
>
> I think this syntax is 100% understandable for a "newbie". Not sure how
> is it related to lenses though.
>
> What do you think?
Thanks for thinking about this problem (we certainly need fresh ideas!)
but unfortunately this syntax is already taken by NamedFieldPuns, which
interprets
foo{val} ==> foo{val = val}
so I don't think we can easily use it. I'm still keen to find a better
solution than # or magic imports, though!
Adam
--
Adam Gundry, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com/
More information about the ghc-devs
mailing list