[Haskell-cafe] Type constraints and classes

2009-04-26 Thread Neil Brown
Hi, I have a Haskell problem that keeps cropping up and I wondered if there was any solution/work-around/dirty-hack that could help. I keep wanting to define class instances for things like Functor or Monad, but with restrictions on the inner type. I'll explain with an example, because I

Re: [Haskell-cafe] Type constraints and classes

2009-04-26 Thread Miguel Mitrofanov
{-# LANGUAGE MultiParamTypeClasses #-} class Returnable m a where ret :: a - m a class Bindable m a b where bind :: m a - (a - m b) - m b newtype MOAMonad r m a = MOAMonad ((a - m r) - m r) instance Monad (MOAMonad r m) where return x = MOAMonad $ ($ x) MOAMonad h = f = MOAMonad $ \p - h

Re: [Haskell-cafe] Type constraints and classes

2009-04-26 Thread Thomas van Noort
This is a recurring problem[1] and I'm still looking for a really satisfying solution. The only working and non-verbose solution I found is the one Miguel suggests. Although I'm not too fond of splitting up the monadic functions into separate type classes. A similar solution is described

Re: [Haskell-cafe] Type constraints and classes

2009-04-26 Thread Brent Yorgey
On Sun, Apr 26, 2009 at 03:23:17PM +0200, Thomas van Noort wrote: This is a recurring problem[1] and I'm still looking for a really satisfying solution. The only working and non-verbose solution I found is the one Miguel suggests. Although I'm not too fond of splitting up the monadic