[Haskell-cafe] Re: Keys and Maps [Was: Re: I just don't get it (data structures and OO)]

Justin Bailey jgbailey at gmail.com
Thu Jun 7 18:07:55 EDT 2007


On 6/7/07, Grzegorz <grzegorz.chrupala at computing.dcu.ie> wrote:
>
> All this hard work for something that in a lesser language would be the
> unimpressive:  universe["Milky Way"]["Sun"] ;-P

Well, if you want to get picky there is the '!' operator defined in Data.Map:

> import Data.Map

> universe :: Map String (Map String String)
> universe = fromList [("Milky Way", fromList [("Sun", "It's home!")])]

> earth :: String
> earth = universe ! "Milky Way" ! "Sun"

Justin


More information about the Haskell-Cafe mailing list