stgi-1.1: Educational implementation of the STG (Spineless Tagless G-machine)

Safe HaskellNone
LanguageHaskell2010

Stg.Language

Contents

Description

The STG language syntax tree, modeled after the description in the 1992 paper (link).

A Program is typically created using functionality provided by the Stg.Parser module, as opposed to manually combining the data types given in this module.

For plenty of comparisons of STG language source and generated parse trees, have a look at the Stg.Parser.QuasiQuoter module.

Synopsis

Documentation

newtype Program Source #

An STG Program is the unit that can be loaded by the STG machine. It consists of a set of bindings.

Constructors

Program Binds 

Instances

Eq Program Source # 

Methods

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

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

Ord Program Source # 
Show Program Source # 
Generic Program Source # 

Associated Types

type Rep Program :: * -> * #

Methods

from :: Program -> Rep Program x #

to :: Rep Program x -> Program #

Semigroup Program Source # 
Monoid Program Source #

Right-biased union of the contained bindings. This makes for a poor man's module system by appending multiple, potentially partially incomplete, Programs to each other.

map <> filter <> [stg| … actual source … |]
Lift Program Source # 

Methods

lift :: Program -> Q Exp #

NFData Program Source # 

Methods

rnf :: Program -> () #

PrettyStgi Program Source # 
FreeVariables Program Source # 
type Rep Program Source # 
type Rep Program = D1 (MetaData "Program" "Stg.Language" "stgi-1.1-LT0PoB9W7KUFnIHxeV3rhx" True) (C1 (MetaCons "Program" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Binds)))

newtype Binds Source #

Bindings are collections of lambda forms, indexed over variables.

They exist at the top level, or as part of a let(rec) binding.

Constructors

Binds (Map Var LambdaForm) 

Instances

Eq Binds Source # 

Methods

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

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

Ord Binds Source # 

Methods

compare :: Binds -> Binds -> Ordering #

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

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

(>) :: Binds -> Binds -> Bool #

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

max :: Binds -> Binds -> Binds #

min :: Binds -> Binds -> Binds #

Show Binds Source # 

Methods

showsPrec :: Int -> Binds -> ShowS #

show :: Binds -> String #

showList :: [Binds] -> ShowS #

Generic Binds Source # 

Associated Types

type Rep Binds :: * -> * #

Methods

from :: Binds -> Rep Binds x #

to :: Rep Binds x -> Binds #

Semigroup Binds Source # 

Methods

(<>) :: Binds -> Binds -> Binds #

sconcat :: NonEmpty Binds -> Binds #

stimes :: Integral b => b -> Binds -> Binds #

Monoid Binds Source #

Right-biased union. See Monoid Program for further information.

Methods

mempty :: Binds #

mappend :: Binds -> Binds -> Binds #

mconcat :: [Binds] -> Binds #

Lift Binds Source # 

Methods

lift :: Binds -> Q Exp #

NFData Binds Source # 

Methods

rnf :: Binds -> () #

PrettyStgi Binds Source # 
FreeVariables Binds Source # 
type Rep Binds Source # 
type Rep Binds = D1 (MetaData "Binds" "Stg.Language" "stgi-1.1-LT0PoB9W7KUFnIHxeV3rhx" True) (C1 (MetaCons "Binds" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map Var LambdaForm))))

data LambdaForm Source #

A lambda form unifies free and bound variables associated with a function body. The lambda body must not be of primitive type, as this would imply the value is both boxed and unboxed.

>>> [stg| \(x) y z -> expr x z |]
LambdaForm [Var "x"] NoUpdate [Var "y",Var "z"] (AppF (Var "expr") [AtomVar (Var "x"),AtomVar (Var "z")])

Constructors

LambdaForm ![Var] !UpdateFlag ![Var] !Expr
  • Free variables (excluding globals)
  • Update flag
  • Bound variables
  • Body

Instances

Eq LambdaForm Source # 
Ord LambdaForm Source # 
Show LambdaForm Source # 
Generic LambdaForm Source # 

Associated Types

type Rep LambdaForm :: * -> * #

Lift LambdaForm Source # 

Methods

lift :: LambdaForm -> Q Exp #

