do-notation Questions

2

Solved

I have read in Learn you a Haskell, that list comprehensions in Haskell could be rewritten as monadic joins or (which is practically the same) do-notation. However, when I try to rewrite the follo...
Orphism asked 24/2, 2014 at 18:19

2

Solved

As far as I know, do blocks in Haskell are just some kind of syntactic sugar for monadic bind operators. For example, one could convert main = do f <- readFile "foo.txt" print f print "Finish...
Trollop asked 22/2, 2014 at 16:14

1

Solved

Apparently the only possible interpretation of runSomeMonad do ... is runSomeMonad (do ...). Why isn't the first variant allowed by the Haskell syntax? Is there some case where foo do bar could be ...
Metamathematics asked 20/2, 2014 at 19:12

1

Solved

I recently encountered an error while using threepenny-gui and it was solved by changing the code from pattern match in the do notation with <- to pattern matching with the let notation. Is th...
Kristin asked 17/11, 2013 at 2:51

2

Solved

Are the following two implementations of flatten equivalent for all well-behaved Monads? flatten1 xss = do xs <- xss x <- xs return x flatten2 xss = do xs <- xss xs
Cab asked 20/6, 2013 at 15:35

3

Solved

I´am trying to desugar a do statement in Haskell. I have found some examples here on SO but wasn´t able to apply them to my case. Only thing I can think of is a heavy nested let statement, which s...
Shantell asked 6/6, 2013 at 14:27

7

Most Haskell tutorials teach the use of do-notation for IO. I also started with the do-notation, but that makes my code look more like an imperative language more than a FP language. This week I ...
Contradictory asked 24/5, 2013 at 2:6

6

Solved

I started my Grand Haskell Crusade (GHC :) ) and I am a bit confused with monads and IO functions. Could anyone explain simply what is the difference between those two functions? f1 = do x <- [...
Nagano asked 4/7, 2012 at 6:7

1

Solved

I do not understand the difference between the three syntaxes: where a = f (b) do a <- f (b) do let a = f (b) I do understand somehow though that a <- f(b) is different from the other two...
Oar asked 13/2, 2012 at 0:25

1

Solved

I've got a series of network requests, that each take >10 seconds. So that the user knows what's happening, I give updates: main = do putStr "Downloading the first thing... " {- Net request -} p...
Paganism asked 2/12, 2011 at 19:26

1

Solved

As I'm learning Haskell I'm realizing that do notation is just syntatic sugar: a = do x <- [3..4] [1..2] return (x, 42) Translates into a = [3..4] >>= (\x -> [1..2] >>= (\_...
Fortna asked 5/11, 2011 at 10:44

2

Solved

F# Computation Expressions allow to hide the complexity of monadic syntax behind a thick layer of syntactic sugar. Is there something similar available in Scala? I think it's for comprehensions .....
Catatonia asked 20/9, 2011 at 3:55

3

Solved

input <- readLn if (input == 0) then putStr "0" else if (input ==1) then putStr "1" else if (input ==2) in this kind of senario how to use multiple putStr with in a then or else if ? ...
Safranine asked 8/6, 2011 at 18:53

4

Solved

I cannot figure out how to make the concise if-then-else notation work, mentioned at [ http://hackage.haskell.org/trac/haskell-prime/wiki/DoAndIfThenElse ]. This works, import System.Environment m...
Deictic asked 24/5, 2011 at 22:35

1

Solved

Possible Duplicate: Haskell “do nothing” IO, or if without else Something got wrong in these "easy" lines ... action = do isdir <- doesDirectoryExist path -- check if...
Nevis asked 7/5, 2011 at 12:2

2

Solved

Well, the question is self-explicative. Suppose I want to implement some special syntax just for fun. Is it possible? What tools should I use?
Sadowski asked 27/3, 2011 at 14:55

3

Solved

Can you create a list of functions and then execute them sequentially, perhaps passing them into do notation? I'm currently doing this by mapping over a list of data and am wondering if I can call...
Atheist asked 10/3, 2010 at 19:2

3

Solved

I'm trying to grasp the State Monad and with this purpose I wanted to write a monadic code that would generate a sequence of random numbers using a Linear Congruential Generator (probably not good,...
Dolora asked 24/12, 2009 at 3:32

© 2022 - 2024 — McMap. All rights reserved.