[prev in list] [next in list] [prev in thread] [next in thread]
List: haskell-cafe
Subject: Re: [Haskell-cafe] Is there any way to parametrize a value update
From: Alexey Khudyakov <alexey.skladnoy () gmail ! com>
Date: 2011-09-06 21:13:49
Message-ID: 4E668D0D.5000103 () gmail ! com
[Download RAW message or body]
On 07.09.2011 00:56, Brandon Allbery wrote:
> 2011/9/6 Poprádi Árpád <popradi_arpad@freemail.hu
> <mailto:popradi_arpad@freemail.hu>>
>
> updateData1 :: X -> MonadicEnv()
> updateData1 d = do; env <- get; put env {data1 = d}
>
>
> > updateData1 d = modify (\r -> r {data1 = d})
>
> But there is, sadly, no eta-reduced version of record update to make the
> "\r -> r ..." boilerplate go away; recognition of the syntax requires an
> expression before the braces. (Consider the ambiguity of the
> eta-reduced expression "modify {data1 = d}".) Also, and much more
> annoyingly, "data1" must be constant.
>
In principle ambiguity could be resolved with a slash:
modyfy \{data = d}
But that's from land of hypothetical language extension and dog headed
people.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic