ghc

What are the differences between inline-c and language-c-inline?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-01 08:56:28
问题 I've been briefly looking into quasi-quotation libraries for Haskell. These libraries allow Haskell to integrate with other languages. For integrating with C, there appears to be two packages with similar functionality: inline-c language-c-inline (which uses language-c-quote) As I'm looking to build a quasi-quotation library of my own, I'm interested in design choices, API differences, performance etc. The only difference I'm aware of is that language-c-quote supports C and Objective-C,

Linking a dynamic library (libjvm.dylib) in Mac OS X (rpath issue)

怎甘沉沦 提交于 2020-01-01 08:27:07
问题 I do have an application that requires linkage with libjvm (a library from the JDK needed to do JNI bindings). When I tell the location of libjvm.dylib using -L it successfully compiles and links. However when I run the binary I get: dyld: Library not loaded: @rpath/libjvm.dylib Referenced from: <my home directory>/./mybinary Reason: image not found So far I found out that I can run my binary specifying LD_LIBRARY_PATH like so: LD_LIBRARY_PATH=<path to libfolder installation> ./mybinary But

Installing & Building GHC with OSX Mavericks GHC

南笙酒味 提交于 2020-01-01 07:28:31
问题 Why doesn't my GHC 7.6.3 work after upgrading to OSX Mavericks? 回答1: It took a long time to figure out how to Work with both OSX 10.9 and GHC 7.6.3, and here are some tips to help you get back to building haskell code. Summary: Download command line tools for mavericks and use gcc version 4.2 (link to the correct gcc path in your ghc settings file) Steps: Download the command line tools for mavericks Install gcc-4.2 using homebrew brew install apple-gcc42 Edit your settings file, Line 2.

Lists of fixed length and type literals

主宰稳场 提交于 2020-01-01 04:57:31
问题 I'm trying to define a type for lists of fixed length in Haskell. When I use the standard way to encode natural numbers as types in unary, everything works fine. However, when I try to build everything on GHC's type literals, I run into tons of problems. My first shot at the desired list type was data List (n :: Nat) a where Nil :: List 0 a (:>) :: a -> List n a -> List (n+1) a which unfortunately didn't allow for writing a zip function with type zip :: List n a -> List n b -> List n (a,b) I

How to cap memory usage of Haskell threads

寵の児 提交于 2020-01-01 01:16:31
问题 In a Haskell program compiled with GHC, is it possible to programmatically guard against excessive memory usage? That is, have it notify the program when memory usage reaches a specified limit, preferably indicating the offending thread. For example, suppose I want to write a server, hosting a scripting language interpreter, that users can connect to. It's Turing-complete, so programs could theoretically use unlimited memory or time. Suppose each client is handled with a separate thread. If a

How to cap memory usage of Haskell threads

耗尽温柔 提交于 2020-01-01 01:16:13
问题 In a Haskell program compiled with GHC, is it possible to programmatically guard against excessive memory usage? That is, have it notify the program when memory usage reaches a specified limit, preferably indicating the offending thread. For example, suppose I want to write a server, hosting a scripting language interpreter, that users can connect to. It's Turing-complete, so programs could theoretically use unlimited memory or time. Suppose each client is handled with a separate thread. If a

Restricting string literals to Text only

拜拜、爱过 提交于 2019-12-31 11:00:10
问题 I'm aware that the OverloadedStrings language pragma wraps an implicit fromString around all string literals. What I'd like to do is not actually overload strings, but merely change their meaning so that they are always turned into Text , and therefore, using a string literal as a list of characters should result in a type error. It appears to be impossible to import the IsString class without also importing the String instance for that class. Does ghc provide some way for me to restrict

Techniques for Tracing Constraints

独自空忆成欢 提交于 2019-12-31 07:54:29
问题 Here's the scenario: I've written some code with a type signature and GHC complains could not deduce x ~ y for some x and y . You can usually throw GHC a bone and simply add the isomorphism to the function constraints, but this is a bad idea for several reasons: It does not emphasize understanding the code. You can end up with 5 constraints where one would have sufficed (for example, if the 5 are implied by one more specific constraint) You can end up with bogus constraints if you've done

GHC: Display of unicode characters

て烟熏妆下的殇ゞ 提交于 2019-12-31 03:23:07
问题 Further to my first question on the management of the unicode characters in the production of .exe file, this is also a bug in GHC? > print "Frère" "Fr\233re" 回答1: print x is equivalent to putStrLn (show x) , where show converts a type of the Show class to a string representation. In your case, x already has the String type. One might think that the String implementation of show would simply return its argument unchanged, but actually it transforms it into an ASCII string literal token with

Preventing caching of computation in Criterion benchmark

核能气质少年 提交于 2019-12-31 01:46:26
问题 The following code (suggested by Reid Barton at Criterion causing memory consumption to explode, no CAFs in sight) has a benchmark time which scales proportionally with num when compiled with O0 optimization. However using O3 optimization seems to result in a benchmark time which is independent of num . Where in the core is the result being cached, and what can I do to prevent it from being cached? The code is : {-# OPTIONS_GHC -fno-cse #-} {-# LANGUAGE BangPatterns #-} module Main where