[Haskell-cafe] Types and hashes of hashes,
trouble for a Java-programmer...
John Smith
smithsnorth at gmail.com
Mon Apr 13 11:42:33 EDT 2009
Hi, a java-programmer running into trouble while trying to learn Haskell.
I try to make a hash containing hashes but can not getting a value out of
the innermost hash - I keep running into type-trouble where IO and Maybe
monad is getting mixed?
My attempt:
removeMaybeHash x =
case x of
Just ref -> ref
Nothing -> HashTable.new (==) (\key -> key)
test = do
h <- HashTable.new (==) (\key -> key)
h1 <- HashTable.new (==) (\key -> key)
HashTable.insert h 3 h1
HashTable.insert h1 1 1000
maybeOuterHash <- HashTable.lookup h 3
res <- removeMaybe (removeMaybeHash maybeOuterHash) 1000
return res
Any clues?
In java this would be as simple as (pseudocode): h.lookup(3).lookup(1000)
Cheers,
Pedro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090413/97ed79be/attachment.htm
More information about the Haskell-Cafe
mailing list