problem about ghci-Collection of common programming errors
Matt Fenwick
artella
haskell ghc ghci winghci
Question 1Hi, if in WinGHCi I intentionally do the following wrong piece of code : 3 4Then the error message I get is :1:1:No instance for (Num (a0 -> t0))arising from the literal `3’Possible fix: add an instance declaration for (Num (a0 -> t0))In the expression: 3In the expression: 3 4In an equation for `it’: it = 3 4What exactly does No instance for (Num (a0 -> t0)) mean?Question 2Why does the following piece of code : (+) 2 3 4 :1:7:No
user42179
haskell ghci
GHCI seems to cache the results of functions during an interactive session. It’s easy to notice, j
pyrospade
haskell multiline ghci
I like to parse strings ad hoc in Python by just pasting into the interpreter.>>> s = “””Adams, John … Washington,George … Lincoln,Abraham … Jefferson, Thomas … “”” >>> print “\n”.join(x.split(“,”)[1].replace(” “, “”)for x in s.strip().split(“\n”)) John George Abraham ThomasThis works great using the Python interpreter, but I’d like to do this with Haskell/GHCi. Problem is, I can’t paste multi-line strings. I can use getContents with an EOF character, but I can only do it once since the EO
AndrewC
haskell ghci
I wrote the below code to construct a tree with given vertex given a list of connections between vertices.type Connection = (Int,Int) data Tree = Leaf Int | Node Int [Tree] deriving (Eq,Read,Show)makeTree :: Int -> [Connection] -> Tree makeTree x [] = Leaf x makeTree indx con
Stephane Rolland
haskell ghci haskell-platform
I’m following a tutorial. (Real World Haskell)And I have one beginner question about head and tail called on empty lists: In GHCi it returns exception.Intuitiv
mgibson
haskell ghci type-families
I am wondering if there is functionality that exists within GHCi (or elsewhere) to expand type synonyms and families out of an arbitrary type expression.For example, if I have these types,data A = A data B = Bdata F a = F a data G a = G a data H a b = H a btype S a b = H (F a) (G b
Mike Izbicki
haskell types ghci
I’m trying to make the types ghci displays for my libraries as intuitive as possible, but I’m running into a lot of difficulties when using more advanced type features.Let’s say I have this code in a file:{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeOperators #-}import GHC.TypeLitsdata Container (xs::[*]) = ContainerI load it up in ghci, then I type the following command:ghci> :t undefined ::
mcandre
Ting L
c++ haskell inline ffi ghci
I have recently met an issue with C++ inline functions when using Haskell FFI to C/C++. Namely, g++ does not really inline functions that are declared inline, and generate symbols for them. Ultimately, this generates linker error when ghci tries to load an object file which calls the inline function:Loading object (static) solveeq.o … done Loading object (dynamic) /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.so … done final link … ghc: solveeq.o: unknown symbol `_ZN5Eigen8internal19throw_std_bad_al
lewurm
haskell ffi ghci
I have a problem regarding FFI in Haskell and the interactive mode of GHC.(Source is also available via a gist):FFISo.hs:{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ForeignFunctionInterface #-} module Main whereimport qualified Data.ByteString.Char8 as Bforeign import ccall “callMeFromHaskell”callMeFromHaskell :: IO ()foreign export ccall callMeFromC :: IO () callMeFromC :: IO () callMeFromC = B.putStrLn “callMeFromC”main :: IO () main = doB.putStrLn “main”callMeFromHaskellreturn ()c.c:#include void callMeFromC(void);void callMeFromHaskell(void) { printf(“callMeFromHaskell\n”);callMeFromC(); }Makefile:GHC_OPT := -Wall -O2 -fno-warn-unused-do-bindall: ffisotest: ffiso./$
Originally posted 2013-11-09 20:19:24.