help understand strange behavior in a lazy code
...
I'm a beginner Haskell programmer. I have written some useful code for the last six month. And I want to release a library from it. The code will use system installation cabal as any Haskell library. A library is released with cabal has a meta data file where there is a logical predicate from the libraries and their versions. A develope...
I'm wondering why Prelude> head $ reverse $ [1..10000000] ++ [99] 99 does not lead to a stack overflow error. The ++ in the prelude seems straight forward and non-tail-recursive: (++) :: [a] -> [a] -> [a] (++) [] ys = ys (++) (x:xs) ys = x : xs ++ ys EDIT: Initially, I thought the issue has something to do with the way ++ is de...
I'm getting a warning from GHC when I compile: Warning: This binding for 'pats' shadows an existing binding in the definition of 'match_ignore_ancs' Here's the function: match_ignore_ancs (TextPat _ c) (Text t) = c t match_ignore_ancs (TextPat _ _) (Element _ _ _) = False match_ignore_ancs (ElemPat _ _ _) (Text t) = False match_ig...
Why can't Haskell resolve the kind of [[]] (A list of lists)? Why isn't it simply * -> *, as I can give it a type like Int, and get [[Int]], which is of kind *. ...
I wanted to use {-# LANGUAGE OverloadedStrings #-} but I forgot how it's called. This kind of thing isn't hoogle-able, and also it takes some time finding using google*. Is there somewhere a list of GHC extensions named as they are in the LANGUAGE pragma? * My googling search journey: Google Haskell at wikipedia GHC at wikipedia GHC ...
I ported a little Haskell program I wrote from Mac to Windows. It's a GUI application (wxHaskell, compiled with ghc 6.12.1), so it does not need the command prompt window to open. It does so, anyway, so my question: What must I do so that the program starts without opening a prompt window first? Is there some ghc switch for this? ...
I read that hash tables in Haskell had performance issues (on the Haskell-Cafe in 2006 and Flying Frog Consultancy's blog in 2009), and since I like Haskell it worried me. That was a year ago, what is the status now (June 2010)? Has the "hash table problem" been fixed in GHC? ...
I'm beginning to understand how the forall keyword is used in so-called "existential types" like this: data ShowBox = forall s. Show s => SB s This is only a subset, however, of how forall is used and I simply cannot wrap my mind around its use in things like this: runST :: forall a. (forall s. ST s a) -> a Or explaining why these ...
When compiling my Haskell application with the -Wall option, GHC complains about orphaned instances, for example: Publisher.hs:45:9: Warning: orphan instance: instance ToSElem Result The type class ToSElem is not mine, it's defined by HStringTemplate. Now I know how to fix this (move the instance declaration into the module where...
I was wondering if GHC's extensions can be divided into basically two different categories those that provide "syntactic suggar" or convenience and those that introduce something new, a new paradigm for instance. Now provided one could divide the existing extensions into the above categories which extension would fit into which categ...
Not a programming question, but the first time I see something like this. UNR 1.6 (based on Ubuntu 10.04) installs the 6.12.1 version of GHC. So, in order to build cabal-install-0.8.2, I have to install the libghc6- packages of parsec, mtl, network and zlib. Then, after launching 'sh ./bootstrap.sh', I get: Checking installed packages ...
I have a Haskell program which processes a text file and builds a Map (with several million elements). The whole thing can run for 2-3 minutes. I found that tweaking the -H and -A options makes a big difference in running time. There is documentation about this functionality of the RTS, but it's a hard read for me since I don't know the...
How to find the actual amount of memory required to store a value of some data type in Haskell (mostly with GHC)? Is it possible to evaluate it in runtime (e.g. in GHCi) or is it possible to estimate memory requirements of a compound data type from its components? In general, if memory requirements of types a and b are known, what is me...
I have two non-overlapping sets of types and want to make other set which is union of these two. Code sample: class A a class B b class AB ab instance A a => AB a instance B b => AB b GHC 6.12.3 doesn't allow to declare this with error message: Duplicate instance declarations: instance (A a) => AB a -- Defined at playgro...
Here is the output from verbose mode. I know this used to work for me before but now this happens. I've tried it with other packages and got the same result. $ sudo cabal install test-framework-quickcheck2 -v /usr/local/bin/ghc --numeric-version looking for package tool: ghc-pkg near compiler in /usr/local/bin found package tool in /u...
Haskell newbie here. $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.12.1 While trying to debug weird locale-related bug in third-party Haskell program, I'm trying to print default encoding: import System.IO main = do print localeEncoding But it fails: $ ghc -o printlocale main.hs main.hs:4:2: No...
Specs GHC 6.12.1 Mac OS X 10.6.4 x64 MacBook Pro Problem I'm having trouble using let syntax. The following code refuses to compile: module Main where main = let x = 1 y = 2 z = 3 in putStrLn $ "X = " ++ show x ++ "\nY = " ++ show y ++ "\nZ = " ++ show z I tried tabbing in y = 2 and z = 3 even more. No dice. ...
[Source Code] data FooBar = Foo | Bar [Command] $ ghc -c foo_bar.hs foo_bar.hs:1:0: The function 'main' is not defined in module 'Main' [Configuration] Glasgow Haskell Compiler, Version 6.12.3, for Haskell 98, stage 2 booted by GHC version 6.10.4 ...
I've tried -fvia-C and the -pgms, but none of them manage to create an executable, splurting out lots of errors like Warning: retaining unknown function ``L4' in output from C compiler. ...