hops-0.7.0: Handy Operations on Power Series

CopyrightAnders Claesson 2015 2016
MaintainerAnders Claesson <anders.claesson@gmail.com>
Safe HaskellNone
LanguageHaskell98

HOPS.GF

Description

License : BSD-3

Synopsis

Documentation

data Cmd Source #

Constructors

Expr Expr0 
Asgmt Name Expr0 

Instances

Eq Cmd Source # 

Methods

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

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

Show Cmd Source # 

Methods

showsPrec :: Int -> Cmd -> ShowS #

show :: Cmd -> String #

showList :: [Cmd] -> ShowS #

Pretty Cmd Source # 

newtype Prg Source #

A program is a list of commands, where a command is either a power series expression or an assignment.

Constructors

Prg 

Fields

packPrg :: Prg -> PackedPrg Source #

A compact representation of a Prg as a wrapped ByteString.

vars :: CorePrg -> [Name] Source #

The list of variables in a program.

anums :: CorePrg -> [Int] Source #

The list of A-numbers in a program.

insertVar :: ByteString -> Series n -> Env n -> Env n Source #

Insert a variable binding into the given environment.

data Core Source #

Constructors

App !Name ![Core] 
X 
A !Int 
Tag !Int 
Var !Name 
Lit !Rat 
Rats !Core 
Let !Name !Core 

Instances

Eq Core Source # 

Methods

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

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

Floating Core Source # 

Methods

pi :: Core #

exp :: Core -> Core #

log :: Core -> Core #

sqrt :: Core -> Core #

(**) :: Core -> Core -> Core #

logBase :: Core -> Core -> Core #

sin :: Core -> Core #

cos :: Core -> Core #

tan :: Core -> Core #

asin :: Core -> Core #

acos :: Core -> Core #

atan :: Core -> Core #

sinh :: Core -> Core #

cosh :: Core -> Core #

tanh :: Core -> Core #

asinh :: Core -> Core #

acosh :: Core -> Core #

atanh :: Core -> Core #

log1p :: Core -> Core #

expm1 :: Core -> Core #

log1pexp :: Core -> Core #

log1mexp :: Core -> Core #

Fractional Core Source # 

Methods

(/) :: Core -> Core -> Core #

recip :: Core -> Core #

fromRational :: Rational -> Core #

Num Core Source # 

Methods

(+) :: Core -> Core -> Core #

(-) :: Core -> Core -> Core #

(*) :: Core -> Core -> Core #

negate :: Core -> Core #

abs :: Core -> Core #

signum :: Core -> Core #

fromInteger :: Integer -> Core #

Ord Core Source # 

Methods

compare :: Core -> Core -> Ordering #

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

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

(>) :: Core -> Core -> Bool #

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

max :: Core -> Core -> Core #

min :: Core -> Core -> Core #

Show Core Source # 

Methods

showsPrec :: Int -> Core -> ShowS #

show :: Core -> String #

showList :: [Core] -> ShowS #

Pretty Core Source # 

type CorePrg = [Core] Source #

data Env n Source #

An environment holds a mapping from A-numbers to series, and a mapping from names to series (assignments).

Constructors

Env 

Fields

evalCorePrg :: KnownNat n => Env n -> CorePrg -> Series n Source #

Evaluate a program in a given environment. E.g.

evalCorePrg (emptyEnv :: Env 4) [ log (1/(1-X)) ]

series (Proxy :: Proxy 4) [Val (0 % 1),Val (1 % 1),Val (1 % 2),Val (1 % 3)]

evalCorePrgs :: KnownNat n => Env n -> [CorePrg] -> [Series n] Source #

Evaluate a list of programs in a given environment.

parsePrg :: ByteString -> Maybe Prg Source #

Parse a program.

parsePrgErr :: ByteString -> Prg Source #

Parse a program and possibly fail with an error.