Suggestion: Syntactic sugar for Maps!

Alson Kemp alson at
Sat Dec 13 18:49:43 EST 2008

>>> circularfunc:
>>> > I suggest Haskell introduce some syntactic sugar for Maps.
>>> >
>>> > Python uses {"this": 2, "is": 1, "a": 1, "Map": 1}
>>> >
>>> > Clojure also use braces: {:k1 1 :k2 3} where whitespace is comma but
>>> > commas are also allowed.
>>> >
>>> > I find the import Data.Map and then fromList [("hello",1), ("there",
>>> > 2)] or the other form that I forgot(because it is to long!) to be to
>>> > long...
>>> >
>>> > So why not {"hello": 1, "there": 2} ?

A comment from the peanut gallery:
  I took circ's comment to be a suggestion that we adopt an _idiom_.
That you can non-idiomatically accomplish the same thing in Haskell by
defining some datatypes and functions doesn't seem to address the core

  I'd rewrite circ's suggestion as follows:
   A bunch of modern and popular languages use the idiom of braces for
maps (e.g. { 'a' => 1, 'b' => 2} ).  Its simplicity has made maps
vital parts of most programs.  Much of the world has adopted this
idiom and if Haskell adopts this syntactic sugar it will make it
easier for others to adopt Haskell.

   Haskell is really interesting for a number of reasons.  Map syntax
isn't one of them but map syntax sugar would make adoption of Haskell
that much easier.  As I think Don S said, it's hard enough to adopt
Haskell, so let's make it easier when possible...

  - Alson

More information about the Haskell-prime mailing list