[Haskell-beginners] Syntactic sugar to insert into a Map?

Kim-Ee Yeoh ky3 at atamo.com
Mon Jul 22 00:44:02 CEST 2013


On Mon, Jul 22, 2013 at 12:06 AM, martin <martin.drautzburg at web.de> wrote:

> It seems like fromList is as pretty as it gets. Actually it is not
> that bad.
>

Agreed. What you might want to look  into is the difference between
/expressions/ and imperative statements, also known as /commands/.

The effectful nature of commands is typically modeled in Haskell using
monads, which may explain your references to do-notation and chaining
functions.

The mapping operations you're asking about can be easily /described/ using
expressions, so monads don't need to enter the picture. Minimize effects
whenever possible.

E.g.

> m0 = fromList [(key1,val1),(key2,val2)]
> m1 = m0 <> fromList [(key3,val3),(key4,val4)]

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130722/67fc62a0/attachment.htm>


More information about the Beginners mailing list