ghc

Haskell program outputs `<<loop>>`

核能气质少年 提交于 2019-12-17 16:32:23
问题 I wrote a Haskell program that preforms a binary search on a list. At least that's what I thought it does. When I compiled the program with ghc v7.6.3 and ran the program I got the following output: progname: <<loop>> What on earth does this output mean? Does it mean I had an infinite loop that ghc optimized away? How am I supposed to debug this? 回答1: As several of the comments have said, this is the Haskell RTS detecting an infinite loop at run-time. It cannot always detect such loops, but

Extracting the exponent and mantissa of a Javascript Number

百般思念 提交于 2019-12-17 10:49:10
问题 Is there a reasonably fast way to extract the exponent and mantissa from a Number in Javascript? AFAIK there's no way to get at the bits behind a Number in Javascript, which makes it seem to me that I'm looking at a factorization problem: finding m and n such that 2^n * m = k for a given k . Since integer factorization is in NP, I can only assume that this would be a fairly hard problem. I'm implementing a GHC plugin for generating Javascript and need to implement the decodeFloat_Int# and

GHCI Haskell not remembering bindings in command line

久未见 提交于 2019-12-13 22:31:19
问题 I am trying to learn Haskell but it is a little hard as non of my bindings are remembered from the command line; output from my terminal below. > let b = [] > b [] > 1:b [1] > b [] I have no idea why this is like this can anyone please help. 回答1: What did you expect your example to do? From what you've presented, I don't see anything surprising. Of course, that answer is probably surprising to you, or you wouldn't have asked. And I'll be honest: I can guess what you were expecting. If I'm

Show substitutions in ghci

自作多情 提交于 2019-12-13 17:16:05
问题 How can I see substitutions of variable names to their values in haskell? e.g. c2i zero ==> c2i (Chr (\x y -> y)) ==> (\x y -> y) (+ 1) 0 ==> 0 As explained in this answer. 来源: https://stackoverflow.com/questions/36650044/show-substitutions-in-ghci

Ambiguous occurrence `Just'

风格不统一 提交于 2019-12-13 14:15:42
问题 I am an absolute beginner. Going through LYAH using emacs. My current Set up: Ubuntu 12.04 LTS (Use Experience - beginner) GNU Emacs 23 (Use Experience - beginner) able to work in haskell major mode Finding difficult to follow instructions (to bring haskell libraries) at Point 2 described here. Also need guidance to enable Scion IDE. Problem: .hs code data Maybe a = Nothing | Just a While running the code, I get following error: Please ignore typo error, Originally posted: *Main> just "Haha"

Profiling a partially evaluated program

耗尽温柔 提交于 2019-12-13 12:25:49
问题 For the purposes of profiling a partially evaluated program, I'm interested in knowing the best way to terminate a GHC program. This is useful for profiling programs that take a long time to run, possibly as long as forever. With GHC 7.4.2, I was able to profile a non-terminating program by enabling profiling (-prof -auto-all) and running my program with +RTS -p . This generated incremental profiling data. The program could be killed with ^c , and the .prof file would contain data. In GHC 7.6

Cabal install error: The package has a './configure' script. This requires a Unix

心不动则不痛 提交于 2019-12-13 12:21:30
问题 I'm trying to install network and old-time with cabal-install. When I try to install either it fails with: setup.exe: The package has a './configure' script. This requires a Unix compatibility toolchain such as MinGW+MSYS or Cygwin. I do have MinGW, in fact it's the MinGW distributed along with GHC. I've also added the bin folder to my PATH. How can I fix this? what tool is the one actually running the configure files? maybe I need to get it? GHC 7.10.1 x64 cabal-install version 1.22.0.0

Stack test output garbled on MINGW64

柔情痞子 提交于 2019-12-13 00:33:00
问题 I'm running GHC using Stack on Windows 10, and using Git Bash (MINGW64) for much of my daily workflow. That includes using GHC and GHCi, which generally works fine. However, when I run stack test from MINGW64, the output is garbled by ANSI color codes: $ stack test UC-0.1.0.0: test (suite: UC-test) [?25lSorting Group 1: [2K[1F prop1: [[92mOK, passed 100 tests[0m] [2K[1F prop2: [[92mOK, passed 100 tests[0m] Properties Total Passed [92m2[0m [92m2[0m Failed 0 0 Total [92m2[0m [92m2[0m [?25h

How to declare type of this function?

*爱你&永不变心* 提交于 2019-12-13 00:32:32
问题 I'm using vector library and trying to write simple function: import qualified Data.Vector.Generic as GV setCharges :: GV.Vector v Double => Network -> v Double -> Network setCharges n cs = n{nodes = GV.zipWith setCharge (nodes n) cs} With XFlexibleContexts ghc accepts type declaration but complain near cs varibale Could not deduce (v ~ Vector) I have nodes n :: Data.Vector.Vector Node setCharge :: Node -> Double -> Node Don't really get, what the problem. 回答1: It's just what GHC says: the

Building a haskell interpreter (hint) as dynamic library, useable from C++: Missing Interpreter.dyn_hi

筅森魡賤 提交于 2019-12-12 16:17:13
问题 I want to create a haskell interpreter that I can use from C++ on linux. I have a file FFIInterpreter.hs which implements the interpreter in haskell and exports the functions via FFI to C++. module FFIInterpreter where import Language.Haskell.Interpreter import Data.IORef import Foreign.StablePtr import Foreign.C.Types import Foreign.C.String import Control.Monad import Foreign.Marshal.Alloc type Session = Interpreter () type Context = StablePtr (IORef Session) foreign export ccall