Questions tagged [runhaskell]

GHC command that allows running a Haskell program as a script, without having to compile it beforehand

runhaskell is a command from the compiler that allows running a Haskell program as a script, without having to compile it beforehand.

Usage

To use it, create and mark executable your Haskell code (that defines main :: IO()), with the line prepended:

#!/usr/bin/env runhaskell

Then, when the script is executed, runhaskell automatically compiles and runs the script. (The runhaskell program strips the shebang line before compiling it).

Pitfalls

  • May not be included with all Haskell implementations
  • The script is compiled, with limited optimization, each time it is run, so performance is slower than a compiled Haskell program
20 questions
1
vote
1 answer

lexical error at character '\DEL' when doing runhaskell

Heres my code: factorial :: Integer -> Integer factorial n = product [1..n] main = print(factorial 50) I don't get any errors compiling, but when i run the compiled code runhaskell test I get this error: test:1:1: lexical error at character…
dopatraman
  • 13,416
  • 29
  • 90
  • 154
1
vote
1 answer

runhaskell setup configure [ installing]

When I try to configure the Cabal-1.18.1.3 package I get the error: Configuring Cabal-1.18.1.3... Setup: does not exist My system is Windows 8 Pro x64, 2GB RAM, 1.7GHz dual core.\ tried: I have tried writing Setup as Setup.hs
1
vote
1 answer

GHCI character limit?

I'm using ghci to do some incremental development using Emacs' run-haskell. Every once in a while, I get an error that looks like :[line]:[character]: _Lexical error at character '\EOT' Setting up an intermediate variable or two gets…
Inaimathi
  • 13,853
  • 9
  • 49
  • 93
0
votes
1 answer

Why does ghci behave differently to runHaskell?

My goal is to pipe some steps for ghci to run from a bash script and then exit cleanly. The commentary online says to use runhaskell for this. This is the command I'm trying to run: ghci> import System.Random ghci> random (mkStdGen 100) :: (Int,…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
0
votes
0 answers

Code snippet works in an online IDE but not on my local ghc

As a beginner, i wrote a snippet to flip a string's case. module Main where import Data.Char main=do str<-getLine putStrLn ( reverser(str) ) reverser:: String -> String reverser [] = [] reverser (x:xs) | isUpper x = toLower x : reverser…
vaZark
  • 95
  • 1
  • 8
1
2