NFData LambdaForm Source # 

Methods

rnf :: LambdaForm -> () #

PrettyStgi LambdaForm Source # 
FreeVariables LambdaForm Source #

Only takes into account the explicit free variable list of the lambda. This means that globals, which are not explicitly free, will not be considered free variables.

type Rep LambdaForm Source # 

prettyLambda Source #

Arguments

:: ([Var] -> Doc StgiAnn)

Free variable list printer

-> LambdaForm 
-> Doc StgiAnn 

Prettyprint a LambdaForm, given prettyprinters for the free variable list.

Introduced so Closure can hijack it to display the free value list differently.

data UpdateFlag Source #

The update flag distinguishes updatable from non-updatable lambda forms.

Constructors

Update

Overwrite the heap object in-place with its reduced value once available, making recurring access cheap

NoUpdate

Don't touch the heap object after evaluation

Instances

Bounded UpdateFlag Source # 
Enum UpdateFlag Source # 
Eq UpdateFlag Source # 
Ord UpdateFlag Source # 
Show UpdateFlag Source # 
Generic UpdateFlag Source # 

Associated Types

type Rep UpdateFlag :: * -> * #

Lift UpdateFlag Source # 

Methods

lift :: UpdateFlag -> Q Exp #

NFData UpdateFlag Source # 

Methods

rnf :: UpdateFlag -> () #

type Rep UpdateFlag Source # 
type Rep UpdateFlag = D1 (MetaData "UpdateFlag" "Stg.Language" "stgi-1.1-LT0PoB9W7KUFnIHxeV3rhx" False) ((:+:) (C1 (MetaCons "Update" PrefixI False) U1) (C1 (MetaCons "NoUpdate" PrefixI False) U1))

data Rec Source #

Distinguishes let from letrec.

Constructors

NonRecursive

Bindings have no access to each other

Recursive

Bindings can be given to each other as free variables

Instances

Bounded Rec Source # 

Methods

minBound :: Rec #

maxBound :: Rec #

Enum Rec Source # 

Methods

succ :: Rec -> Rec #

pred :: Rec -> Rec #

toEnum :: Int -> Rec #

fromEnum :: Rec -> Int #

enumFrom :: Rec -> [Rec] #

enumFromThen :: Rec -> Rec -> [Rec] #

enumFromTo :: Rec -> Rec -> [Rec] #

enumFromThenTo :: Rec -> Rec -> Rec -> [Rec] #

Eq Rec Source # 

Methods

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

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

Ord Rec Source # 

Methods

compare :: Rec -> Rec -> Ordering #

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

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

(>) :: Rec -> Rec -> Bool #

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

max :: Rec -> Rec -> Rec #

min :: Rec -> Rec -> Rec #

Show Rec Source # 

Methods

showsPrec :: Int -> Rec -> ShowS #

show :: Rec -> String #

showList :: [Rec] -> ShowS #

Generic Rec Source # 

Associated Types

type Rep Rec :: * -> * #

Methods

from :: Rec -> Rep Rec x #

to :: Rep Rec x -> Rec #

Lift Rec Source # 

Methods

lift :: Rec -> Q Exp #

NFData Rec Source # 

Methods

rnf :: Rec -> () #

PrettyStgi Rec Source # 
type Rep Rec Source # 
type Rep Rec = D1 (MetaData "Rec" "Stg.Language" "stgi-1.1-LT0PoB9W7KUFnIHxeV3rhx" False) ((:+:) (C1 (MetaCons "NonRecursive" PrefixI False) U1) (C1 (MetaCons "Recursive" PrefixI False) U1))

data Expr Source #

An expression in the STG language.

Constructors

Let !Rec !Binds !Expr

Let expression let(rec) ... in ...

Case !Expr !Alts

Case expression case ... of ... x -> y

AppF !Var ![Atom]

Function application f x y z

AppC !Constr ![Atom]

Saturated constructor application Just a

AppP !PrimOp !Atom !Atom

Primitive function application + 2#

LitE !Literal

Literal expression 1#

Instances

Eq Expr Source # 

Methods

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

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

Ord Expr Source # 

Methods

