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

apfelmus apfelmus at quantentunnel.de
Thu Jun 7 17:19:34 EDT 2007

Grzegorz wrote:
> apfelmus <apfelmus <at> quantentunnel.de> writes:
> [ .. lengthy discussion and implementation .. ]
>> As an example, we have
>>   Just "Earth" == lookup (at "Milky Way" </> at "Sun") universe
>> assuming that
>>   universe :: Data.Map String (Data.Map String String)
> All this hard work for something that in a lesser language would be the
> unimpressive:  universe["Milky Way"]["Sun"] ;-P

Yo, and the lesser language surely has first-class keys as in

     let worstCaseScenario k = forM_ parallelUniverses $ destroySystem k
     worstCaseScenario ["Milky Way"]["Sun"]

, right. Right? Hopefully not ;)

The Haskell version is safe though, as the old universes are still in
memory because there's no update in place. Very useful in case the
imperative imperator decides to segfault the space-time continuum and
thus destroys this and all parallel worlds. Don't worry, the old ones
are still there.


More information about the Haskell-Cafe mailing list