sebastian-philipp / StringMap

Haskell Project to convert the PrefixTree of the Holumbus into it's own Hackage Packet
MIT License
1 stars 5 forks source link

StringMap is an instance of Bind #5

Open sebastian-philipp opened 10 years ago

sebastian-philipp commented 10 years ago

Bind (Bindable Functor) is a Monad without return

UweSchmidt commented 10 years ago

Then we can make StringMap an instance of Monad with

return v = singleton "" v
sebastian-philipp commented 10 years ago

I don't think using an empty string as default is a good idea. Anyway, I don't think it's worth the effort

ghci Data.Functor.Bind Data.Map> fromList [("foo",5), ("bar",1)] >>- (\x -> fromList [("foo", x + 1), ("bar", x - 1), ("baz", x * 2)])
fromList [("bar",0),("foo",6)]