compare :: Expr -> Expr -> Ordering #

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

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

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

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

max :: Expr -> Expr -> Expr #

min :: Expr -> Expr -> Expr #

Show Expr Source # 

Methods

showsPrec :: Int -> Expr -> ShowS #

show :: Expr -> String #

showList :: [Expr] -> ShowS #

Generic Expr Source # 

Associated Types

type Rep Expr :: * -> * #

Methods

from :: Expr -> Rep Expr x #

to :: Rep Expr x -> Expr #

Lift Expr Source # 

Methods

lift :: Expr -> Q Exp #

NFData Expr Source # 

Methods

rnf :: Expr -> () #

PrettyStgi Expr Source # 
FreeVariables Expr Source # 
type Rep Expr Source # 
type Rep Expr = D1 (MetaData "Expr" "Stg.Language" "stgi-1.1-LT0PoB9W7KUFnIHxeV3rhx" False) ((:+:) ((:+:) (C1 (MetaCons "Let" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Rec)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Binds)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Expr))))) ((:+:) (C1 (MetaCons "Case" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Expr)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Alts)))) (C1 (MetaCons "AppF" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Var)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [Atom])))))) ((:+:) (C1 (MetaCons "AppC" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Constr)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [Atom])))) ((:+:) (C1 (MetaCons "AppP" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 PrimOp)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Atom)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Atom))))) (C1 (MetaCons "LitE" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Literal))))))

data Alts Source #

List of possible alternatives in a Case expression.

The list of alts has to be homogeneous. This is not ensured by the type system, and should be handled by the parser instead.

Instances

Eq Alts Source # 

Methods

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

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

Ord Alts Source # 

Methods

compare :: Alts -> Alts -> Ordering #

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

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

(>) :: Alts -> Alts -> Bool #

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

max :: Alts -> Alts -> Alts #

min :: Alts -> Alts -> Alts #

Show Alts Source # 

Methods

showsPrec :: Int -> Alts -> ShowS #

show :: Alts -> String #

showList :: [Alts] -> ShowS #

Generic Alts Source # 

Associated Types

type Rep Alts :: * -> * #

Methods

from :: Alts -> Rep Alts x #

to :: Rep Alts x -> Alts #

Lift Alts Source # 

Methods

lift :: Alts -> Q Exp #

NFData Alts Source # 

Methods

rnf :: Alts -> () #

PrettyStgi Alts Source # 
FreeVariables Alts Source # 
type Rep Alts Source # 

data NonDefaultAlts Source #

The part of a Case alternative that's not the default.

Constructors

NoNonDefaultAlts

Used in 'case' statements that consist only of a default alternative. These can be useful to force or unpack values.

AlgebraicAlts !(NonEmpty AlgebraicAlt)

Algebraic alternative, like Cons x xs.

PrimitiveAlts !(NonEmpty PrimitiveAlt)

Primitive alternative, like 1#.

Instances

Eq NonDefaultAlts Source # 
Ord NonDefaultAlts Source # 
Show NonDefaultAlts Source # 
Generic NonDefaultAlts Source # 

Associated Types

type Rep NonDefaultAlts :: * -> * #

Lift NonDefaultAlts Source # 

Methods

lift :: NonDefaultAlts -> Q Exp #

NFData NonDefaultAlts Source # 

Methods

rnf :: NonDefaultAlts -> () #

FreeVariables NonDefaultAlts Source # 
type Rep NonDefaultAlts Source # 
type Rep NonDefaultAlts = D1 (MetaData "NonDefaultAlts" "Stg.Language" "stgi-1.1-LT0PoB9W7KUFnIHxeV3rhx" False) ((:+:) (C1 (MetaCons "NoNonDefaultAlts" PrefixI False) U1) ((:+:) (C1 (MetaCons "AlgebraicAlts" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (NonEmpty AlgebraicAlt)))) (C1 (MetaCons "PrimitiveAlts" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (NonEmpty PrimitiveAlt))))))

data AlgebraicAlt Source #

As in True | False

Constructors

AlgebraicAlt !Constr ![Var] !Expr 

Instances

