ghci

`stack ghci` fails when you include a project which imports Gloss

假装没事ソ 提交于 2019-12-23 18:00:30
问题 If you import Gloss within a Stack project and use stack ghci , you get the following error: GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help <command line>: can't load .so/.DLL for: /Users/v/hs/.stack-work/install/x86_64-osx/lts-3.7/7.10.2/lib/x86_64-osx-ghc-7.10.2/GLUT-2.7.0.3-FFXiDYE1CfiDHjNKroBerv/libHSGLUT-2.7.0.3-FFXiDYE1CfiDHjNKroBerv-ghc7.10.2.dylib (dlopen(/Users/v/hs/.stack-work/install/x86_64-osx/lts-3.7/7.10.2/lib/x86_64-osx-ghc-7.10.2/GLUT-2.7.0.3

stack ghci not loading up local modules?

回眸只為那壹抹淺笑 提交于 2019-12-23 16:32:50
问题 I have mainLogger.hs Logger.hs in my local directory where the mainLogger.hs reference the Logger module. When in stack ghci I :load mainLogger.hs I get the following error message : mainLogger.hs:6:18: Could not find module ‘Logger’ It is not a module in the current program, or in any known package. However if I can compile stack exec -- ghc mainLogger.hs and run stack runghc mainLogger2.hs or have stack exec -- ghci load the module correctly. Anyone knows what is preventing stack ghci from

Finding out which module a function belongs to

淺唱寂寞╮ 提交于 2019-12-23 15:43:18
问题 In ghci (haskell) is there a command which will tell me which module (out of the loaded modules) a function belongs to. e.g. if the function is called whichMod, then it would work as follows : Prelude>whichMod take Prelude Prelude>whichMod sort Data.List 回答1: You want the :i command (short for :info ). Prelude> :i take take :: Int -> [a] -> [a] -- Defined in GHC.List Prelude> :i sort Top level: Not in scope: `sort' Prelude> :m +Data.List Prelude Data.List> :i sort sort :: Ord a => [a] -> [a]

Haskell GHCi - Using EOF character on stdin with getContents

旧城冷巷雨未停 提交于 2019-12-23 09:15:48
问题 I like to parse strings ad hoc in Python by just pasting into the interpreter. >>> s = """Adams, John ... Washington,George ... Lincoln,Abraham ... Jefferson, Thomas ... """ >>> print "\n".join(x.split(",")[1].replace(" ", "") for x in s.strip().split("\n")) John George Abraham Thomas This works great using the Python interpreter, but I'd like to do this with Haskell/GHCi. Problem is, I can't paste multi-line strings. I can use getContents with an EOF character, but I can only do it once

Investigating (->) with ghci and trying to get to its roots

有些话、适合烂在心里 提交于 2019-12-23 09:12:33
问题 I am trying to use ghci to investigate type (->) . I'd love to understand why I can ask :t (+) , but not :t (->) : Prelude> :t (->) <interactive>:1:2: error: parse error on input ‘->’ Luckily, both operators allow investigation using :i , so I presume it's all because (+) is a method of class Num, whereas (->) is a data. Diving deeper into (->) : Prelude> :i (->) data (->) (a :: TYPE q) (b :: TYPE r) -- Defined in ‘GHC.Prim’ infixr 0 -> instance Applicative ((->) a) -- Defined in ‘GHC.Base’

ghci randomio type inference

帅比萌擦擦* 提交于 2019-12-22 18:24:07
问题 I am following https://en.wikibooks.org/wiki/Haskell/Understanding_monads/State, and randomIO prints an integer in ghci directly. Given its type is polymorphic, how does ghci know it's Int here? Are there some special rules for type inference in ghci ? GHCi> :m System.Random GHCi> :t randomIO randomIO :: Random a => IO a GHCi> randomIO -1557093684 GHCi> randomIO 1342278538 回答1: I suppose it is just simple Monomorphism restriction. Polymorphic types such as Num a => a are handled like Integer

Memory blowing up for strict sum/strict foldl in ghci

梦想与她 提交于 2019-12-22 12:37:41
问题 As mentioned in Why does (sum $ takeWhile (<10000000) [1..]) use so much memory? the following does not blow up the memory in ghci : foldl' (+) 0 $ takeWhile (< 10000000) [1 .. ] However if I create a file containing : import Data.List longList::[Int] longList = [1 .. ] result :: Int result = foldl' (+) 0 $ takeWhile (< 10000000) longList main = do print $ result and load into ghci, then upon running the program the memory consumption blows up. Why is this, and what can I do to fix the

Testing FFI Code (with “foreign import”s) with GHCi

99封情书 提交于 2019-12-22 04:04:29
问题 Good (your local time of day), everyone. I went through Real World Haskell's chapter on the Foreign Function Interface, and did some follow-up reading here. I'm now experimenting with binding to C functions, and I'd like some clarification on some things. The following is fairly clear: foreign import ccall unsafe "math.h sin" c_sin :: CDouble -> CDouble I can load this and code that uses it in ghci, and everything is fine. It even loads in the embedded ghci in emacs's Haskell mode. I find

How to set ghci options for cabal repl?

不想你离开。 提交于 2019-12-21 07:13:49
问题 I have a haskell project which I compile with -Werror by default. This means that when I run cabal repl it runs with the option -Werror turned on. This means that for example when I evaluate 2 + 2 I get the following error message: <interactive>:2:3: Warning: Defaulting the following constraint(s) to type `Integer' (Num a0) arising from a use of `+' In the expression: 2 + 2 In an equation for `it': it = 2 + 2 So I need a way to turn on the option, -w or maybe -Wwarn on by default for cabal

How to send text to GHCi process?

末鹿安然 提交于 2019-12-21 05:11:10
问题 I'm working on Haskell presentation engine Howerpoint. It is running in GHCi. I would like to create a function which would output a statement to current running GHCi session. It must work on Linux and Mac, Windows is not necessary. Function probably will have type executeStatement :: String -> IO () What I tried already: getProcessID and getParentProcessID and then sending something like echo 'xxx' > /proc/92856/fd/1 -bash: /proc/92856/fd/1: No such file or directory I also tried runCommand