ghc

gitlab-CI for a Haskell Stack project: How to cache built libraries?

試著忘記壹切 提交于 2019-12-10 16:06:09
问题 I'm using the following .gitlab-ci.yml file for setting up gitlab-CI for a Haskell Stack project created with stack new actividad3 --resolver=lts-14.6 . image: haskell:8.6.5 cache: paths: - .stack - .stack-work - target test: stage: test script: - ghc --version - stack --system-ghc build - stack test Building and testing the project last almost 5 minutes. Most of the time is spent building the hspec library. Is there any way to cache the used libraries between pipeline runs? Thanks in advance

Failed to install haskell-src-exts-1.16.0 on OSX 10.9.5

时光总嘲笑我的痴心妄想 提交于 2019-12-10 15:40:04
问题 My env: ghc 7.8.3 from http://ghcformacosx.github.io/ OSX 10.9.5 cabal 1.20.0.3 (directly from ghc for mac osx) I did cabal install alex and cabal install happy . cabal binary path was confirmed to be added to my $PATH as $(HOME)/Library/Haskell/bin/ . cabal install haskell-src-exts emitted the following compiling error: [19 of 22] Compiling Language.Haskell.Exts.InternalParser ( dist/build/Language/Haskell/Exts/InternalParser.hs, dist/build/Language/Haskell/Exts/InternalParser.o ) templates

Understanding a case of Haskell Type-Ambiguity

泪湿孤枕 提交于 2019-12-10 15:32:00
问题 I wrote a Haskell program and got a compile error I don't understand. The program should: Get the command line arguments Concatenate tokenized arguments back to a single String Read the String into a NestedList data type Flatten the NestedList into a List Print the List Unfortunately, it won't compile because of a type ambiguity. Haskell Code: {- Run like this: $ ./prog List [Elem 1, List [Elem 2, List [Elem 3, Elem 4], Elem 5]] Output: [1,2,3,4,5] -} import System.Environment import Data

Does ghc-gc-tune 0.2.1 work with ghc 7.4.1?

浪尽此生 提交于 2019-12-10 15:29:09
问题 Does ghc-gc-tune 0.2.1 work with ghc 7.4.1? It seems ghc-gc-tune has not been updated for quite a while and may only work with ghc 6.x? I cannot find any reliable information on this. I get the following error: ghc-gc-tune: Can't parse GC stats: " ,(\"num_GCs\", \"320602\")\n ,(\"average_bytes_used\", \"105444\")\n ,(\"max_bytes_used\", \"131296\")\n ,(\"num_byte_usage_samples\", \"1677\")\n ,(\"peak_megabytes_allocated\", \"2\")\n ,(\"init_cpu_seconds\", \"0.00\")\n ,(\"init_wall_seconds\",

Understanding BlockedIndefinitelyOnMVar in Concurrent code

隐身守侯 提交于 2019-12-10 15:07:43
问题 I asked this question on the ghc-users mailing list and got some helpful responses, but still don't understand what is happening in this code. Essentially I am trying to understand how I can catch the exception BlockedIndefinitelyOnMVar to restore a lock that may have not been returned, and to understand this exception in general. Here is some single-threaded code that does just that: -- This raises the exception only once and the lock is successfully restored: main1 = do lock <- newMVar ()

How to use a proxy in Haskell? (probably using a higher-rank types extension)

懵懂的女人 提交于 2019-12-10 14:17:57
问题 For the last few months, I've been putting some serious effort into learning Haskell - previously, I was a seemingly perpetual newbie with a very limited knowledge of the basics. While trying to put my new knowledge into practice on few-steps-up-from-hello-world projects, I keep finding that I want to use proxy-like patterns based on type classes. The first couple of times, when I figured out why it wasn't working, I dismissed it as "OK - I may not find a single idiomatic Haskell replacement,

Ambiguous type variable `a0' arising from a use of `it'

微笑、不失礼 提交于 2019-12-10 13:56:43
问题 I have the following function to return the Factor Pairs for a given number factorPairs:: (RealFrac a, Floating a, Integral a) => a -> [(a, a)] factorPairs n = map(\x -> (x, div n x)) [y | y <- [1..(ceiling $ sqrt n)], n `rem` y == 0] When I call the function in ghci factorPairs 18 I'm getting a run time error of * Ambiguous type variable `a0' arising from a use of `it' prevents the constraint `(Floating a0)' from being solved. Probable fix: use a type annotation to specify what `a0' should

Repeated evaluation of pure expression in IO action

本小妞迷上赌 提交于 2019-12-10 13:53:49
问题 I have a procedure that (a) does some IO, (b) constructs a lookup table, and (c) returns an IO action that uses the lookup table. But when compiled with -O , GHC (version 6.12.1) inlines the construction the lookup table, so that it is reevaluated for every call of the IO action. Example: module Main where import Data.Array import Data.IORef import Control.Monad makeAction getX getY sumRef = do x <- getX let a = listArray (0, 1000) [x ..] return $ do y <- getY modifyIORef sumRef (\sum -> sum

After upgrading to GHC7, all programs suddenly fail saying “Most RTS options are disabled. Link with -rtsopts to enable them.”

自作多情 提交于 2019-12-10 13:21:06
问题 Haskell tools compiled in the upgraded environment fail with this message, regardless of command line parameters. 回答1: As it turns out, RTS options can pose a security issue, so they can be disabled in GHC7. Then, when a RTS option is passed to such a program, it fails. The problem was that I had GHCRTS environment variable set, which is added to RTS options of all Haskell programs. Clearing this environment variable solved the issue. 来源: https://stackoverflow.com/questions/12133000/after

Generate LLVM IR from Haskell code

拥有回忆 提交于 2019-12-10 13:02:00
问题 My goal is take source codes in different languages (mostly C, C++, Obj-C and Haskell) and tell every kind of statistics about them. (eg. number of variables, functions, memory allocations, complexity etc.) LLVM seemed to be a perfect tool for this, because I can generate the bitcode for these languages and with LLVM's customizable passes I can almost do anything. For the C family it works fine, take a C program ( test.c ) for example: #include <stdio.h> int main( ) { int num1, num2, sum;