[Haskell-cafe] Are all monads functions?

2011-12-31 Thread Yves Parès
Hello Café, One thought occur to me recently when explaining the concept of Monad to non-haskellers: internally, all standard Monads are newtypes wrapping functions: StateT is, WriterT is, ContT is. Even IO and ST are, both conceptually and in their implementation by GHC. ParsecT (not part of

Re: [Haskell-cafe] Are all monads functions?

2011-12-31 Thread Jerzy Karczmarczuk
Yves Parès : all standard Monads are newtypes wrapping functions What about Maybe and [] ? Jerzy Karczmarczuk ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Are all monads functions?

2011-12-31 Thread Stephen Tetley
On 31 December 2011 12:26, Jerzy Karczmarczuk jerzy.karczmarc...@unicaen.fr wrote: Yves Parès : all standard Monads are newtypes wrapping functions What about Maybe and [] ? And Identity ... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Are all monads functions?

2011-12-31 Thread Yves Parès
Maybe and [] have still the same meaning: they can be seen as functions: - they represent the result(s) that might or might not have a computation - *they have to be called/ran/executed* (wichever term you prefer) through Data.Maybe.maybe or Data.List.foldX, so that we can extract some value out

Re: [Haskell-cafe] Are all monads functions?

2011-12-31 Thread Roman Cheplyaka
* Yves Parès limestrael+hask...@gmail.com [2011-12-31 13:09:37+0100] One thought occur to me recently when explaining the concept of Monad to non-haskellers: internally, all standard Monads are newtypes wrapping functions: StateT is, WriterT is, ContT is. Even IO and ST are, both conceptually

Re: [Haskell-cafe] Are all monads functions?

2011-12-31 Thread Yves Parès
Thanks for the explanation on free monads, it's interesting. But still, I maintain my previous view. I could clarify that by saying that (e.g. for Maybe) we could separate it in two types, Maybe itself and its monad: -- The plain Maybe type data Maybe a = Just a | Nothing -- The MaybeMonad

Re: [Haskell-cafe] Are all monads functions?

2011-12-31 Thread Chris Smith
On Dec 31, 2011 8:19 AM, Yves Parès limestrael+hask...@gmail.com wrote: -- The plain Maybe type data Maybe a = Just a | Nothing -- The MaybeMonad newtype MaybeMonad a = MM ( () - Maybe a ) That's what using Maybe as a monad semantically means, doesn't it? I'd have to say no. That Maybe

[Haskell-cafe] Avoiding parametric function binding

2011-12-31 Thread Kevin Quick
I'm having some difficulty avoiding a tight parametric binding of function parameters, which is limiting the (de)composability of my expressions. I'm curious as to whether there is an option or method I haven't tried to achieve this. Here's an example test case: data Var = V1 (Maybe

Re: [Haskell-cafe] Avoiding parametric function binding

2011-12-31 Thread Stephen Tetley
Maybe you want a deconstructor (sometime called an eliminator)? deconsVar :: (Maybe Int - a) - (Maybe String - a) - Var - a deconsVar f g (V1 a) = f a deconsVar f g (V2 b) = g b ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Avoiding parametric function binding

2011-12-31 Thread Kevin Quick
On Sat, 31 Dec 2011 08:50:05 -0700, Stephen Tetley stephen.tet...@gmail.com wrote: Maybe you want a deconstructor (sometime called an eliminator)? deconsVar :: (Maybe Int - a) - (Maybe String - a) - Var - a deconsVar f g (V1 a) = f a deconsVar f g (V2 b) = g b That works and has the

Re: [Haskell-cafe] Are all monads functions?

2011-12-31 Thread Steve Horne
On 31/12/2011 13:18, Yves Parès wrote: But still, I maintain my previous view. I could clarify that by saying that (e.g. for Maybe) we could separate it in two types, Maybe itself and its monad: -- The plain Maybe type data Maybe a = Just a | Nothing -- The MaybeMonad newtype MaybeMonad a =

Re: [Haskell-cafe] Are all monads functions?

2011-12-31 Thread Ertugrul Söylemez
Yves Parès limestrael+hask...@gmail.com wrote: But still, I maintain my previous view. I could clarify that by saying that (e.g. for Maybe) we could separate it in two types, Maybe itself and its monad: -- The plain Maybe type data Maybe a = Just a | Nothing -- The MaybeMonad newtype

Re: [Haskell-cafe] Avoiding parametric function binding

2011-12-31 Thread Yucheng Zhang
On Sat, Dec 31, 2011 at 11:09 PM, Kevin Quick qu...@sparq.org wrote: varElem :: forall x . (Show x) = Var - x varElem (V1 x) = x varElem (V2 x) = x main = putStrLn . elemStr . varElem $ test The problem here is that you want the return type to depend on the 'value' of Var, which is not

Re: [Haskell-cafe] Are all monads functions?

2011-12-31 Thread Conal Elliott
In that sense every value in maths is a function. In other words: Your extension of everything (!) to functions is redundant. And function is not unique in this way. All types can be embedded into pairs also, e.g., newtype MyInt = MyInt ((),Int), or newtype MyInt = MyInt (((),Int),()), etc.