Eq AlgebraicAlt Source # 
Ord AlgebraicAlt Source # 
Show AlgebraicAlt Source # 
Generic AlgebraicAlt Source # 

Associated Types

type Rep AlgebraicAlt :: * -> * #

Lift AlgebraicAlt Source # 

Methods

lift :: AlgebraicAlt -> Q Exp #

NFData AlgebraicAlt Source # 

Methods

rnf :: AlgebraicAlt -> () #

PrettyStgi AlgebraicAlt Source # 
FreeVariables AlgebraicAlt Source # 
type Rep AlgebraicAlt Source # 

data PrimitiveAlt Source #

As in 1#, 2#, 3#

Constructors

PrimitiveAlt !Literal !Expr 

Instances

Eq PrimitiveAlt Source # 
Ord PrimitiveAlt Source # 
Show PrimitiveAlt Source # 
Generic PrimitiveAlt Source # 

Associated Types

type Rep PrimitiveAlt :: * -> * #

Lift PrimitiveAlt Source # 

Methods

lift :: PrimitiveAlt -> Q Exp #

NFData PrimitiveAlt Source # 

Methods

rnf :: PrimitiveAlt -> () #

PrettyStgi PrimitiveAlt Source # 
FreeVariables PrimitiveAlt Source # 
type Rep PrimitiveAlt Source # 

data DefaultAlt Source #

If no viable alternative is found in a pattern match, use a DefaultAlt as fallback.

Instances

Eq DefaultAlt Source # 
Ord DefaultAlt Source # 
Show DefaultAlt Source # 
Generic DefaultAlt Source # 

Associated Types

type Rep DefaultAlt :: * -> * #

Lift DefaultAlt Source # 

Methods

lift :: DefaultAlt -> Q Exp #

NFData DefaultAlt Source # 

Methods

rnf :: DefaultAlt -> () #

PrettyStgi DefaultAlt Source # 
FreeVariables DefaultAlt Source # 
type Rep DefaultAlt Source # 

newtype Literal Source #

Literals are the basis of primitive operations.

Constructors

Literal Integer 

data PrimOp Source #

Primitive operations.

Constructors

Add
+
Sub
-
Mul
*
Div
/
Mod
%
Eq
==
Lt
<
Leq
<=
Gt
>
Geq
>=
Neq
/=

Instances

Bounded PrimOp Source # 
Enum PrimOp Source # 
Eq PrimOp Source # 

Methods

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

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

Ord PrimOp Source # 
Show PrimOp Source # 
Generic PrimOp Source # 

Associated Types

type Rep PrimOp :: * -> * #

Methods

from :: PrimOp -> Rep PrimOp x #

to :: Rep PrimOp x -> PrimOp #

Lift PrimOp Source # 

Methods

lift :: PrimOp -> Q Exp #

NFData PrimOp Source # 

Methods

rnf :: PrimOp -> () #

PrettyStgi PrimOp Source # 
type Rep PrimOp Source # 
type Rep PrimOp = D1 (MetaData "PrimOp" "Stg.Language" "stgi-1.1-LT0PoB9W7KUFnIHxeV3rhx" False) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "Add" PrefixI False) U1) (C1 (MetaCons "Sub" PrefixI False) U1)) ((:+:) (C1 (MetaCons "Mul" PrefixI False) U1) ((:+:) (C1 (MetaCons "Div" PrefixI False) U1) (C1 (MetaCons "Mod" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "Eq" PrefixI False) U1) ((:+:) (C1 (MetaCons "Lt" PrefixI False) U1) (C1 (MetaCons "Leq" PrefixI False) U1))) ((:+:) (C1 (MetaCons "Gt" PrefixI False) U1) ((:+:) (C1 (MetaCons "Geq" PrefixI False) U1) (C1 (MetaCons "Neq" PrefixI False) U1)))))

newtype Var Source #

Variable.

Constructors

Var Text 

Instances

Eq Var Source # 

Methods

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

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

Ord Var Source # 

Methods

compare :: Var -> Var -> Ordering #

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

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

(>) :: Var -> Var -> Bool #

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

max :: Var -> Var -> Var #

min :: Var -> Var -> Var #

Show Var Source # 

Methods

showsPrec :: Int -> Var -> ShowS #

show :: Var -> String #

showList :: [Var] -> ShowS #

IsString Var Source # 

Methods

fromString :: String -> Var #

Generic Var Source # 

Associated Types

type Rep Var :: * -> * #

Methods

from :: Var -> Rep Var x #

to :: Rep Var x -> Var #

Lift Var Source # 

Methods

lift :: Var -> Q Exp #

NFData Var Source # 

Methods

rnf :: Var -> () #

PrettyStgi Var Source # 
FreeVariables Var Source # 
type Rep Var Source # 
type Rep Var = D1 (MetaData "Var" "Stg.Language" "stgi-1.1-LT0PoB9W7KUFnIHxeV3rhx" True) (C1 (MetaCons "Var" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))

data Atom Source #

Smallest unit of data. Atoms unify variables and literals, and are what functions take as arguments.

Constructors

AtomVar !Var 
AtomLit !Literal 

Instances

Eq Atom Source # 

Methods

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

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

Ord Atom Source # 

Methods

compare :: Atom -> Atom -> Ordering #

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

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

(>) :: Atom -> Atom -> Bool #

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

max :: Atom -> Atom -> Atom #

min :: Atom -> Atom -> Atom #

Show Atom Source # 

Methods

showsPrec :: Int -> Atom -> ShowS #

show :: Atom -> String #

showList :: [Atom] -> ShowS #

Generic Atom Source # 

Associated Types

type Rep Atom :: * -> * #

Methods

from :: Atom -> Rep Atom x #

to :: Rep Atom x -> Atom #

Lift Atom Source # 

Methods

lift :: Atom -> Q Exp #

NFData Atom Source # 

Methods

rnf :: Atom -> () #

PrettyStgi Atom Source # 
FreeVariables Atom Source # 
type Rep Atom Source # 

newtype Constr Source #

Constructors of algebraic data types.

Constructors

Constr Text 

Instances

Eq Constr Source # 

Methods

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

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

Ord Constr Source # 
Show Constr Source # 
IsString Constr Source # 

Methods

fromString :: String -> Constr #

Generic Constr Source # 

Associated Types

type Rep Constr :: * -> * #

Methods

from :: Constr -> Rep Constr x #

to :: Rep Constr x -> Constr #

Lift Constr Source # 

Methods

lift :: Constr -> Q Exp #

NFData Constr Source # 

Methods

rnf :: Constr -> () #

PrettyStgi Constr Source # 
type Rep Constr Source # 
type Rep Constr = D1 (MetaData "Constr" "Stg.Language" "stgi-1.1-LT0PoB9W7KUFnIHxeV3rhx" True) (C1 (MetaCons "Constr" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))

class Pretty a where #

Overloaded conversion to Doc.

Laws:

  1. output should be pretty. :-)

Minimal complete definition

pretty

Methods

pretty :: a -> Doc ann #

>>> pretty 1 <+> pretty "hello" <+> pretty 1.234
1 hello 1.234

prettyList :: [a] -> Doc ann #

prettyList is only used to define the instance Pretty a => Pretty [a]. In normal circumstances only the pretty function is used.

>>> prettyList [1, 23, 456]
[1, 23, 456]

Instances

Pretty Bool
>>> pretty True
True

Methods

pretty :: Bool -> Doc ann #

prettyList :: [Bool] -> Doc ann #

Pretty Char

Instead of (pretty '\n'), consider using line as a more readable alternative.

>>> pretty 'f' <> pretty 'o' <> pretty 'o'
foo
>>> pretty ("string" :: String)
string

Methods

pretty :: Char -> Doc ann #

prettyList :: [Char] -> Doc ann #

Pretty Double
>>> pretty (exp 1 :: Double)
2.718281828459045

Methods

pretty :: Double -> Doc ann #

prettyList :: [Double] -> Doc ann #

Pretty Float
>>> pretty (pi :: Float)
3.1415927

Methods

pretty :: Float -> Doc ann #

prettyList :: [Float] -> Doc ann #

Pretty Int
>>> pretty (123 :: Int)
123

Methods

pretty :: Int -> Doc ann #

