[Haskell-cafe] Functional references

Tim Newsham newsham at lava.net
Fri Sep 5 20:24:39 EDT 2008

> It's especially bad when modules are extremely likely to be used
> together, like Control.Monad.State & FRef, or Data.Map & the Prelude.
> You end up being required to import one or the other qualified.

I think in the case of State vs. FRef a simple solution is to make
two modules: FRef, which uses "get" and "set" and "modify"
naturally, and FRef.State which defines State equivalents without
polluting the namespace.  Then if you're working with pure functions
you can import FRef and use the natural names, and when you're using the 
State monad you can import FRef.State and get the State definitions
that dont interfere with the standard "get" and "modify" names.
In the rare case (I think, am I wrong?) where you use both State
and FRef "modify" and "get" definitions in the same file, you can
import the one you use less off qualified...

>  -- ryan

Tim Newsham

More information about the Haskell-Cafe mailing list