Hi Chris!


On Aug 24, 2006, at 7:28 PM, Chris Kuklewicz wrote:

class Ref m r | m->r where
  newRef
  readRef
  writeRef

instance Ref IO IORef
  writeRef r x = writeIORef r $! x

instance (Ref m r) => Ref (WriterT m) r where
  writeRef = lift . writeRef

and so on...

The code snippet above looks like a very good idea.  The monad
dependent operations combined with "lift" seem more complicated
than necessary.  "lift" in particular often seems like plumbing that
should not be necessary.
Best Wishes,
Greg

Well, lift is the common plumbing that lets you build writeRef and liftIO. So it is an intermediate invention. In fact it is the only thing in MonadTrans:

class MonadTrans (t::(* -> *) -> * -> *) where
  lift :: forall (m::* -> *) a. Monad m => m a -> t m a
        -- Imported from Control.Monad.Trans


You are supposed to make higher level shorthand and abstractions from it.

But it helps to learn how the plumbing works.

I have no objection to good plumbing (I have some in my house).
I just usually like it to be out of sight in the wall or under the floor.

Which does lead to a mess in the case of leaks.... ;-)

Metaphorically,
Greg

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to