prettyList :: [Int] -> Doc ann #

Pretty Int8 

Methods

pretty :: Int8 -> Doc ann #

prettyList :: [Int8] -> Doc ann #

Pretty Int16 

Methods

pretty :: Int16 -> Doc ann #

prettyList :: [Int16] -> Doc ann #

Pretty Int32 

Methods

pretty :: Int32 -> Doc ann #

prettyList :: [Int32] -> Doc ann #

Pretty Int64 

Methods

pretty :: Int64 -> Doc ann #

prettyList :: [Int64] -> Doc ann #

Pretty Integer
>>> pretty (2^123 :: Integer)
10633823966279326983230456482242756608

Methods

pretty :: Integer -> Doc ann #

prettyList :: [Integer] -> Doc ann #

Pretty Word 

Methods

pretty :: Word -> Doc ann #

prettyList :: [Word] -> Doc ann #

Pretty Word8 

Methods

pretty :: Word8 -> Doc ann #

prettyList :: [Word8] -> Doc ann #

Pretty Word16 

Methods

pretty :: Word16 -> Doc ann #

prettyList :: [Word16] -> Doc ann #

Pretty Word32 

Methods

pretty :: Word32 -> Doc ann #

prettyList :: [Word32] -> Doc ann #

Pretty Word64 

Methods

pretty :: Word64 -> Doc ann #

prettyList :: [Word64] -> Doc ann #

Pretty ()
>>> pretty ()
()

The argument is not used,

>>> pretty (error "Strict?" :: ())
()

Methods

pretty :: () -> Doc ann #

prettyList :: [()] -> Doc ann #

Pretty Text

(lazy Text instance, identical to the strict version)

Methods

pretty :: Text -> Doc ann #

prettyList :: [Text] -> Doc ann #

Pretty Text

Automatically converts all newlines to line.

>>> pretty ("hello\nworld" :: Text)
hello
world

Note that line can be undone by group:

>>> group (pretty ("hello\nworld" :: Text))
hello world

Manually use hardline if you definitely want newlines.

Methods

pretty :: Text -> Doc ann #

prettyList :: [Text] -> Doc ann #

Pretty Natural 

Methods

pretty :: Natural -> Doc ann #

prettyList :: [Natural] -> Doc ann #

Pretty Void

Finding a good example for printing something that does not exist is hard, so here is an example of printing a list full of nothing.

>>> pretty ([] :: [Void])
[]

Methods

pretty :: Void -> Doc ann #

prettyList :: [Void] -> Doc ann #

Pretty a => Pretty [a]
>>> pretty [1,2,3]
[1, 2, 3]

Methods

pretty :: [a] -> Doc ann #

prettyList :: [[a]] -> Doc ann #

Pretty a => Pretty (Maybe a)

Ignore Nothings, print Just contents.

>>> pretty (Just True)
True
>>> braces (pretty (Nothing :: Maybe Bool))
{}
>>> pretty [Just 1, Nothing, Just 3, Nothing]
[1, 3]

Methods

pretty :: Maybe a -> Doc ann #

prettyList :: [Maybe a] -> Doc ann #

Pretty a => Pretty (NonEmpty a) 

Methods

pretty :: NonEmpty a -> Doc ann #

prettyList :: [NonEmpty a] -> Doc ann #

(Pretty a1, Pretty a2) => Pretty (a1, a2)
>>> pretty (123, "hello")
(123, hello)

Methods

pretty :: (a1, a2) -> Doc ann #

prettyList :: [(a1, a2)] -> Doc ann #

(Pretty a1, Pretty a2, Pretty a3) => Pretty (a1, a2, a3)
>>> pretty (123, "hello", False)
(123, hello, False)

Methods

pretty :: (a1, a2, a3) -> Doc ann #

prettyList :: [(a1, a2, a3)] -> Doc ann #

Meta information

classify :: LambdaForm -> LambdaType Source #

Classify the type of a lambda form based on its shape.

data LambdaType Source #

Possible classification of lambda forms.

Constructors

LambdaCon

Data constructor (AppC as body)

LambdaFun

Function (lambda with non-empty argument list)

LambdaThunk

Thunk (everything else)