Creighton Hogg schrieb:
> Okay, so I think what you want is
>
> [...]
Yes. Your solution works. Thank you. But:
> a <- msum . map return $ [1,2,3]
Why Do I need this "msum . map return" thing?
The "map return" part is somewhat clear. But not entirely. Which
type of monad is created here?
T
Hello list,
maybe I'm just stupid, I'm trying to do something like this:
import Control.Monad
import Control.Monad.Trans
import Control.Monad.List
foobar = do
a <- [1,2,3]
b <- [4,5,6]
liftIO $ putStrLn $ (show a) +
Hello list,
still playing with monads and states, I have the following question:
Given:
import Control.Monad.State.Lazy
data MyData = MyData { content :: String }
foobar :: State MyData String
foobar = do
gets content
Ok, that looks nice and tidy. But
Jules Bean schrieb:
> data Stack a b = Stack { run :: [a] -> (b, [a]) }
Thank you, that does the trick.
> The correct types for the other functions are:
>
> push :: a -> Stack a ()
> pop :: Stack a a
> top :: Stack a a
>
> With those clues I think you will be able to write >>= and return more
>
Miguel Mitrofanov schrieb:
> May be you can explain what do you want to do with this "monad"?
Pure educational purpose, just "learning by doing".
> What kind of code would you write if it would be such monad?
Useless stuff like:
s2 = do
push 11
push 17
co
at my operator (>>=) is of type:
Stack a -> (a -> Stack a) -> Stack a
but should be:
Stack a -> (a -> Stack b) -> Stack b
But, I have simply no clue how to fix that. :-(
Can anybody give my a hint?
Thank you in advance.
Michael Roth
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
even it is larger than the ruby solution, and more
imporant, the programm flow feels (at least to me) not very clear.
Are there any libraries available to make writing such tools easier?
How can I made the haskell source looking more beautiful?
Michael Roth
signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe