nix-eval-0.3.3.0: Evaluate Haskell expressions using Nix to get packages

Safe HaskellNone
LanguageHaskell2010

Language.Eval.Internal

Synopsis

Documentation

newtype Pkg Source #

Constructors

Pkg String 

Instances

Eq Pkg Source # 

Methods

(==) :: Pkg -> Pkg -> Bool #

(/=) :: Pkg -> Pkg -> Bool #

Ord Pkg Source # 

Methods

compare :: Pkg -> Pkg -> Ordering #

(<) :: Pkg -> Pkg -> Bool #

(<=) :: Pkg -> Pkg -> Bool #

(>) :: Pkg -> Pkg -> Bool #

(>=) :: Pkg -> Pkg -> Bool #

max :: Pkg -> Pkg -> Pkg #

min :: Pkg -> Pkg -> Pkg #

Show Pkg Source # 

Methods

showsPrec :: Int -> Pkg -> ShowS #

show :: Pkg -> String #

showList :: [Pkg] -> ShowS #

IsString Pkg Source # 

Methods

fromString :: String -> Pkg #

newtype Mod Source #

Constructors

Mod String 

Instances

Eq Mod Source # 

Methods

(==) :: Mod -> Mod -> Bool #

(/=) :: Mod -> Mod -> Bool #

Ord Mod Source # 

Methods

compare :: Mod -> Mod -> Ordering #

(<) :: Mod -> Mod -> Bool #

(<=) :: Mod -> Mod -> Bool #

(>) :: Mod -> Mod -> Bool #

(>=) :: Mod -> Mod -> Bool #

max :: Mod -> Mod -> Mod #

min :: Mod -> Mod -> Mod #

Show Mod Source # 

Methods

showsPrec :: Int -> Mod -> ShowS #

show :: Mod -> String #

showList :: [Mod] -> ShowS #

IsString Mod Source # 

Methods

fromString :: String -> Mod #

newtype Flag Source #

Constructors

Flag String 

Instances

Eq Flag Source # 

Methods

(==) :: Flag -> Flag -> Bool #

(/=) :: Flag -> Flag -> Bool #

Ord Flag Source # 

Methods

compare :: Flag -> Flag -> Ordering #

(<) :: Flag -> Flag -> Bool #

(<=) :: Flag -> Flag -> Bool #

(>) :: Flag -> Flag -> Bool #

(>=) :: Flag -> Flag -> Bool #

max :: Flag -> Flag -> Flag #

min :: Flag -> Flag -> Flag #

Show Flag Source # 

Methods

showsPrec :: Int -> Flag -> ShowS #

show :: Flag -> String #

showList :: [Flag] -> ShowS #

IsString Flag Source # 

Methods

fromString :: String -> Flag #

data Expr Source #

Constructors

Expr 

Fields

Instances

Eq Expr Source # 

Methods

(==) :: Expr -> Expr -> Bool #

(/=) :: Expr -> Expr -> Bool #

Show Expr Source # 

Methods

showsPrec :: Int -> Expr -> ShowS #

show :: Expr -> String #

showList :: [Expr] -> ShowS #

IsString Expr Source # 

Methods

fromString :: String -> Expr #

eval :: Expr -> IO (Maybe String) Source #

Evaluate an Expr; this is where the magic happens! If successful, returns Just a String, which you can do what you like with.

eval' :: (String -> String) -> Expr -> IO (Maybe String) Source #

Same as eval, but allows a custom formatting function to be supplied, eg. if you want an alternative to the default "main = putStr (..)" behaviour.

runCmdStdIO :: CreateProcess -> String -> IO (String, ExitCode) Source #

Runs the given command, piping the given String into stdin, returning stdout and the ExitCode. stderr is inherited.

mkCmd :: Expr -> (String, [String]) Source #

Construct the nix-shell command. We use wrapper.sh as a layer of indirection, to work around buggy environments.

mkGhcPkg :: [Pkg] -> [Char] Source #

Creates a Nix expression which will use ghcEnvWithPkgs.nix to make a Haskell environment containing all of the given packages

pkgsToName :: [Pkg] -> [Char] Source #

This creates a name for our Haskell environment. We make it here once, and pass it into both Nix and wrapper.sh, to ensure consistency

havePkgs :: [Pkg] -> IO Bool Source #

Check if all of the required packages are already available, i.e. whether we need to create a new Haskell environment

needNewEnv :: [Pkg] -> IO Bool Source #

Do we need to create a new Haskell environment, because we don't have GHC available or because the packages we need aren't available?

mkHs :: String -> String Source #

Turn an expression into a Haskell module, complete with imports and main

trim :: String -> String Source #

Strip leading and trailing whitespace

haveCommand :: [Char] -> IO Bool Source #

Check if a shell command is available

haveNix :: IO Bool Source #

Check if the `nix-shell` command is available via the shell

haveGhcPkg :: IO Bool Source #

Check if the `ghc-pkg` command is available via the shell

raw :: String -> Expr Source #

A raw String of Haskell code, with no packages or modules. You can use OverloadedStrings to call this automatically.

($$) :: Expr -> Expr -> Expr infixr 8 Source #

Apply the first Expr to the second, eg. `f $$ x` ==> `f x`

asString :: Show a => a -> Expr Source #

Convert the argument to a String, then send to raw

qualified :: Mod -> Expr -> Expr Source #

Qualify an expression, eg. `qualified Data.Bool "not"` gives the expression not with Data.Bool in its module list

withMods :: [Mod] -> Expr -> Expr Source #

Append modules to an expression's context

withPkgs :: [Pkg] -> Expr -> Expr Source #

Append packages to an expression's context

withFlags :: [Flag] -> Expr -> Expr Source #

Append arguments to an expression's context