tct-2.0.1: A Complexity Analyser for Term Rewrite Systems

Portabilityunportable
Stabilityunstable
MaintainerMartin Avanzini <martin.avanzini@uibk.ac.at>
Safe HaskellNone

Tct.Processor.Args.Instances

Contents

Description

This module defines various instances of processor arguments.

Synopsis

Documentation

data Proc a

Constructors

Proc a 

newtype Assoc a

Constructors

Assoc a 

Instances

class AssocArgument a where

Instances of this class can be parsed by means of the defined method assoc.

Methods

assoc :: Phantom a -> [(String, a)]

The resulting list associates names to elements, and should be finite. An element is parsed by parsing its name.

newtype EnumOf a

Constructors

EnumOf a 

Instances

nat :: Int -> Nat

Constructors for Arguments

naturalArg :: Arg Nat

Natural argument

boolArg :: Arg Bool

Boolean argument, which is parsed as either On or Off.

maybeArg :: Arg a -> Arg (Maybe a)

Argument, that additionally parses as none.

listArg :: Arg a -> Arg [a]

A list of arguments.

processorArg :: Arg Processor

Processor argument

type EnumArg a = Arg (EnumOf a)

This can be used to lift instances of Typeable, Show, Enum and Bounded to arguments. Suppose you have a datatype like the following.

>>> data MyType = A | B | C deriving (Typeable, Show, Enum, Bounded)

An argument description for an element of type MyType is then given by

>>> arg :: EnumArg MyType

type AssocArg a = Arg (Assoc a)

Construct an argument from an associated list, by declaring a datatype an instance of AssocArgument. Use as follows:

>>> instance AssocArgument MyType where
     assoc _ = [("nameA", valueA), ("nameB", valueB)...]

Then one can use a declaration

>>> arg :: AssocArg MyType

which will parse valueA as nameA, valueB as nameB, and so on.