ghc

How does the GHC garbage collector / runtime know that it can create an array `inplace'

[亡魂溺海] 提交于 2019-12-06 04:43:20
问题 For example main = do let ls = [0..10000000] print ls This will create the array 'inplace', using O(1) memory. The following edit causes the program to run out of memory while executing. main = do let ls = [0..10000000] print ls print ls ls in this case must be kept in memory to be printed again. It would actually be heaps more memory efficient to recalculate the array again 'inplace' than to try to keep this in place. That's an aside though. My real question is "how and when does GHC

GHC Haskell performance of IPv4 address rendering

自古美人都是妖i 提交于 2019-12-06 03:15:56
I recently built a library for handling IPv4 address in haskell. I have written two functions to render an IPv4 address to Text and I am surprised that the naive approach outperforms the approach that I actually thought about. Here are the relevant pieces. First, there is the definition of IPv4 : newtype IPv4 = IPv4 { getIPv4 :: Word32 } Next we have the IP address renderer that I expected to perform well: toDotDecimalText :: IPv4 -> Text toDotDecimalText = LText.toStrict . TBuilder.toLazyText . toDotDecimalBuilder {-# INLINE toDotDecimalText #-} toDotDecimalBuilder :: IPv4 -> TBuilder.Builder

Export Haskell lib as DLL

冷暖自知 提交于 2019-12-06 03:04:15
问题 I am working with GHC version 7.6.1, following the steps in the docs for creating a DLL from a Haskell lib for using it in VBA: GHC Docs 7.6.1 # Make a DLL The files I use are the exact same ones as in the Docs. When it comes to compiling, the following to commands work nearly as expected: ghc -c Adder.hs ghc -c StartEnd.c The first command returns this: Adder.hs:7:1: Warning: the 'stdcall' calling convention is unsupported on this platform, treating as ccall When checking declaration:

Controlling memory allocation/GC in a simulation?

我与影子孤独终老i 提交于 2019-12-06 02:47:54
问题 I'm having a bit of trouble figuring out how to reduce memory usage and GC time in a simulation running in the State monad. Presently I have to run the compiled code with +RTS -K100M to avoid stack space overflow, and the GC stats are pretty hideous (see below). Here are relevant snippets of the code. Complete, working (GHC 7.4.1) code can be found at http://hpaste.org/68527. -- Lone algebraic data type holding the simulation configuration. data SimConfig = SimConfig { numDimensions :: !Int -

Why does `peek` with a polymorphic Ptr return GHC.Prim.Any when used with a bind?

假装没事ソ 提交于 2019-12-06 02:34:55
Using the low-level GNU Science Library bindings Bindings.Gsl.RandomNumberGeneration , I'm running into this odd type behavior in GHCi where binding changes return type from a peek into GHC.Prim.Any . I'm trying to understand why since I can't use the c'rng_alloc unless I retain the type of pointer to an rng . For eample: λ> :t c'gsl_rng_alloc c'gsl_rng_alloc :: Ptr C'gsl_rng_type -> IO (Ptr C'gsl_rng) λ> :t p'gsl_rng_mt19937 p'gsl_rng_mt19937 :: Ptr (Ptr gsl_rng_type) λ> :t peek p'gsl_rng_mt19937 peek p'gsl_rng_mt19937 :: IO (Ptr gsl_rng_type) λ> x <- peek p'gsl_rng_mt19937 λ> :t x x :: Ptr

Even more generalized newtype deriving

纵饮孤独 提交于 2019-12-05 20:12:39
问题 Newtypes are often used to change the behavior of certain types when used in certain class contexts. For example, one would use the Data.Monoid.All wrapper to change the behavior of Bool when used as a Monoid . I'm currently writing such a newtype wrapper that would apply to a large range of different types. The wrapper is supposed to change the behavior of one specific class instance. It might look like this: newtype Wrapper a = Wrapper a instance Special a => Special (Wrapper a) where -- ..

Can GHC link binaries against a libc implementation such as uclibc (used in OpenWrt by default)?

ε祈祈猫儿з 提交于 2019-12-05 17:59:21
问题 I am using Debian/MIPS+QEMU to build MIPS ports of PortFusion (a TCP tunneling solution). The resulting binaries are linked against GNU libc. Thus, they cannot be just copied over and used on vanilla OpenWrt which ships with uclibc instead of eglibc (which seems binary-compatible with GNU libc). Is there a way to link Haskell/GHC binaries on Debian/MIPS against uclibc instead of eglibc ? Can OpenWrt's using uclibc be really the reason why PortFusion binaries copied over from Debian fail to

Trouble Installing HTF with Cabal

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 17:53:52
I am trying to install HTF. However after I cabal install HTF I get this: Resolving dependencies... Configuring HTF-0.10.0.7... Warning: This package indirectly depends on multiple versions of the same package. This is highly likely to cause a compile failure. package regex-base-0.93.2 requires mtl-2.0.1.0 package aeson-0.6.0.2 requires mtl-2.1.2 package HTF-0.10.0.7 requires mtl-2.1.2 package mtl-2.0.1.0 requires transformers-0.2.2.0 package transformers-base-0.4.1 requires transformers-0.3.0.0 package mtl-2.1.2 requires transformers-0.3.0.0 package monad-control-0.3.1.4 requires transformers

GADT Type Inference with Higher-Kinded Types

*爱你&永不变心* 提交于 2019-12-05 16:23:24
I've got some code that compiles: {-# LANGUAGE ScopedTypeVariables, KindSignatures, GADTs, FlexibleContexts #-} module Foo where data Foo :: (* -> *) where Foo :: c m zp' -> Foo (c m zp) f :: forall c m zp d . Foo (c m zp) -> d f y@(Foo (x :: c m a)) = g x y g :: c m a -> Foo (c m b) -> d g = error "" The key thing I need in my real code is to convince GHC that if y has the type Foo (c m zp) and x has the type c' m' zp' , then c' ~ c and m' ~ m . The above code achieves this because I am able to call g . I want to change this code in two orthogonal ways, but I can't seem to figure out how to

Does Travis ci allow ghc versions larger than 7.8?

烂漫一生 提交于 2019-12-05 15:53:27
问题 I just created a Haskell Travis CI project with this .travis.yml : language: haskell ghc: - 7.8 - 7.10 But Travis interprets the second version as 7.1 : https://travis-ci.org/fhaust/dtw/jobs/57648139 The version is only recognized if I enclose it in quotes (though this results in other errors, since 7.10 is not a version available on Travis CI): language: haskell ghc: - 7.8 - "7.10" Is this a bug? Edit 2015-11-22 There is an open issue for GHC 7.10 on travis-ci: https://github.com/travis-ci