Why re-binding to a socket will fail randomly?

This question is related to a question about getting a free port in Haskell, where I included a getFreePort function that retrieved the first available port. This function works on a Windows system, but when I tried on my Linux box it fails randomly ...
more »

2017-08-17 19:08 (1) Answers

Fast-logger clean up action (haskell)

I'm willing to use the fast-logger haskell library, but i have some questions: Function newTimedFastLogger is explained as: Initialize a FastLogger with timestamp attached to each message. a tuple of logger and clean up action are returned. So...
more »

2017-08-17 14:08 (1) Answers

Specialization of singleton parameters

I'm playing around with specialization of singletons: {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE KindSignatures #-} module Data.Test where data SingBool (b :: Bool) where STrue :: SingBool 'True SFalse :: Sing...
more »

2017-08-17 13:08 (1) Answers

Impose constraint on MonadIO return type

I'm trying to make an instance of MonadIO for a type that represents computations in the cloud. So liftIO would represent an IO action that is executed locally. transient-universe, the library that provides this, provides a function localIO that doe...
more »

2017-08-17 12:08 (0) Answers

Ctrl-c causes cygwin to crash on ghci

Im trying to start to learn Haskell and I am using cygwin to do so as I like the linux type commands. However when I try to exit from a session with Ctrl-C the console freezes and crashes, this problem also occurs on cmd Similarly putting it to sle...
more »

2017-08-17 07:08 (1) Answers

seq vs. rnf in Haskell

According to the definitions given by "Parallel and Concurrent Programming in Haskell" on page 29, the class method "return normal form" is defined as: rnf a = a `seq` () Just to see if wrapping seq in another function, as the authors prescribe, r...
more »

2017-08-16 17:08 (1) Answers

How to do generalization?

Earlier, it used to have map and sequence with following implementation: mapM :: Monad m => (a -> m b) -> [a] -> m [b] sequence :: Monad m => [m a] -> m [a] then haskell contributors did generalize to: traverse :: Applicati...
more »

2017-08-16 12:08 (1) Answers

How does Haskell function `tell` work

I'm learning do expression and Monad using LEARN YOU A HASKELL FOR GREAT GOOD. There's a gcd implementation using tell function makes me confused. gcd :: Int -> Int -> Writer [String] Int gcd a b | b == 0 = tell ["Finished with " ++ show a ]...
more »

2017-08-16 07:08 (1) Answers

Using haskell in atom - ghc mod error

I have installed Haskell minimal installer on Windows 10. I have been using haskell by writiting small programs in Notepad++ and running then by ghci using ':l myfile.hs' I have now installed the hackable 'ATOM' text editor and installed the atom-ha...
more »

2017-08-16 06:08 (1) Answers

Monadic "double-bind"

Is it possible to resolve y as a function of f and x, if the monads N and M are one-way? x :: M (N X) f :: X -> M (N Y) -- pattern matching not allowed, one-way monads implied y :: M (N Y) y = _ Full definitions: data X = X data Y = Y -- pa...
more »

2017-08-15 20:08 (0) Answers

How to install d3js Haskell package?

I'd just like to try the Haskell d3js package. Here's what I tried: stack install d3js But it gives the error: Error: While constructing the build plan, the following exceptions were encountered: In the dependencies for d3js- base-...
more »

2017-08-15 17:08 (2) Answers

How to convert Dynamic to Forall something

I have a cache with Dynamic values. Some of them have the type Delayed a. Normally when I access the cache, I know the type a, so it's not a problem, I can use fromDynamic to cast to Maybe a. I would like to call a function which doesn't need to kn...
more »

2017-08-15 16:08 (2) Answers

Haskell Yesod get user credentials in subsite

I'm writing a subsite for my yesod project, and I need to display the logged in user's name on that subsite (I'm using yesod-auth hardcoded where the type of AuthId master = Text). However, the user is logged in on the master site. I'm able to get a...
more »

2017-08-15 16:08 (1) Answers

Elegant egress from `Async` actions

Is there a simple way of cancelling an Async a value, such that it won't be interrupted in the middle of some critical action? I suppose I could use a semaphore inside a loop condition. async $ whileM readSemaphore runLoopBody But I'd like to know...
more »

2017-08-15 14:08 (1) Answers

Type-preserving rounding in Haskell

Is there a built-in function in Haskell that rounds a real floating-point number to the nearest whole number, without changing the type of said number? sameTypeRound f == fromIntegral (round f) ...
more »

2017-08-15 07:08 (0) Answers