Folks,

I wonder if there is any particular reason for not having a class for object map of a functor (Functor-instances) in addition to the arrow map (fmap). Now you may say that this is just the constructor, but in my current example I have found it useful to have a general way of taking an object/value a into F a since the constructor can be arbitrary. I thought that I may need the return-operator in class Monad. I call it flift:

  class Lift f where
     flift :: a -> f a

This works nicely for trivial datatypes like "data Unit a = Unit" and "data Id a = Id a":

  instance Lift Unit where
     flift a = Unit

  instance Lift Id where
     flift a = Id a

My question is --- how would you define Lift for constructors such as data Sum a = Inl a|Inr a and so forth?

Best Wishes,
Johan Glimming

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

Reply via email to