ghc

Convert a “do” notation with more than two actions to use the bind function

主宰稳场 提交于 2019-12-30 18:42:07
问题 I know that the following "do" notation's "bind" function is equivalent to getLine >>= \line -> putStrLn do line <- getLine putStrLn line But how is the following notation equivalent to bind function? do line1 <- getLine putStrLn "enter second line" line2 <- getLine return (line1,line2) 回答1: I take it you are trying to see how to bind the result of "putStrLn". The answer is in the type of putStrLn: putStrLn :: String -> IO () Remember that "()" is the unit type, which has a single value (also

How to install Haskell Platform on Linux Debian Wheezy?

瘦欲@ 提交于 2019-12-30 08:18:09
问题 Initially I thought I would get install Haskell with couple of commands using apt-get but its seems somehow complex. As I look at the haskell org download page, I downloaded haskell-platform-2013.2.0.0.tar.gz . Then next step is somehow confusing. It ask to install GHC before installing platform but at the same time if one opens GHC download page , it shows some warning e.g Stop ! ..... we recommend installing the Haskell Platform instead of GHC . Please guide me how to install Haskell on

How to install Haskell Platform on Linux Debian Wheezy?

半世苍凉 提交于 2019-12-30 08:16:19
问题 Initially I thought I would get install Haskell with couple of commands using apt-get but its seems somehow complex. As I look at the haskell org download page, I downloaded haskell-platform-2013.2.0.0.tar.gz . Then next step is somehow confusing. It ask to install GHC before installing platform but at the same time if one opens GHC download page , it shows some warning e.g Stop ! ..... we recommend installing the Haskell Platform instead of GHC . Please guide me how to install Haskell on

Why is there no `-XDeriveApplicative` extension?

扶醉桌前 提交于 2019-12-30 08:05:13
问题 GHC has several useful language extensions for mechanically deriving various common Haskell typeclasses ( -XDeriveFunctor , -XDeriveFoldable , -XDeriveTraversable ). It seems that Applicative is another class which is often needed and frequently easily derived. For a simple record containing slots of type a , e.g., data SimpleRecord a = Simple a a a the Applicative instance is trivially derived, instance Applicative SimpleRecord where pure x = Simple x x x Simple a1 b1 c1 <*> Simple a2 b2 c2

Why is there no `-XDeriveApplicative` extension?

家住魔仙堡 提交于 2019-12-30 08:04:08
问题 GHC has several useful language extensions for mechanically deriving various common Haskell typeclasses ( -XDeriveFunctor , -XDeriveFoldable , -XDeriveTraversable ). It seems that Applicative is another class which is often needed and frequently easily derived. For a simple record containing slots of type a , e.g., data SimpleRecord a = Simple a a a the Applicative instance is trivially derived, instance Applicative SimpleRecord where pure x = Simple x x x Simple a1 b1 c1 <*> Simple a2 b2 c2

Debugging a memory leak that doesn't show on heap profiling

99封情书 提交于 2019-12-30 03:38:12
问题 I'm working on a Haskell daemon that receives and processes JSON requests. While the operations of the daemon are complex, the main structure is intentionally kept simple: Its internal state is just an IORef with a data structure and all threads perform atomic operations on this IORef . Then there are a few threads that upon a trigger take the value a do something with it. The problem is that the daemon is leaking memory and I can't find out why. It's certainly related to the requests: when

How to [temporarily] suppress “defined but not used” warnings?

旧城冷巷雨未停 提交于 2019-12-29 07:22:39
问题 When I prototype Haskell programs, I always get hundreds of warnings like this (not joking): /Users/bob/SourceCode/course/is/expriment/LiftedSpine2.hs:70:15: Warning: Defined but not used: `ta' /Users/bob/SourceCode/course/is/expriment/LiftedSpine2.hs:72:15: Warning: Defined but not used: `ta' /Users/bob/SourceCode/course/is/expriment/LiftedSpine2.hs:77:26: Warning: Defined but not used: `v' Is there anyway to remove these warnings temporarily? I tried putting this in my .hs file: {-# OPTIONS

How are variable names chosen in type signatures inferred by GHC?

久未见 提交于 2019-12-29 07:00:48
问题 When I play with checking types of functions in Haskell with :t , for example like those in my previous question, I tend to get results such as: Eq a => a -> [a] -> Bool (Ord a, Num a, Ord a1, Num a1) => a -> a1 -> a (Num t2, Num t1, Num t, Enum t2, Enum t1, Enum t) => [(t, t1, t2)] It seems that this is not such a trivial question - how does the Haskell interpreter pick literals to symbolize typeclasses? When would it choose a rather than t ? When would it choose a1 rather than b ? Is it

Why are GHC Sparks Fizzling?

a 夏天 提交于 2019-12-29 06:22:50
问题 I have a simple routine that takes the product of a vector of Double . I am attempting to parallelize this code, but many of the sparks end up fizzling. Here is a self-contained benchmark which is also provided as a gist: {-# LANGUAGE BangPatterns #-} {-# LANGUAGE MagicHash #-} {-# OPTIONS_GHC -O2 -Wall -threaded -fforce-recomp #-} import Criterion.Main import Control.Monad (when) import Control.Parallel.Strategies (runEval,rpar,rseq) import qualified Data.Vector.Primitive as PV main :: IO ()

Statically link C++ library with a Haskell library

被刻印的时光 ゝ 提交于 2019-12-29 04:42:08
问题 Setup: I have a Haskell library HLib which makes calls to a C/C++ backend CLib for efficiency. The backend is small and specialized for use with HLib . The interface to CLib will only be exposed through HLib ; HLib tests, HLib benchmarks and third party libraries depending on HLib will not make direct FFI calls to CLib . From the test/benchmark/3rd party lib perspective, HLib should be appear purely Haskell. This means in the cabal file sections for, e.g., HLib tests, there should be no