Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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, Int, MeasureFuns f, Int, [Var])
- data OrId f
- class Sized a where
- class Symbolic f a | a -> f where
- data Var = V {}
- data Term f
- pattern (:@:) :: Term f -> [Term f] -> Term f
- match :: Eq f => Term f -> Term f -> Maybe (Map Var (Term f))
- unify :: Eq f => Term f -> Term f -> Maybe (Map Var (Term f))
- terms :: Symbolic f a => a -> [Term f]
- funs :: Symbolic f a => a -> [f]
- vars :: Symbolic f a => a -> [Var]
- getApp :: Term f -> (Term f, [Term f])
- 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
- mapFun :: (f -> g) -> Term f -> Term g
- flatMapFun :: (f -> Term g) -> Term f -> Term g
- eliminateId :: Term (OrId f) -> Maybe (Term f)
- subterms :: Term f -> [Term f]
- properSubterms :: Term f -> [Term f]
- subtermsFO :: Term f -> [Term f]
- properSubtermsFO :: 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
- depth :: Term f -> Int
- 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 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.Internal.Term | |
(Pretty fun1, Pretty fun2) => Pretty (fun1 :+: fun2) Source # | |
Defined in QuickSpec.Internal.Term pPrintPrec :: PrettyLevel -> Rational -> (fun1 :+: fun2) -> Doc # pPrint :: (fun1 :+: fun2) -> Doc # pPrintList :: PrettyLevel -> [fun1 :+: fun2] -> Doc # | |
(Sized fun1, Sized fun2) => Sized (fun1 :+: fun2) Source # | |
(Typed fun1, Typed fun2) => Typed (fun1 :+: fun2) Source # | |
(PrettyTerm fun1, PrettyTerm fun2) => PrettyTerm (fun1 :+: fun2) Source # | |
Defined in QuickSpec.Internal.Term |
newtype MeasureFuns f Source #
A helper for Measure
.
MeasureFuns (Term f) |
Instances
Ord f => Eq (MeasureFuns f) Source # | |
Defined in QuickSpec.Internal.Term (==) :: MeasureFuns f -> MeasureFuns f -> Bool # (/=) :: MeasureFuns f -> MeasureFuns f -> Bool # | |
Ord f => Ord (MeasureFuns f) Source # | |
Defined in QuickSpec.Internal.Term 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, 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.
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
CoArbitrary Var Source # | |
Defined in QuickSpec.Internal.Term coarbitrary :: Var -> Gen b -> Gen b # | |
Generic Var Source # | |
Show Var Source # | |
Eq Var Source # | |
Ord Var Source # | |
Pretty Var Source # | |
Defined in QuickSpec.Internal.Term pPrintPrec :: PrettyLevel -> Rational -> Var -> Doc # pPrintList :: PrettyLevel -> [Var] -> Doc # | |
Typed Var Source # | |
type Rep Var Source # | |
Defined in QuickSpec.Internal.Term type Rep Var = D1 ('MetaData "Var" "QuickSpec.Internal.Term" "quickspec-2.2-IZSjQ5lmka18t2AqwSyTXi" '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
Foldable Term Source # | |
Defined in QuickSpec.Internal.Term fold :: Monoid m => Term m -> m # foldMap :: Monoid m => (a -> m) -> Term a -> m # foldMap' :: Monoid m => (a -> m) -> Term a -> m # foldr :: (a -> b -> b) -> b -> Term a -> b # foldr' :: (a -> b -> b) -> b -> Term a -> b # foldl :: (b -> a -> b) -> b -> Term a -> b # foldl' :: (b -> a -> b) -> b -> Term a -> b # foldr1 :: (a -> a -> a) -> Term a -> a # foldl1 :: (a -> a -> a) -> Term a -> a # elem :: Eq a => a -> Term a -> Bool # maximum :: Ord a => Term a -> a # | |
Traversable Term Source # | |
Functor Term Source # | |
Symbolic f (Term f) Source # | |
Show f => Show (Term f) Source # | |
Eq f => Eq (Term f) Source # | |
Ord f => Ord (Term f) Source # | |
PrettyTerm f => Pretty (Term f) Source # | |
Defined in QuickSpec.Internal.Term pPrintPrec :: PrettyLevel -> Rational -> Term f -> Doc # pPrintList :: PrettyLevel -> [Term f] -> Doc # | |
Sized f => Sized (Term f) Source # | |
(PrettyTerm f, Typed f) => Apply (Term f) Source # | |
Typed f => Typed (Term f) Source # | |
pattern (:@:) :: Term f -> [Term f] -> Term f Source #
Decompose a term into a head and a list of arguments.
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.
subtermsFO :: Term f -> [Term f] Source #
properSubtermsFO :: Term f -> [Term f] Source #
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
.
pPrintPrec :: PrettyLevel -> Rational -> a -> Doc #
pPrintList :: PrettyLevel -> [a] -> Doc #
Instances
class EqualsBonus f #
A hack for encoding Horn clauses. See Score
.
The default implementation of hasEqualsBonus
should work OK.
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.
Nothing
Instances
PrettyTerm TyCon Source # | |
Defined in QuickSpec.Internal.Type | |
(PrettyTerm fun1, PrettyTerm fun2) => PrettyTerm (fun1 :+: fun2) Source # | |
Defined in QuickSpec.Internal.Term |
Defines how to print out a function symbol.
TermStyle | |
|
module Twee.Pretty