Safe Haskell | None |
---|---|
Language | Haskell98 |
QuickSpec.Term
Description
This module is internal to QuickSpec.
Typed terms and operations on them.
Synopsis
- data a :+: b
- newtype MeasureFuns f = MeasureFuns (Term f)
- type Measure f = (Int, Int, Int, MeasureFuns f, Int, [Var])
- class Sized a where
- class Symbolic f a | a -> f where
- data Var = V {}
- data Term f
- isApp :: Term f -> Bool
- isVar :: Term f -> Bool
- terms :: Symbolic f a => a -> [Term f]
- funs :: Symbolic f a => a -> [f]
- vars :: Symbolic f a => a -> [Var]
- freeVar :: Symbolic f a => a -> Int
- occ :: (Eq f, Symbolic f a) => f -> a -> Int
- occVar :: Symbolic f a => Var -> a -> Int
- mapVar :: (Var -> Var) -> Term f -> Term f
- subterms :: Term f -> [Term f]
- properSubterms :: Term f -> [Term f]
- canonicalise :: Symbolic fun a => a -> a
- evalTerm :: (Typed fun, Apply a, Monad m) => (Var -> m a) -> (fun -> m a) -> Term fun -> m a
- measure :: (Sized f, Typed f) => Term f -> Measure f
- compareFuns :: Ord f => Term f -> Term f -> Ordering
- class Pretty a where
- pPrintPrec :: PrettyLevel -> Rational -> a -> Doc
- pPrint :: a -> Doc
- pPrintList :: PrettyLevel -> [a] -> Doc
- class Arity f where
- class EqualsBonus f
- prettyPrint :: Pretty a => a -> IO ()
- class Pretty f => PrettyTerm f where
- newtype TermStyle = TermStyle {
- pPrintTerm :: forall a. Pretty a => PrettyLevel -> Rational -> Doc -> [a] -> Doc
- module Twee.Pretty
Documentation
A sum type. Intended to be used to build the type of function symbols. Comes with instances that are useful for QuickSpec.
Instances
(Eq a, Eq b) => Eq (a :+: b) Source # | |
(Ord a, Ord b) => Ord (a :+: b) Source # | |
Defined in QuickSpec.Term | |
(Pretty fun1, Pretty fun2) => Pretty (fun1 :+: fun2) Source # | |
Defined in QuickSpec.Term Methods pPrintPrec :: PrettyLevel -> Rational -> (fun1 :+: fun2) -> Doc # pPrint :: (fun1 :+: fun2) -> Doc # pPrintList :: PrettyLevel -> [fun1 :+: fun2] -> Doc # | |
(Arity fun1, Arity fun2) => Arity (fun1 :+: fun2) Source # | |
Defined in QuickSpec.Term | |
(PrettyTerm fun1, PrettyTerm fun2) => PrettyTerm (fun1 :+: fun2) Source # | |
Defined in QuickSpec.Term | |
(Typed fun1, Typed fun2) => Typed (fun1 :+: fun2) Source # | |
(Sized fun1, Sized fun2) => Sized (fun1 :+: fun2) Source # | |
newtype MeasureFuns f Source #
A helper for Measure
.
Constructors
MeasureFuns (Term f) |
Instances
Ord f => Eq (MeasureFuns f) Source # | |
Defined in QuickSpec.Term Methods (==) :: MeasureFuns f -> MeasureFuns f -> Bool # (/=) :: MeasureFuns f -> MeasureFuns f -> Bool # | |
Ord f => Ord (MeasureFuns f) Source # | |
Defined in QuickSpec.Term Methods compare :: MeasureFuns f -> MeasureFuns f -> Ordering # (<) :: MeasureFuns f -> MeasureFuns f -> Bool # (<=) :: MeasureFuns f -> MeasureFuns f -> Bool # (>) :: MeasureFuns f -> MeasureFuns f -> Bool # (>=) :: MeasureFuns f -> MeasureFuns f -> Bool # max :: MeasureFuns f -> MeasureFuns f -> MeasureFuns f # min :: MeasureFuns f -> MeasureFuns f -> MeasureFuns f # |
type Measure f = (Int, Int, Int, MeasureFuns f, Int, [Var]) Source #
A standard term ordering - size, skeleton, generality. Satisfies the property: if measure (schema t) < measure (schema u) then t < u.
class Symbolic f a | a -> f where Source #
A class for things that contain terms.
Methods
termsDL :: a -> DList (Term f) Source #
A different list of all terms contained in the thing.
subst :: (Var -> Term f) -> a -> a Source #
Apply a substitution to all terms in the thing.
A variable, which has a type and a number.
Instances
Eq Var Source # | |
Ord Var Source # | |
Show Var Source # | |
Generic Var Source # | |
CoArbitrary Var Source # | |
Defined in QuickSpec.Term Methods coarbitrary :: Var -> Gen b -> Gen b # | |
Pretty Var Source # | |
Defined in QuickSpec.Term Methods pPrintPrec :: PrettyLevel -> Rational -> Var -> Doc # pPrintList :: PrettyLevel -> [Var] -> Doc # | |
Typed Var Source # | |
type Rep Var Source # | |
Defined in QuickSpec.Term type Rep Var = D1 (MetaData "Var" "QuickSpec.Term" "quickspec-2.1.1-8ayCzcvVUjmFxcf6Z16wEZ" False) (C1 (MetaCons "V" PrefixI True) (S1 (MetaSel (Just "var_ty") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Type) :*: S1 (MetaSel (Just "var_id") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int))) |
A typed term.
Instances
Functor Term Source # | |
Symbolic f (Term f) Source # | |
Eq f => Eq (Term f) Source # | |
Ord f => Ord (Term f) Source # | |
Show f => Show (Term f) Source # | |
PrettyTerm f => Pretty (Term f) Source # | |
Defined in QuickSpec.Term Methods pPrintPrec :: PrettyLevel -> Rational -> Term f -> Doc # pPrintList :: PrettyLevel -> [Term f] -> Doc # | |
Typed f => Typed (Term f) Source # | |
Sized f => Sized (Term f) Source # | |
funs :: Symbolic f a => a -> [f] Source #
All function symbols appearing in a Symbolic
, in order of appearance,
with duplicates included.
vars :: Symbolic f a => a -> [Var] Source #
All variables appearing in a Symbolic
, in order of appearance,
with duplicates included.
freeVar :: Symbolic f a => a -> Int Source #
Compute the number of a variable which does not appear in the Symbolic
.
occ :: (Eq f, Symbolic f a) => f -> a -> Int Source #
Count how many times a given function symbol occurs.
properSubterms :: Term f -> [Term f] Source #
Find all subterms of a term. Does not include the term itself.
canonicalise :: Symbolic fun a => a -> a Source #
Renames variables so that they appear in a canonical order. Also makes sure that variables of different types have different numbers.
evalTerm :: (Typed fun, Apply a, Monad m) => (Var -> m a) -> (fun -> m a) -> Term fun -> m a Source #
Evaluate a term, given a valuation for variables and function symbols.
Pretty printing class. The precedence level is used in a similar way as in
the Show
class. Minimal complete definition is either pPrintPrec
or
pPrint
.
Minimal complete definition
Instances
For types which have a notion of arity.
class EqualsBonus f #
A hack for encoding Horn clauses. See Score
.
The default implementation of hasEqualsBonus
should work OK.
Instances
EqualsBonus f => EqualsBonus (Extended f) | |
EqualsBonus f => EqualsBonus (Fun f) | |
prettyPrint :: Pretty a => a -> IO () #
Print a value to the console.
class Pretty f => PrettyTerm f where #
A class for customising the printing of function symbols.
Minimal complete definition
Nothing
Instances
PrettyTerm TyCon Source # | |
Defined in QuickSpec.Type | |
PrettyTerm f => PrettyTerm (Extended f) | |
PrettyTerm f => PrettyTerm (Fun f) | |
Defined in Twee.Pretty | |
(PrettyTerm fun1, PrettyTerm fun2) => PrettyTerm (fun1 :+: fun2) Source # | |
Defined in QuickSpec.Term |
Defines how to print out a function symbol.
Constructors
TermStyle | |
Fields
|
module Twee.Pretty