Re: [Haskell-cafe] Newbie Q: composeMaybe :: (a -> Maybe b) -> (b -> Maybe c) -> (a -> Maybe c)

2006-11-09 Thread Dmitri O.Kondratiev
Hey DeeJay, Thanks for detailed answer, it really helps as it shows the way I need to follow! It also helped me to realize that my question why f1 f g x = mapMaybe f (g x) has this type: f1 :: (a -> b) -> (t -> Maybe a) -> t -> Maybe b and not that (type which I expected): f1 :: (a -> b) -> (t ->

Re: [Haskell-cafe] Newbie Q: composeMaybe :: (a -> Maybe b) -> (b -> Maybe c) -> (a -> Maybe c)

2006-11-08 Thread DeeJay-G615
Hi Dmitri, your f1 function has 3 arguments, f, g and x. you pass f as the first argument to mapMaybe, so it naturally must have type (a -> b). you pass the result of (g x) to the second argument of mapMaybe, so (g x) must have type Maybe a. This means g must have the type (t -> Maybe a) where

[Haskell-cafe] Newbie Q: composeMaybe :: (a -> Maybe b) -> (b -> Maybe c) -> (a -> Maybe c)

2006-11-08 Thread Dmitri O.Kondratiev
I am trying to solve a problem from "The Craft of Functional Programming" book: 14.38 ... define the function: data Maybe a = Nothing | Just a composeMaybe :: (a -> Maybe b) -> (b -> Maybe c) -> (a -> Maybe c) using functions: squashMaybe :: Maybe (Maybe a) -> Maybe a squashMaybe (Just (Just x)