io-monad Questions
1
Solved
Take the MaybeT monad transformer:
newtype MaybeT m a = MaybeT { runMaybeT :: m (Maybe a) }
I wouldn't have expected a different definition for it, because Maybe is just kind of a box with a (opti...
Nissensohn asked 11/4, 2024 at 20:25
5
Solved
The following program creates two threads running concurrently, that each sleep for a random amount of time, before printing a line of text to stdout.
import Control.Concurrent
import Control.Mona...
Pamphleteer asked 31/12, 2013 at 9:6
1
ZIO (https://zio.dev/) is a scala framework which has at its core the ZIO[R, E, A] datastructure and its site gives the following information for the three parameters:
ZIO
The ZIO[R, E, A] data ty...
Urethra asked 2/9, 2020 at 19:48
1
According to the cats official document: https://typelevel.org/cats-effect/typeclasses/liftio.html, if we want lift something from IO to other container, you should implement LiftIO trait, but the ...
Illconditioned asked 12/9, 2019 at 0:47
2
Solved
I have a map of string to IO like this Map[String, IO[String]], I want to transform it into IO[Map[String, String]]. How to do it?
Straley asked 27/12, 2018 at 13:36
3
Solved
I am trying to get a firm grasp of exceptions, so that I can improve my conditional loop implementation. To this end, I am staging various experiments, throwing stuff and seeing what gets caught.
...
Emory asked 7/8, 2019 at 19:58
1
Solved
Haskell wiki has the following question:
https://en.wikibooks.org/wiki/Haskell/Higher-order_functions
for :: a -> (a -> Bool) -> (a -> a) -> (a -> IO ()) -> IO ()
for i p f j...
1
Solved
Here is some Scala cats code using the IO Monad:
import java.util.concurrent.{ExecutorService, Executors}
import cats.effect.IO
import scala.concurrent.{ExecutionContext, ExecutionContextExecuto...
Oratorio asked 21/9, 2018 at 6:16
1
I have a Logger type of kind * -> * which can take any type and log the value in a file. I am trying to implement this in a monadic way so that I log and keep working the same. My code looks lik...
Fin asked 18/8, 2018 at 8:46
3
Is print in Haskell a pure function; why or why not? I'm thinking it's not, because it does not always return the same value as pure functions should.
Oira asked 16/11, 2017 at 17:52
2
Solved
I know there are some almost identical implementations in Scalaz of IO operators like putStrLn :: String -> IO () and getLine :: IO String but I mean about Scala standard API why there aren't su...
Virgule asked 23/6, 2017 at 13:8
1
Solved
I have a
foobar :: IO (ParseResult [(String,String)])
ParseResult is a monad defined here: https://hackage.haskell.org/package/haskell-src-exts-1.13.5/docs/Language-Haskell-Exts-Parser.html#t:P...
2
Solved
For better or for worse, Haskell's popular Servant library has made it common-place to run code in a monad transformer stack involving ExceptT err IO. Servant's own handler monad is ExceptT Servant...
Obduliaobdurate asked 2/11, 2016 at 3:35
1
Solved
I /think/ I have a similar misunderstanding of the language in two places involving how variable assignment works in do blocks, involving the IO monad. Could you help me understand (1) is it the sa...
2
Solved
Somewhat mystified by the following code. In non-toy version of the problem I'm trying to do a monadic computation in a monad Result, the values of which can only be constructed from within IO. See...
Berryman asked 31/5, 2016 at 6:40
1
Solved
Here's an excerpt of a domain-specific file-IO function I'm writing:
let
cp :: FilePath -> IO ()
cp "." = putStr "" -- OUCH!
cp ".." = putStr "" -- CRIKEY!
cp fname = custom logic here...
i...
2
After diving into monads I understand that they are a general concept to allow chaining computations inside some context (failing, non-determinism, state, etc) and there is no magic behind them.
S...
Horsefly asked 13/4, 2016 at 11:16
1
Solved
I have the following function that produces a random string of characters in multiples of 1024:
import System.Random
rchars :: Int -> [IO Char]
rchars n = map (\_ -> randomRIO ('a', 'z')) [...
Niedersachsen asked 13/2, 2016 at 15:47
1
Solved
I have written a file parser using the Parsec library. I would like to write a high-level unit test using the Tasty testing framework to ensure that the parser correctly parses some given files.
I...
Karren asked 9/10, 2015 at 14:22
2
Solved
I'm fairly new to Haskell and have been trying to find a way to pass multiple IO-tainted values to a function to deal with a C library. Most people seem to use the <- operator inside a do block,...
1
Solved
First of all, my apologies for the non-descriptive title. Since I have no idea what's actually going on I can't really make it any more specific.
Now for my question. I have implemented the follow...
1
Solved
When I looked at scalaz.effect.IO source code, I noticed that it has a method apply with the following signature:
sealed trait IO[A] {
def apply(rw: Tower[IvoryTower]): Trampoline[(Tower[IvoryTow...
4
Solved
To test my skills in Haskell, I decided I wanted to implement the very first game you find in Land of Lisp / Realm of Racket. The "Guess My Number" game. The game relies on mutable state to run, as...
Tayyebeb asked 27/1, 2015 at 19:21
4
Solved
The following function f attempts to read an Int twice by using an IO (Maybe Int) function twice, but “short-circuits” execution after successfully reading one Int:
readInt :: IO (Maybe Int)
f ::...
Infirmary asked 24/1, 2015 at 11:9
4
Solved
I have checked the possibility of duplicate question,
and cannot find the exact solution.
I wrote some function chain code in JavaScript as below, and works fine.
var log = function(args)
{
consol...
Squatness asked 16/1, 2015 at 9:22
1 Next >
© 2022 - 2025 — McMap. All rights reserved.