-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Feedback services for intelligent tutoring systems -- -- Ideas (Interactive Domain-specific Exercise Assistants) is a joint -- research project between the Open University of the Netherlands and -- Utrecht University. The project's goal is to use software and compiler -- technology to build state-of-the-art components for intelligent -- tutoring systems (ITS) and learning environments. The ideas -- software package provides a generic framework for constructing the -- expert knowledge module (also known as a domain reasoner) for an ITS -- or learning environment. Domain knowledge is offered as a set of -- feedback services that are used by external tools such as the digital -- mathematical environment (DME), MathDox, and the Math-Bridge system. -- We have developed several domain reasoners based on this framework, -- including reasoners for mathematics, linear algebra, logic, learning -- Haskell (the Ask-Elle programming tutor) and evaluating Haskell -- expressions, and for practicing communication skills (the serious game -- Communicate!). @package ideas @version 1.8 -- | Type classes and instances. module Ideas.Common.Classes -- | A type class for functors that can be applied to a value. -- Transformation, Rule, and Strategy are all instances of this type -- class. class Apply t applyAll :: Apply t => t a -> a -> [a] -- | Returns zero or one results apply :: Apply t => t a -> a -> Maybe a -- | Checks whether the functor is applicable (at least one result) applicable :: Apply t => t a -> a -> Bool -- | If not applicable, return the current value (as default) applyD :: Apply t => t a -> a -> a -- | Same as apply, except that the result (at most one) is returned in -- some monad applyM :: (Apply t, Monad m) => t a -> a -> m a applyList :: Apply t => [t a] -> a -> Maybe a -- | Instances should satisfy the following law: getSingleton . -- singleton == Just class Container f singleton :: Container f => a -> f a getSingleton :: Container f => f a -> Maybe a -- | Type class for bi-directional arrows. - should be used -- instead of arr from the arrow interface. Minimal complete -- definition: -. class Arrow arr => BiArrow arr (<->) :: BiArrow arr => (a -> b) -> (b -> a) -> arr a b (!->) :: BiArrow arr => (a -> b) -> arr a b (<-!) :: BiArrow arr => (b -> a) -> arr a b class BiFunctor f biMap :: BiFunctor f => (a -> c) -> (b -> d) -> f a b -> f c d mapFirst :: BiFunctor f => (a -> b) -> f a c -> f b c mapSecond :: BiFunctor f => (b -> c) -> f a b -> f a c mapBoth :: BiFunctor f => (a -> b) -> f a a -> f b b class Fix a fix :: Fix a => (a -> a) -> a class BoolValue a true :: BoolValue a => a false :: BoolValue a => a fromBool :: BoolValue a => Bool -> a isTrue :: BoolValue a => a -> Bool isFalse :: BoolValue a => a -> Bool class BoolValue a => Boolean a (<&&>) :: Boolean a => a -> a -> a (<||>) :: Boolean a => a -> a -> a complement :: Boolean a => a -> a ands :: Boolean a => [a] -> a ors :: Boolean a => [a] -> a implies :: Boolean a => a -> a -> a equivalent :: Boolean a => a -> a -> a class Buggy a buggy :: Buggy a => a -> a setBuggy :: Buggy a => Bool -> a -> a isBuggy :: Buggy a => a -> Bool class Minor a minor :: Minor a => a -> a setMinor :: Minor a => Bool -> a -> a isMinor :: Minor a => a -> Bool isMajor :: Minor a => a -> Bool instance Ideas.Common.Classes.Boolean GHC.Types.Bool instance Ideas.Common.Classes.Boolean b => Ideas.Common.Classes.Boolean (a -> b) instance Ideas.Common.Classes.BoolValue GHC.Types.Bool instance Ideas.Common.Classes.BoolValue b => Ideas.Common.Classes.BoolValue (a -> b) instance Ideas.Common.Classes.BiFunctor Data.Either.Either instance Ideas.Common.Classes.BiFunctor (,) instance Ideas.Common.Classes.Container [] instance Ideas.Common.Classes.Container Data.Set.Internal.Set module Ideas.Common.Rewriting.AC type Pairings a = a -> a -> [[(a, a)]] type PairingsList a b = [a] -> [b] -> [[([a], [b])]] type PairingsPair a b = (a, a) -> (b, b) -> [[(a, b)]] pairingsNone :: PairingsPair a b pairingsA :: Bool -> PairingsList a b pairingsMatchA :: (a -> [b] -> c) -> [a] -> [b] -> [[c]] pairingsC :: PairingsPair a b pairingsAC :: Bool -> PairingsList a b -- | A type class for expressing choice, preference, and left-biased -- choice. The Menu datatype implements the type class by keeping -- all the alternatives. module Ideas.Common.Strategy.Choice -- | Laws: .|., ./. |> are all associative, and -- have empty as their unit element. class Choice a -- | Nothing to choose from. empty :: Choice a => a -- | Normal (unbiased) choice. (.|.) :: Choice a => a -> a -> a -- | Left-preference. (./.) :: Choice a => a -> a -> a -- | Left-biased choice. (|>) :: Choice a => a -> a -> a -- | One of the alternatives in a list (unbiased). choice :: Choice a => [a] -> a preference :: Choice a => [a] -> a orelse :: Choice a => [a] -> a -- | A menu offers choices and preferences. It stores singleton bindings -- (thus acting as a finite map) and one special element -- (doneMenu). It is an instance of the Functor and -- Monad type classes. data Menu k a -- | Singleton binding (|->) :: a -> s -> Menu a s infixr 5 |-> -- | Special element for denoting success doneMenu :: Menu k a -- | Equality with a comparison function for the elements eqMenuBy :: (k -> k -> Bool) -> (a -> a -> Bool) -> Menu k a -> Menu k a -> Bool -- | Returns all elements that are in the menu. elems :: Menu k a -> [(k, a)] -- | Returns only the best elements that are in the menu with respect to -- left-biased choices. bests :: Menu k a -> [(k, a)] -- | Returns only the best elements that are in the menu, with a given -- ordering. bestsOrdered :: (k -> k -> Ordering) -> Menu k a -> [(k, a)] -- | Is the menu empty? isEmpty :: Menu k a -> Bool hasDone :: Menu k a -> Bool -- | Get an element from the menu by its index. getByIndex :: Int -> Menu k a -> Maybe (k, a) -- | Only keep the best elements in the menu. cut :: Menu k a -> Menu k a -- | Generalized monadic bind, with the arguments flipped. onMenu :: Choice b => (k -> a -> b) -> b -> Menu k a -> b -- | Maps a function over a menu that also takes the index of an element. onMenuWithIndex :: Choice b => (Int -> k -> a -> b) -> b -> Menu k a -> b instance (GHC.Classes.Eq k, GHC.Classes.Eq a) => GHC.Classes.Eq (Ideas.Common.Strategy.Choice.Menu k a) instance Ideas.Common.Strategy.Choice.Choice (Ideas.Common.Strategy.Choice.Menu k a) instance GHC.Base.Functor (Ideas.Common.Strategy.Choice.Menu k) instance Ideas.Common.Strategy.Choice.Choice [a] instance Ideas.Common.Strategy.Choice.Choice b => Ideas.Common.Strategy.Choice.Choice (a -> b) module Ideas.Common.Traversal.Utils class Update f update :: Update f => f a -> (a, a -> f a) current :: Update f => f a -> a change :: Update f => (a -> a) -> f a -> f a replace :: Update f => a -> f a -> f a changeM :: Update f => (a -> Maybe a) -> f a -> Maybe (f a) changeG :: (Update f, Monad g) => (a -> g a) -> f a -> g (f a) class Focus a where { type family Unfocus a; } focus :: Focus a => Unfocus a -> a focusM :: Focus a => Unfocus a -> Maybe a unfocus :: Focus a => a -> Unfocus a liftFocus :: Focus a => (Unfocus a -> Maybe (Unfocus a)) -> a -> Maybe a unliftFocus :: Focus a => (a -> Maybe a) -> Unfocus a -> Maybe (Unfocus a) class Wrapper f wrap :: Wrapper f => a -> f a unwrap :: Wrapper f => f a -> a liftWrapper :: (Monad m, Wrapper f) => (a -> m a) -> f a -> m (f a) unliftWrapper :: (Monad m, Wrapper f) => (f a -> m (f a)) -> a -> m a mapWrapper :: Wrapper f => (a -> a) -> f a -> f a data Mirror a makeMirror :: a -> Mirror a (>|<) :: (a -> Maybe a) -> (a -> Maybe a) -> a -> Maybe a infixr 0 >|< safe :: (a -> Maybe a) -> a -> a fixp :: (a -> Maybe a) -> a -> a fixpl :: (a -> Maybe a) -> a -> [a] -- | An associative operation. The default definition is -- --
--   mplus = (<|>)
--   
mplus :: MonadPlus m => m a -> m a -> m a -- | Left-to-right Kleisli composition of monads. (>=>) :: Monad m => a -> m b -> b -> m c -> a -> m c infixr 1 >=> instance GHC.Classes.Eq a => GHC.Classes.Eq (Ideas.Common.Traversal.Utils.Mirror a) instance GHC.Show.Show a => GHC.Show.Show (Ideas.Common.Traversal.Utils.Mirror a) instance Ideas.Common.Traversal.Utils.Wrapper Ideas.Common.Traversal.Utils.Mirror module Ideas.Common.Traversal.Iterator class Iterator a next :: Iterator a => a -> Maybe a previous :: Iterator a => a -> Maybe a first :: Iterator a => a -> a final :: Iterator a => a -> a position :: Iterator a => a -> Int isFirst :: Iterator a => a -> Bool isFinal :: Iterator a => a -> Bool hasNext :: Iterator a => a -> Bool hasPrevious :: Iterator a => a -> Bool searchForward :: Iterator a => (a -> Bool) -> a -> Maybe a searchBackward :: Iterator a => (a -> Bool) -> a -> Maybe a searchNext :: Iterator a => (a -> Bool) -> a -> Maybe a searchPrevious :: Iterator a => (a -> Bool) -> a -> Maybe a searchWith :: (a -> Maybe a) -> (a -> Bool) -> a -> Maybe a data ListIterator a instance GHC.Classes.Eq a => GHC.Classes.Eq (Ideas.Common.Traversal.Iterator.ListIterator a) instance GHC.Show.Show a => GHC.Show.Show (Ideas.Common.Traversal.Iterator.ListIterator a) instance Ideas.Common.Traversal.Iterator.Iterator (Ideas.Common.Traversal.Iterator.ListIterator a) instance Ideas.Common.Traversal.Utils.Focus (Ideas.Common.Traversal.Iterator.ListIterator a) instance Ideas.Common.Traversal.Utils.Update Ideas.Common.Traversal.Iterator.ListIterator instance Test.QuickCheck.Arbitrary.Arbitrary a => Test.QuickCheck.Arbitrary.Arbitrary (Ideas.Common.Traversal.Iterator.ListIterator a) instance Ideas.Common.Traversal.Iterator.Iterator a => Ideas.Common.Traversal.Iterator.Iterator (Ideas.Common.Traversal.Utils.Mirror a) module Ideas.Main.CGI -- | Run an application using CGI. run :: Application -> IO () module Ideas.Main.Revision ideasVersion :: String ideasRevision :: String ideasLastChanged :: String -- | Support for LaTeX. module Ideas.Text.Latex data Latex class ToLatex a toLatex :: ToLatex a => a -> Latex toLatexPrec :: ToLatex a => Int -> a -> Latex toLatexList :: ToLatex a => [a] -> Latex array :: String -> [[Latex]] -> Latex commas :: [Latex] -> Latex brackets :: Latex -> Latex parens :: Latex -> Latex command :: String -> Latex instance Ideas.Text.Latex.ToLatex a => Ideas.Text.Latex.ToLatex [a] instance Ideas.Text.Latex.ToLatex a => Ideas.Text.Latex.ToLatex (GHC.Base.Maybe a) instance Ideas.Text.Latex.ToLatex GHC.Types.Char instance Ideas.Text.Latex.ToLatex GHC.Types.Int instance GHC.Show.Show Ideas.Text.Latex.Latex instance Data.String.IsString Ideas.Text.Latex.Latex instance GHC.Base.Semigroup Ideas.Text.Latex.Latex instance GHC.Base.Monoid Ideas.Text.Latex.Latex module Ideas.Text.OpenMath.Symbol type Symbol = (Maybe String, String) makeSymbol :: String -> String -> Symbol extraSymbol :: String -> Symbol dictionary :: Symbol -> Maybe String symbolName :: Symbol -> String showSymbol :: Symbol -> String module Ideas.Text.OpenMath.Dictionary.Transc1 -- | List of symbols defined in transc1 dictionary transc1List :: [Symbol] -- | This symbol represents a binary log function; the first argument is -- the base, to which the second argument is log'ed. It is defined in -- Abramowitz and Stegun, Handbook of Mathematical Functions, section 4.1 logSymbol :: Symbol -- | This symbol represents the ln function (natural logarithm) as -- described in Abramowitz and Stegun, section 4.1. It takes one -- argument. Note the description in the CMP/FMP of the branch cut. If -- signed zeros are in use, the inequality needs to be non-strict. lnSymbol :: Symbol -- | This symbol represents the exponentiation function as described in -- Abramowitz and Stegun, section 4.2. It takes one argument. expSymbol :: Symbol -- | This symbol represents the sin function as described in Abramowitz and -- Stegun, section 4.3. It takes one argument. sinSymbol :: Symbol -- | This symbol represents the cos function as described in Abramowitz and -- Stegun, section 4.3. It takes one argument. cosSymbol :: Symbol -- | This symbol represents the tan function as described in Abramowitz and -- Stegun, section 4.3. It takes one argument. tanSymbol :: Symbol -- | This symbol represents the sec function as described in Abramowitz and -- Stegun, section 4.3. It takes one argument. secSymbol :: Symbol -- | This symbol represents the csc function as described in Abramowitz and -- Stegun, section 4.3. It takes one argument. cscSymbol :: Symbol -- | This symbol represents the cot function as described in Abramowitz and -- Stegun, section 4.3. It takes one argument. cotSymbol :: Symbol -- | This symbol represents the sinh function as described in Abramowitz -- and Stegun, section 4.5. It takes one argument. sinhSymbol :: Symbol -- | This symbol represents the cosh function as described in Abramowitz -- and Stegun, section 4.5. It takes one argument. coshSymbol :: Symbol -- | This symbol represents the tanh function as described in Abramowitz -- and Stegun, section 4.5. It takes one argument. tanhSymbol :: Symbol -- | This symbol represents the sech function as described in Abramowitz -- and Stegun, section 4.5. It takes one argument. sechSymbol :: Symbol -- | This symbol represents the csch function as described in Abramowitz -- and Stegun, section 4.5. It takes one argument. cschSymbol :: Symbol -- | This symbol represents the coth function as described in Abramowitz -- and Stegun, section 4.5. It takes one argument. cothSymbol :: Symbol -- | This symbol represents the arcsin function. This is the inverse of the -- sin function as described in Abramowitz and Stegun, section 4.4. It -- takes one argument. arcsinSymbol :: Symbol -- | This symbol represents the arccos function. This is the inverse of the -- cos function as described in Abramowitz and Stegun, section 4.4. It -- takes one argument. arccosSymbol :: Symbol -- | This symbol represents the arctan function. This is the inverse of the -- tan function as described in Abramowitz and Stegun, section 4.4. It -- takes one argument. arctanSymbol :: Symbol -- | This symbol represents the arcsec function as described in Abramowitz -- and Stegun, section 4.4. arcsecSymbol :: Symbol -- | This symbol represents the arccsc function as described in Abramowitz -- and Stegun, section 4.4. arccscSymbol :: Symbol -- | This symbol represents the arccot function as described in Abramowitz -- and Stegun, section 4.4. arccotSymbol :: Symbol -- | This symbol represents the arcsinh function as described in Abramowitz -- and Stegun, section 4.6. arcsinhSymbol :: Symbol -- | This symbol represents the arccosh function as described in Abramowitz -- and Stegun, section 4.6. arccoshSymbol :: Symbol -- | This symbol represents the arctanh function as described in Abramowitz -- and Stegun, section 4.6. arctanhSymbol :: Symbol -- | This symbol represents the arcsech function as described in Abramowitz -- and Stegun, section 4.6. arcsechSymbol :: Symbol -- | This symbol represents the arccsch function as described in Abramowitz -- and Stegun, section 4.6. arccschSymbol :: Symbol -- | This symbol represents the arccoth function as described in Abramowitz -- and Stegun, section 4.6. arccothSymbol :: Symbol module Ideas.Text.OpenMath.Dictionary.Relation1 -- | List of symbols defined in relation1 dictionary relation1List :: [Symbol] -- | This symbol represents the binary equality function. eqSymbol :: Symbol -- | This symbol represents the binary less than function which returns -- true if the first argument is less than the second, it returns false -- otherwise. ltSymbol :: Symbol -- | This symbol represents the binary greater than function which returns -- true if the first argument is greater than the second, it returns -- false otherwise. gtSymbol :: Symbol -- | This symbol represents the binary inequality function. neqSymbol :: Symbol -- | This symbol represents the binary less than or equal to function which -- returns true if the first argument is less than or equal to the -- second, it returns false otherwise. leqSymbol :: Symbol -- | This symbol represents the binary greater than or equal to function -- which returns true if the first argument is greater than or equal to -- the second, it returns false otherwise. geqSymbol :: Symbol -- | This symbol is used to denote the approximate equality of its two -- arguments. approxSymbol :: Symbol module Ideas.Text.OpenMath.Dictionary.Quant1 -- | List of symbols defined in quant1 dictionary quant1List :: [Symbol] -- | This symbol represents the universal ("for all") quantifier which -- takes two arguments. It must be placed within an OMBIND element. The -- first argument is the bound variables (placed within an OMBVAR -- element), and the second is an expression. forallSymbol :: Symbol -- | This symbol represents the existential ("there exists") quantifier -- which takes two arguments. It must be placed within an OMBIND element. -- The first argument is the bound variables (placed within an OMBVAR -- element), and the second is an expression. existsSymbol :: Symbol module Ideas.Text.OpenMath.Dictionary.Nums1 -- | List of symbols defined in nums1 dictionary nums1List :: [Symbol] -- | This symbol represents the constructor function for integers, -- specifying the base. It takes two arguments, the first is a positive -- integer to denote the base to which the number is represented, the -- second argument is a string which contains an optional sign and the -- digits of the integer, using 0-9a-z (as a consequence of this no radix -- greater than 35 is supported). Base 16 and base 10 are already covered -- in the encodings of integers. basedIntegerSymbol :: Symbol -- | This symbol represents the constructor function for rational numbers. -- It takes two arguments, the first is an integer p to denote the -- numerator and the second a nonzero integer q to denote the denominator -- of the rational p/q. rationalSymbol :: Symbol -- | A symbol to represent the notion of infinity. infinitySymbol :: Symbol -- | This symbol represents the base of the natural logarithm, -- approximately 2.718. See Abramowitz and Stegun, Handbook of -- Mathematical Functions, section 4.1. eSymbol :: Symbol -- | This symbol represents the square root of -1. iSymbol :: Symbol -- | A symbol to convey the notion of pi, approximately 3.142. The ratio of -- the circumference of a circle to its diameter. piSymbol :: Symbol -- | A symbol to convey the notion of the gamma constant as defined in -- Abramowitz and Stegun, Handbook of Mathematical Functions, section -- 6.1.3. It is the limit of 1 + 12 + 13 + ... + 1/m - ln m as m -- tends to infinity, this is approximately 0.5772 15664. gammaSymbol :: Symbol -- | A symbol to convey the notion of not-a-number. The result of an -- ill-posed floating computation. See IEEE standard for floating point -- representations. naNSymbol :: Symbol module Ideas.Text.OpenMath.Dictionary.Logic1 -- | List of symbols defined in logic1 dictionary logic1List :: [Symbol] -- | This symbol is used to show that two boolean expressions are logically -- equivalent, that is have the same boolean value for any inputs. equivalentSymbol :: Symbol -- | This symbol represents the logical not function which takes one -- boolean argument, and returns the opposite boolean value. notSymbol :: Symbol -- | This symbol represents the logical and function which is an n-ary -- function taking boolean arguments and returning a boolean value. It is -- true if all arguments are true or false otherwise. andSymbol :: Symbol -- | This symbol represents the logical xor function which is an n-ary -- function taking boolean arguments and returning a boolean value. It is -- true if there are an odd number of true arguments or false otherwise. xorSymbol :: Symbol -- | This symbol represents the logical or function which is an n-ary -- function taking boolean arguments and returning a boolean value. It is -- true if any of the arguments are true or false otherwise. orSymbol :: Symbol -- | This symbol represents the logical implies function which takes two -- boolean expressions as arguments. It evaluates to false if the first -- argument is true and the second argument is false, otherwise it -- evaluates to true. impliesSymbol :: Symbol -- | This symbol represents the boolean value true. trueSymbol :: Symbol -- | This symbol represents the boolean value false. falseSymbol :: Symbol module Ideas.Text.OpenMath.Dictionary.List1 -- | List of symbols defined in list1 dictionary list1List :: [Symbol] -- | This symbol represents a mapping function which may be used to -- construct lists, it takes as arguments a function from X to Y and a -- list over X in that order. The value that is returned is a list of -- values in Y. The argument list may be a set or an integer_interval. mapSymbol :: Symbol -- | This symbol represents the suchthat function which may be used to -- construct lists, it takes two arguments. The first argument should be -- the set which contains the elements of the list, the second argument -- should be a predicate, that is a function from the set to the booleans -- which describes if an element is to be in the list returned. suchthatSymbol :: Symbol -- | This symbol denotes the list construct which is an n-ary function. The -- list entries must be given explicitly. listSymbol :: Symbol module Ideas.Text.OpenMath.Dictionary.Linalg2 -- | List of symbols defined in linalg2 dictionary linalg2List :: [Symbol] -- | This symbol represents an n-ary function used to construct (or -- describe) vectors. Vectors in this CD are considered to be row vectors -- and must therefore be transposed to be considered as column vectors. vectorSymbol :: Symbol -- | This symbol is an n-ary constructor used to represent rows of -- matrices. Its arguments should be members of a ring. matrixrowSymbol :: Symbol -- | This symbol is an n-ary matrix constructor which requires matrixrow's -- as arguments. It is used to represent matrices. matrixSymbol :: Symbol module Ideas.Text.OpenMath.Dictionary.Fns1 -- | List of symbols defined in fns1 dictionary fns1List :: [Symbol] -- | The domainofapplication element denotes the domain over which a given -- function is being applied. It is intended in MathML to be a more -- general alternative to specification of this domain using such -- quantifier elements as bvar, lowlimit or condition. domainofapplicationSymbol :: Symbol -- | This symbol denotes the domain of a given function, which is the set -- of values it is defined over. domainSymbol :: Symbol -- | This symbol denotes the range of a function, that is a set that the -- function will map to. The single argument should be the function whos -- range is being queried. It should be noted that this is not -- necessarily equal to the image, it is merely required to contain the -- image. rangeSymbol :: Symbol -- | This symbol denotes the image of a given function, which is the set of -- values the domain of the given function maps to. imageSymbol :: Symbol -- | The identity function, it takes one argument and returns the same -- value. identitySymbol :: Symbol -- | This symbol is used to describe the left inverse of its argument (a -- function). This inverse may only be partially defined because the -- function may not have been surjective. If the function is not -- surjective the left inverse function is ill-defined without further -- stipulations. No other assumptions are made on the semantics of this -- left inverse. leftInverseSymbol :: Symbol -- | This symbol is used to describe the right inverse of its argument (a -- function). This inverse may only be partially defined because the -- function may not have been surjective. If the function is not -- surjective the right inverse function is ill-defined without further -- stipulations. No other assumptions are made on the semantics of this -- right inverse. rightInverseSymbol :: Symbol -- | This symbol is used to describe the inverse of its argument (a -- function). This inverse may only be partially defined because the -- function may not have been surjective. If the function is not -- surjective the inverse function is ill-defined without further -- stipulations. No assumptions are made on the semantics of this -- inverse. inverseSymbol :: Symbol -- | This symbol represents the function which forms the left-composition -- of its two (function) arguments. leftComposeSymbol :: Symbol -- | This symbol is used to represent anonymous functions as lambda -- expansions. It is used in a binder that takes two further arguments, -- the first of which is a list of variables, and the second of which is -- an expression, and it forms the function which is the lambda -- extraction of the expression lambdaSymbol :: Symbol module Ideas.Text.OpenMath.Dictionary.Calculus1 -- | List of symbols defined in calculus1 dictionary calculus1List :: [Symbol] -- | This symbol is used to express ordinary differentiation of a unary -- function. The single argument is the unary function. diffSymbol :: Symbol -- | This symbol is used to express the nth-iterated ordinary -- differentiation of a unary function. The first argument is n, and the -- second the unary function. nthdiffSymbol :: Symbol -- | This symbol is used to express partial differentiation of a function -- of more than one variable. It has two arguments, the first is a list -- of integers which index the variables of the function, the second is -- the function. partialdiffSymbol :: Symbol -- | This symbol is used to represent indefinite integration of unary -- functions. The argument is the unary function. intSymbol :: Symbol -- | This symbol is used to represent definite integration of unary -- functions. It takes two arguments; the first being the range (e.g. a -- set) of integration, and the second the function. defintSymbol :: Symbol module Ideas.Text.OpenMath.Dictionary.Arith1 -- | List of symbols defined in arith1 dictionary arith1List :: [Symbol] -- | The symbol to represent the n-ary function to return the least common -- multiple of its arguments. lcmSymbol :: Symbol -- | The symbol to represent the n-ary function to return the gcd (greatest -- common divisor) of its arguments. gcdSymbol :: Symbol -- | The symbol representing an n-ary commutative function plus. plusSymbol :: Symbol -- | This symbol denotes unary minus, i.e. the additive inverse. unaryMinusSymbol :: Symbol -- | The symbol representing a binary minus function. This is equivalent to -- adding the additive inverse. minusSymbol :: Symbol -- | The symbol representing an n-ary multiplication function. timesSymbol :: Symbol -- | This symbol represents a (binary) division function denoting the first -- argument right-divided by the second, i.e. divide(a,b)=a*inverse(b). -- It is the inverse of the multiplication function defined by the symbol -- times in this CD. divideSymbol :: Symbol -- | This symbol represents a power function. The first argument is raised -- to the power of the second argument. When the second argument is not -- an integer, powering is defined in terms of exponentials and -- logarithms for the complex and real numbers. This operator can -- represent general powering. powerSymbol :: Symbol -- | A unary operator which represents the absolute value of its argument. -- The argument should be numerically valued. In the complex case this is -- often referred to as the modulus. absSymbol :: Symbol -- | A binary operator which represents its first argument "lowered" to its -- n'th root where n is the second argument. This is the inverse of the -- operation represented by the power symbol defined in this CD. Care -- should be taken as to the precise meaning of this operator, in -- particular which root is represented, however it is here to represent -- the general notion of taking n'th roots. As inferred by the signature -- relevant to this symbol, the function represented by this symbol is -- the single valued function, the specific root returned is the one -- indicated by the first CMP. Note also that the converse of the second -- CMP is not valid in general. rootSymbol :: Symbol -- | An operator taking two arguments, the first being the range of -- summation, e.g. an integral interval, the second being the function to -- be summed. Note that the sum may be over an infinite interval. sumSymbol :: Symbol -- | An operator taking two arguments, the first being the range of -- multiplication e.g. an integral interval, the second being the -- function to be multiplied. Note that the product may be over an -- infinite interval. productSymbol :: Symbol -- | Support for the UTF8 encoding module Ideas.Text.UTF8 -- | Encode a string to UTF8 format encode :: String -> String -- | Encode a string to UTF8 format (monadic) encodeM :: Monad m => String -> m String -- | Decode an UTF8 format string to unicode points decode :: String -> String -- | Decode an UTF8 format string to unicode points (monadic) decodeM :: Monad m => String -> m String -- | Test whether the argument is a proper UTF8 string isUTF8 :: String -> Bool -- | Test whether all characters are in the range 0-255 allBytes :: String -> Bool -- | QuickCheck internal encoding/decoding functions propEncoding :: Property -- | Datatype for representing XML documents module Ideas.Text.XML.Document type Name = String type Attributes = [Attribute] data Attribute (:=) :: Name -> AttValue -> Attribute data Reference CharRef :: Int -> Reference EntityRef :: String -> Reference newtype Parameter Parameter :: String -> Parameter data XMLDoc XMLDoc :: Maybe String -> Maybe String -> Maybe Bool -> Maybe DTD -> [(String, External)] -> Element -> XMLDoc [versionInfo] :: XMLDoc -> Maybe String [encoding] :: XMLDoc -> Maybe String [standalone] :: XMLDoc -> Maybe Bool [dtd] :: XMLDoc -> Maybe DTD [externals] :: XMLDoc -> [(String, External)] [root] :: XMLDoc -> Element data XML Tagged :: Element -> XML CharData :: String -> XML CDATA :: String -> XML Reference :: Reference -> XML data Element Element :: Name -> Attributes -> Content -> Element [name] :: Element -> Name [attributes] :: Element -> Attributes [content] :: Element -> Content type Content = [XML] data DTD DTD :: Name -> (Maybe ExternalID) -> [DocTypeDecl] -> DTD data DocTypeDecl ElementDecl :: Name -> ContentSpec -> DocTypeDecl AttListDecl :: Name -> [AttDef] -> DocTypeDecl EntityDecl :: Bool -> Name -> EntityDef -> DocTypeDecl NotationDecl :: Name -> (Either ExternalID PublicID) -> DocTypeDecl DTDParameter :: Parameter -> DocTypeDecl DTDConditional :: Conditional -> DocTypeDecl data ContentSpec Empty :: ContentSpec Any :: ContentSpec Mixed :: Bool -> [Name] -> ContentSpec Children :: CP -> ContentSpec data CP Choice :: [CP] -> CP Sequence :: [CP] -> CP QuestionMark :: CP -> CP Star :: CP -> CP Plus :: CP -> CP CPName :: Name -> CP data AttType IdType :: AttType IdRefType :: AttType IdRefsType :: AttType EntityType :: AttType EntitiesType :: AttType NmTokenType :: AttType NmTokensType :: AttType StringType :: AttType EnumerationType :: [String] -> AttType NotationType :: [String] -> AttType data DefaultDecl Required :: DefaultDecl Implied :: DefaultDecl Value :: AttValue -> DefaultDecl Fixed :: AttValue -> DefaultDecl type AttDef = (Name, AttType, DefaultDecl) type EntityDef = Either EntityValue (ExternalID, Maybe String) type AttValue = [Either Char Reference] type EntityValue = [Either Char (Either Parameter Reference)] data ExternalID System :: String -> ExternalID Public :: String -> String -> ExternalID type PublicID = String data Conditional Include :: [DocTypeDecl] -> Conditional Ignore :: [String] -> Conditional type TextDecl = (Maybe String, String) type External = (Maybe TextDecl, Content) prettyXML :: Bool -> XML -> Doc prettyElement :: Bool -> Element -> Doc escape :: String -> String instance GHC.Show.Show Ideas.Text.XML.Document.XML instance GHC.Show.Show Ideas.Text.XML.Document.Element instance Text.PrettyPrint.Leijen.Pretty Ideas.Text.XML.Document.XML instance Text.PrettyPrint.Leijen.Pretty Ideas.Text.XML.Document.Element instance GHC.Show.Show Ideas.Text.XML.Document.Attribute instance Text.PrettyPrint.Leijen.Pretty Ideas.Text.XML.Document.Attribute instance GHC.Show.Show Ideas.Text.XML.Document.Parameter instance Text.PrettyPrint.Leijen.Pretty Ideas.Text.XML.Document.Parameter instance GHC.Show.Show Ideas.Text.XML.Document.Reference instance Text.PrettyPrint.Leijen.Pretty Ideas.Text.XML.Document.Reference -- | Support for Unicode module Ideas.Text.XML.Unicode isExtender :: Char -> Bool isLetter :: Char -> Bool isDigit :: Char -> Bool isCombiningChar :: Char -> Bool decoding :: Monad m => String -> m String -- | Extensions to the QuickCheck library module Ideas.Utils.Decoding data Decoder env s a runDecoder :: Monad m => Decoder env s a -> env -> s -> m a symbol :: Decoder env [s] s type Encoder env = Decoder env () runEncoder :: Monad m => Encoder env a -> env -> m a data Error a runError :: Error a -> Either String a runErrorM :: Monad m => Error a -> m a instance Control.Monad.State.Class.MonadState s (Ideas.Utils.Decoding.Decoder env s) instance Control.Monad.Reader.Class.MonadReader env (Ideas.Utils.Decoding.Decoder env s) instance GHC.Base.MonadPlus (Ideas.Utils.Decoding.Decoder env s) instance GHC.Base.Monad (Ideas.Utils.Decoding.Decoder env s) instance GHC.Base.Alternative (Ideas.Utils.Decoding.Decoder env s) instance GHC.Base.Applicative (Ideas.Utils.Decoding.Decoder env s) instance GHC.Base.Functor (Ideas.Utils.Decoding.Decoder env s) instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Ideas.Utils.Decoding.Decoder env s a) instance GHC.Base.Monoid a => GHC.Base.Monoid (Ideas.Utils.Decoding.Decoder env s a) instance GHC.Base.Functor Ideas.Utils.Decoding.Error instance GHC.Base.Applicative Ideas.Utils.Decoding.Error instance GHC.Base.Alternative Ideas.Utils.Decoding.Error instance GHC.Base.Monad Ideas.Utils.Decoding.Error instance GHC.Base.MonadPlus Ideas.Utils.Decoding.Error -- | Utility functions for parsing with Parsec library module Ideas.Utils.Parsing -- | Sequential application. -- -- A few functors support an implementation of <*> that is -- more efficient than the default one. (<*>) :: Applicative f => f a -> b -> f a -> f b infixl 4 <*> -- | Sequence actions, discarding the value of the first argument. (*>) :: Applicative f => f a -> f b -> f b infixl 4 *> -- | Sequence actions, discarding the value of the second argument. (<*) :: Applicative f => f a -> f b -> f a infixl 4 <* -- | An infix synonym for fmap. -- -- The name of this operator is an allusion to $. Note the -- similarities between their types: -- --
--    ($)  ::              (a -> b) ->   a ->   b
--   (<$>) :: Functor f => (a -> b) -> f a -> f b
--   
-- -- Whereas $ is function application, <$> is -- function application lifted over a Functor. -- --

Examples

-- -- Convert from a Maybe Int to a -- Maybe String using show: -- --
--   >>> show <$> Nothing
--   Nothing
--   
--   >>> show <$> Just 3
--   Just "3"
--   
-- -- Convert from an Either Int Int to -- an Either Int String using -- show: -- --
--   >>> show <$> Left 17
--   Left 17
--   
--   >>> show <$> Right 17
--   Right "17"
--   
-- -- Double each element of a list: -- --
--   >>> (*2) <$> [1,2,3]
--   [2,4,6]
--   
-- -- Apply even to the second element of a pair: -- --
--   >>> even <$> (2,2)
--   (2,True)
--   
(<$>) :: Functor f => a -> b -> f a -> f b infixl 4 <$> -- | Replace all locations in the input with the same value. The default -- definition is fmap . const, but this may be -- overridden with a more efficient version. (<$) :: Functor f => a -> f b -> f a infixl 4 <$ -- | A variant of <*> with the arguments reversed. (<**>) :: Applicative f => f a -> f a -> b -> f b infixl 4 <**> parseSimple :: Parser a -> String -> Either String a complete :: Parser a -> Parser a skip :: Parser a -> Parser () (<..>) :: Char -> Char -> Parser Char infix 6 <..> ranges :: [(Char, Char)] -> Parser Char stopOn :: [String] -> Parser String naturalOrFloat :: Parser (Either Integer Double) float :: Parser Double data UnbalancedError NotClosed :: SourcePos -> Char -> UnbalancedError NotOpened :: SourcePos -> Char -> UnbalancedError balanced :: [(Char, Char)] -> String -> Maybe UnbalancedError instance GHC.Show.Show Ideas.Utils.Parsing.UnbalancedError -- | A parser for XML documents, directly derived from the specification: -- -- http://www.w3.org/TR/2006/REC-xml-20060816 module Ideas.Text.XML.Parser document :: Parser XMLDoc extParsedEnt :: Parser (Maybe TextDecl, Content) extSubset :: Parser (Maybe TextDecl, [DocTypeDecl]) -- | Collection of common operation on XML documents module Ideas.Text.XML data XML type Name = String type Attributes = [Attribute] data Attribute (:=) :: Name -> String -> Attribute parseXML :: String -> Either String XML parseXMLFile :: FilePath -> IO XML class (Semigroup a, Monoid a) => BuildXML a (.=.) :: BuildXML a => String -> String -> a string :: BuildXML a => String -> a builder :: BuildXML a => XML -> a tag :: BuildXML a => String -> a -> a char :: BuildXML a => Char -> a text :: (BuildXML a, Show s) => s -> a element :: BuildXML a => String -> [a] -> a emptyTag :: BuildXML a => String -> a data XMLBuilder makeXML :: String -> XMLBuilder -> XML prettyXML :: XML -> String compactXML :: XML -> String name :: XML -> Name attributes :: XML -> Attributes findAttribute :: Monad m => String -> XML -> m String children :: XML -> [XML] findChildren :: String -> XML -> [XML] findChild :: Monad m => String -> XML -> m XML getData :: XML -> String expecting :: Monad m => String -> XML -> m () decodeData :: Decoder env XML String decodeAttribute :: String -> Decoder env XML String decodeChild :: Name -> Decoder env XML a -> Decoder env XML a decodeFirstChild :: Name -> Decoder env XML a -> Decoder env XML a class ToXML a toXML :: ToXML a => a -> XML listToXML :: ToXML a => [a] -> XML builderXML :: (ToXML a, BuildXML b) => a -> b class ToXML a => InXML a fromXML :: (InXML a, Monad m) => XML -> m a listFromXML :: (InXML a, Monad m) => XML -> m [a] foldXML :: (Name -> [a] -> [Either s e] -> e) -> (Attribute -> a) -> (String -> s) -> XML -> e trimXML :: XML -> XML content :: XML -> [Either String XML] emptyContent :: XML -> Bool fromBuilder :: XMLBuilder -> Maybe XML instance GHC.Classes.Eq Ideas.Text.XML.XML instance GHC.Classes.Eq Ideas.Text.XML.Attribute instance Ideas.Text.XML.ToXML () instance Ideas.Text.XML.ToXML a => Ideas.Text.XML.ToXML (GHC.Base.Maybe a) instance GHC.Base.Semigroup Ideas.Text.XML.XMLBuilder instance GHC.Base.Monoid Ideas.Text.XML.XMLBuilder instance Ideas.Text.XML.BuildXML Ideas.Text.XML.XMLBuilder instance Data.String.IsString Ideas.Text.XML.XMLBuilder instance Ideas.Text.XML.BuildXML a => Ideas.Text.XML.BuildXML (Ideas.Utils.Decoding.Decoder env s a) instance GHC.Show.Show Ideas.Text.XML.XML module Ideas.Text.OpenMath.Object data OMOBJ OMI :: Integer -> OMOBJ OMF :: Double -> OMOBJ OMV :: String -> OMOBJ OMS :: Symbol -> OMOBJ OMA :: [OMOBJ] -> OMOBJ OMBIND :: OMOBJ -> [String] -> OMOBJ -> OMOBJ getOMVs :: OMOBJ -> [String] xml2omobj :: XML -> Either String OMOBJ omobj2xml :: OMOBJ -> XML instance GHC.Classes.Eq Ideas.Text.OpenMath.Object.OMOBJ instance GHC.Show.Show Ideas.Text.OpenMath.Object.OMOBJ instance Ideas.Text.XML.ToXML Ideas.Text.OpenMath.Object.OMOBJ instance Ideas.Text.XML.InXML Ideas.Text.OpenMath.Object.OMOBJ instance Data.Generics.Uniplate.Operations.Uniplate Ideas.Text.OpenMath.Object.OMOBJ module Ideas.Text.OpenMath.Tests propEncoding :: Property -- | Formal mathematical properties (FMP) module Ideas.Text.OpenMath.FMP data FMP FMP :: Symbol -> [String] -> OMOBJ -> Symbol -> OMOBJ -> FMP [quantor] :: FMP -> Symbol [metaVariables] :: FMP -> [String] [leftHandSide] :: FMP -> OMOBJ [relation] :: FMP -> Symbol [rightHandSide] :: FMP -> OMOBJ toObject :: FMP -> OMOBJ eqFMP :: OMOBJ -> OMOBJ -> FMP -- | Represents a common misconception. In certain (most) situations, the -- two objects are not the same. buggyFMP :: OMOBJ -> OMOBJ -> FMP -- | A minimal interface for constructing simple HTML pages See -- http://www.w3.org/TR/html4/ module Ideas.Text.HTML class ToHTML a toHTML :: ToHTML a => a -> HTMLBuilder listToHTML :: ToHTML a => [a] -> HTMLBuilder data HTMLPage type HTMLBuilder = XMLBuilder addCSS :: FilePath -> HTMLPage -> HTMLPage addScript :: FilePath -> HTMLPage -> HTMLPage addStyle :: String -> HTMLPage -> HTMLPage showHTML :: HTMLPage -> String string :: BuildXML a => String -> a text :: (BuildXML a, Show s) => s -> a htmlPage :: String -> HTMLBuilder -> HTMLPage link :: BuildXML a => String -> a -> a h1 :: BuildXML a => String -> a h2 :: BuildXML a => String -> a h3 :: BuildXML a => String -> a h4 :: BuildXML a => String -> a h5 :: BuildXML a => String -> a h6 :: BuildXML a => String -> a preText :: BuildXML a => String -> a ul :: BuildXML a => [a] -> a -- | First argument indicates whether the table has a header or not table :: BuildXML a => Bool -> [[a]] -> a keyValueTable :: BuildXML a => [(String, a)] -> a image :: BuildXML a => String -> a space :: BuildXML a => a spaces :: BuildXML a => Int -> a (<#>) :: BuildXML a => a -> a -> a spaced :: BuildXML a => [a] -> a highlightXML :: Bool -> XML -> HTMLBuilder para :: BuildXML a => a -> a ttText :: BuildXML a => String -> a hr :: BuildXML a => a br :: BuildXML a => a pre :: BuildXML a => a -> a bullet :: BuildXML a => a divClass :: BuildXML a => String -> a -> a spanClass :: BuildXML a => String -> a -> a idA :: BuildXML a => String -> a classA :: BuildXML a => String -> a styleA :: BuildXML a => String -> a titleA :: BuildXML a => String -> a -- | Renders as teletype or monospaced Ideas.Text. tt :: BuildXML a => a -> a -- | Renders as italic text style. italic :: BuildXML a => a -> a -- | Renders as bold text style. bold :: BuildXML a => a -> a big :: BuildXML a => a -> a small :: BuildXML a => a -> a instance Ideas.Text.XML.ToXML Ideas.Text.HTML.HTMLPage instance Ideas.Text.HTML.ToHTML a => Ideas.Text.HTML.ToHTML [a] instance (Ideas.Text.HTML.ToHTML a, Ideas.Text.HTML.ToHTML b) => Ideas.Text.HTML.ToHTML (Data.Either.Either a b) instance Ideas.Text.HTML.ToHTML a => Ideas.Text.HTML.ToHTML (GHC.Base.Maybe a) instance Ideas.Text.HTML.ToHTML () instance (Ideas.Text.HTML.ToHTML a, Ideas.Text.HTML.ToHTML b) => Ideas.Text.HTML.ToHTML (a, b) instance (Ideas.Text.HTML.ToHTML a, Ideas.Text.HTML.ToHTML b, Ideas.Text.HTML.ToHTML c) => Ideas.Text.HTML.ToHTML (a, b, c) instance (Ideas.Text.HTML.ToHTML a, Ideas.Text.HTML.ToHTML b) => Ideas.Text.HTML.ToHTML (Data.Map.Internal.Map a b) instance Ideas.Text.HTML.ToHTML GHC.Types.Int instance Ideas.Text.HTML.ToHTML GHC.Types.Bool instance Ideas.Text.HTML.ToHTML GHC.Types.Char -- | A minimal interface for using W3.CSS, a modern CSS framework with -- built-in responsiveness. See https://www.w3schools.com/w3css/ module Ideas.Text.HTML.W3CSS w3css :: HTMLPage -> HTMLPage w3class :: BuildXML a => String -> a -> a w3classIf :: BuildXML a => Bool -> String -> a -> a data Color Red :: Color Pink :: Color Purple :: Color DeepPurple :: Color Indigo :: Color Blue :: Color LightBlue :: Color Cyan :: Color Aqua :: Color Teal :: Color Green :: Color LightGreen :: Color Lime :: Color Sand :: Color Khaki :: Color Yellow :: Color Amber :: Color Orange :: Color DeepOrange :: Color BlueGray :: Color Brown :: Color LightGray :: Color Gray :: Color DarkGray :: Color Black :: Color PaleRed :: Color PaleYellow :: Color PaleGreen :: Color PaleBlue :: Color White :: Color data Size Tiny :: Size Small :: Size Medium :: Size Large :: Size XL :: Size XXL :: Size XXXL :: Size Jumbo :: Size data Position TopLeft :: Position Top :: Position TopRight :: Position CenterLeft :: Position Center :: Position CenterRight :: Position BottomLeft :: Position Bottom :: Position BottomRight :: Position onTop :: Position -> Bool onLeft :: Position -> Bool onRight :: Position -> Bool onBottom :: Position -> Bool uncamel :: String -> String -- | HTML container with 16px left and right padding container :: BuildXML a => a -> a -- | HTML container with 16px left and right padding and 16px top and -- bottom margin panel :: BuildXML a => a -> a -- | Circular badge badge :: BuildXML a => a -> a -- | Rectangular tag tag :: BuildXML a => a -> a -- | Unordered list ul :: BuildXML a => [a] -> a -- | Unordered list ulWith :: BuildXML a => (a -> a) -> [a] -> a -- | Code container code :: BuildXML a => a -> a -- | Inline code container (for code snippets) codespan :: BuildXML a => a -> a -- | Container for an HTML table table :: BuildXML a => a -> a -- | All properties set tableAll :: BuildXML a => a -> a -- | Striped table striped :: BuildXML a => a -> a -- | Bordered lines bordered :: BuildXML a => a -> a -- | Centered table centered :: BuildXML a => a -> a -- | Hoverable table hoverable :: BuildXML a => a -> a -- | Creates a responsive table responsive :: BuildXML a => a -> a -- | Same as w3-card-2 card :: BuildXML a => a -> a -- | Container for any HTML content (2px bordered shadow) card2 :: BuildXML a => a -> a -- | Container for any HTML content (4px bordered shadow) card4 :: BuildXML a => a -> a -- | Container for one row of fluid responsive content row :: BuildXML a => a -> a -- | Row where all columns have a default padding rowPadding :: BuildXML a => a -> a -- | Container for fixed size centered content content :: BuildXML a => a -> a -- | Half (1/2) screen column container half :: BuildXML a => a -> a -- | Third (1/3) screen column container third :: BuildXML a => a -> a -- | Two third (2/3) screen column container twothird :: BuildXML a => a -> a -- | Quarter (1/4) screen column container quarter :: BuildXML a => a -> a -- | Three quarters (3/4) screen column container threequarter :: BuildXML a => a -> a -- | Column container for any HTML content col :: BuildXML a => a -> a -- | Occupies the rest of the column width rest :: BuildXML a => a -> a -- | Hide content on small screens (less than 601px) hideSmall :: BuildXML a => a -> a -- | Hide content on medium screens hideMedium :: BuildXML a => a -> a -- | Hide content on large screens (larger than 992px) hideLarge :: BuildXML a => a -> a -- | Responsive image image :: BuildXML a => a -> a -- | Adds mobile-first responsiveness to any element. Displays elements as -- block elements on mobile devices. mobile :: BuildXML a => a -> a -- | Container for layout columns (cells). cellRow :: BuildXML a => a -> a -- | Layout column (cell). cell :: BuildXML a => a -> a -- | Aligns content at the top of a column (cell). cellTop :: BuildXML a => a -> a -- | Aligns content at the vertical middle of a column (cell). cellMiddle :: BuildXML a => a -> a -- | Aligns content at the bottom of a column (cell). cellBottom :: BuildXML a => a -> a -- | Horizontal bar bar :: BuildXML a => a -> a -- | Vertical bar barBlock :: BuildXML a => a -> a -- | Provides common style for bar items barItem :: BuildXML a => a -> a -- | Side bar sidebar :: BuildXML a => a -> a -- | Used together with w3-sidebar to create a fully automatic responsive -- side navigation. For this class to work, the page content must be -- within a "w3-main" class collapse :: BuildXML a => a -> a -- | Container for page content when using the w3-collapse class for -- responsive side navigations mainPage :: BuildXML a => a -> a -- | Clickable dropdown element dropdownClick :: BuildXML a => a -> a -- | Hoverable dropdown element dropdownHover :: BuildXML a => a -> a -- | Rectangular button with grey background color on hover button :: BuildXML a => String -> a -> a -- | Rectangular button with shadows on hover btn :: BuildXML a => String -> a -> a -- | Rectangular button with ripple effect ripple :: BuildXML a => String -> a -> a -- | Input elements input :: BuildXML a => a -> a -- | Checkbox input type check :: BuildXML a => a -> a -- | Radio input type radio :: BuildXML a => a -> a -- | Input select element select :: BuildXML a => a -> a -- | Modal container modal :: BuildXML a => a -> a -- | Modal pop-up element modalContent :: BuildXML a => a -> a -- | Tooltip element tooltip :: BuildXML a => a -> a -- | Tooltip text tooltipText :: BuildXML a => a -> a -- | Animates an element from -300px to 0px animate :: BuildXML a => Position -> a -> a -- | Animates an element's opacity from 0 to 1 animateOpacity :: BuildXML a => a -> a -- | Animates an element from 0 to 100% in size animateZoom :: BuildXML a => a -> a -- | Animates an element's opacity from 0 to 1 and 1 to 0 (fades in AND -- out) animateFading :: BuildXML a => a -> a -- | Spin an icon 360 degrees spin :: BuildXML a => a -> a -- | Animates the width of an input field to 100% animateInput :: BuildXML a => a -> a -- | Specifies a font size: tiny 10px, small 12px, large 18px, xlarge 24px, -- xxlarge 32px, xxxlarge 48px, jumbo 64px fontSize :: BuildXML a => Size -> a -> a -- | Specifies a wider text wide :: BuildXML a => a -> a -- | Changes the font to serif serif :: BuildXML a => a -> a -- | Centered content center :: BuildXML a => a -> a -- | Floats an element to the left (float: left) left :: BuildXML a => a -> a -- | Floats an element to the right (float: right) right :: BuildXML a => a -> a -- | Left aligned text leftAlign :: BuildXML a => a -> a -- | Right aligned text rightAlign :: BuildXML a => a -> a -- | Right and left aligned text justify :: BuildXML a => a -> a -- | Circled content circle :: BuildXML a => a -> a -- | Hidden content (display:none) hide :: BuildXML a => a -> a -- | Alias of w3-show (display:block) showBlock :: BuildXML a => a -> a -- | Show content as inline-block (display:inline-block) showInlineBlock :: BuildXML a => a -> a -- | Fixed content at the top of a page top :: BuildXML a => a -> a -- | Fixed content at the bottom of a page bottom :: BuildXML a => a -> a -- | Container for w3-display-classes (position: relative) display :: BuildXML a => Position -> a -> a -- | Displays content on hover inside the w3-display-container displayHover :: BuildXML a => a -> a -- | Adds opacity/transparency to an element (opacity: 0.6) opacity :: BuildXML a => a -> a -- | Turns off opacity/transparency (opacity: 1) opacityOff :: BuildXML a => a -> a -- | Adds opacity/transparency to an element (opacity: 0.75) opacityMin :: BuildXML a => a -> a -- | Adds opacity/transparency to an element (opacity: 0.25) opacityMax :: BuildXML a => a -> a -- | Adds a grayscale effect to an element (grayscale: 50%) grayscaleMin :: BuildXML a => a -> a -- | Adds a grayscale effect to an element (grayscale: 75%) grayscale :: BuildXML a => a -> a -- | Adds a grayscale effect to an element (grayscale: 100%) grayscaleMax :: BuildXML a => a -> a -- | Adds a sepia effect to an element (sepia: 50%) sepiaMin :: BuildXML a => a -> a -- | Adds a sepia effect to an element (sepia: 75%) sepia :: BuildXML a => a -> a -- | Adds a sepia effect to an element (sepia: 100%) sepiaMax :: BuildXML a => a -> a -- | Creates an overlay effect overlay :: BuildXML a => a -> a -- | Background color background :: BuildXML a => Color -> a -> a -- | Transparent background-color transparent :: BuildXML a => a -> a -- | Hover color hover :: BuildXML a => Color -> a -> a -- | Text color textColor :: BuildXML a => Color -> a -> a -- | Hover text color hoverColor :: BuildXML a => Color -> a -> a -- | Adds transparency to an element on hover (opacity: 0.6) hoverOpacity :: BuildXML a => a -> a -- | Removes transparency from an element on hover (100% opacity) hoverOpacityOff :: BuildXML a => a -> a -- | Adds shadow to an element on hover hoverShadow :: BuildXML a => a -> a -- | Adds a black and white (100% grayscale) effect to an element hoverGrayscale :: BuildXML a => a -> a -- | Adds a sepia effect to an element on hover hoverSepia :: BuildXML a => a -> a -- | Removes hover effects from an element hoverNone :: BuildXML a => a -> a -- | Element rounded (border-radius): small 2px, medium 4px, large 8px, -- xlarge 16px, xxlarge 32px rounded :: BuildXML a => Size -> a -> a -- | Small: Padding 4px top and bottom, and 8px left and right, Medium: -- Padding 8px top and bottom, and 16px left and right, Large: Padding -- 12px top and bottom, and 24px left and right. padding :: BuildXML a => Size -> a -> a -- | Padding top and bottom: medium 16px, large 24px, xlarge 32px, xxlarge -- 48px, xxxlarge 64px vpadding :: BuildXML a => Size -> a -> a -- | Adds an 16px margin to an element margin :: BuildXML a => a -> a marginPos :: BuildXML a => Position -> a -> a -- | Adds an 16px top and bottom margin to an element section :: BuildXML a => a -> a -- | Borders (top, right, bottom, left) border :: BuildXML a => a -> a borderPos :: BuildXML a => Position -> a -> a -- | Removes all borders noBorder :: BuildXML a => a -> a -- | Border color borderColor :: BuildXML a => Color -> a -> a -- | Adds a thick border (bar) to an element barPos :: BuildXML a => Position -> a -> a data ColorTheme L1 :: ColorTheme L2 :: ColorTheme L3 :: ColorTheme L4 :: ColorTheme L5 :: ColorTheme D1 :: ColorTheme D2 :: ColorTheme D3 :: ColorTheme D4 :: ColorTheme D5 :: ColorTheme theme_ :: BuildXML a => a -> a textTheme :: BuildXML a => a -> a borderTheme :: BuildXML a => a -> a theme :: BuildXML a => ColorTheme -> a -> a instance GHC.Show.Show Ideas.Text.HTML.W3CSS.ColorTheme instance GHC.Classes.Eq Ideas.Text.HTML.W3CSS.Position instance GHC.Show.Show Ideas.Text.HTML.W3CSS.Position instance GHC.Classes.Ord Ideas.Text.HTML.W3CSS.Size instance GHC.Classes.Eq Ideas.Text.HTML.W3CSS.Size instance GHC.Show.Show Ideas.Text.HTML.W3CSS.Color instance GHC.Show.Show Ideas.Text.HTML.W3CSS.Size -- | W3CSS templates for html pages module Ideas.Text.HTML.Templates webpage :: WebPage -> HTMLPage data WebPage WebPage :: String -> [Button] -> Style -> Style -> Int -> HTMLBuilder -> [Button] -> Style -> Style -> HTMLBuilder -> HTMLBuilder -> Style -> WebPage [title] :: WebPage -> String [menuButtons] :: WebPage -> [Button] [menuStyle] :: WebPage -> Style [iconBarsStyle] :: WebPage -> Style [sideWidth] :: WebPage -> Int [sideHeader] :: WebPage -> HTMLBuilder [sideButtons] :: WebPage -> [Button] [sideStyle] :: WebPage -> Style [iconCloseStyle] :: WebPage -> Style [content] :: WebPage -> HTMLBuilder [footer] :: WebPage -> HTMLBuilder [footerStyle] :: WebPage -> Style data Button Button :: String -> HTMLBuilder -> HTMLBuilder -> HTMLBuilder -> Button [buttonUrl] :: Button -> String [buttonStyle] :: Button -> HTMLBuilder -> HTMLBuilder [buttonText] :: Button -> HTMLBuilder type Style = HTMLBuilder -> HTMLBuilder fontAwesome :: BuildXML a => String -> a -- | Support for JavaScript Object Notation (JSON) and remote procedure -- calls using JSON. JSON is a lightweight alternative for XML. module Ideas.Text.JSON data JSON Number :: Number -> JSON String :: String -> JSON Boolean :: Bool -> JSON Array :: [JSON] -> JSON Object :: [(Key, JSON)] -> JSON Null :: JSON type Key = String data Number I :: Integer -> Number D :: Double -> Number class InJSON a toJSON :: InJSON a => a -> JSON listToJSON :: InJSON a => [a] -> JSON fromJSON :: (InJSON a, Monad m) => JSON -> m a listFromJSON :: (InJSON a, Monad m) => JSON -> m [a] lookupM :: Monad m => String -> JSON -> m JSON parseJSON :: String -> Either String JSON compactJSON :: JSON -> String jsonRPC :: JSON -> RPCHandler -> IO RPCResponse type RPCHandler = String -> JSON -> IO JSON data RPCResponse Response :: JSON -> JSON -> JSON -> RPCResponse [responseResult] :: RPCResponse -> JSON [responseError] :: RPCResponse -> JSON [responseId] :: RPCResponse -> JSON propEncoding :: Property instance GHC.Classes.Eq Ideas.Text.JSON.JSON instance GHC.Classes.Eq Ideas.Text.JSON.Number instance GHC.Show.Show Ideas.Text.JSON.RPCResponse instance Ideas.Text.JSON.InJSON Ideas.Text.JSON.RPCResponse instance GHC.Show.Show Ideas.Text.JSON.RPCRequest instance Ideas.Text.JSON.InJSON Ideas.Text.JSON.RPCRequest instance Ideas.Text.JSON.InJSON GHC.Types.Int instance Ideas.Text.JSON.InJSON GHC.Integer.Type.Integer instance Ideas.Text.JSON.InJSON GHC.Types.Double instance Ideas.Text.JSON.InJSON GHC.Types.Char instance Ideas.Text.JSON.InJSON GHC.Types.Bool instance Ideas.Text.JSON.InJSON a => Ideas.Text.JSON.InJSON [a] instance (Ideas.Text.JSON.InJSON a, Ideas.Text.JSON.InJSON b) => Ideas.Text.JSON.InJSON (a, b) instance (Ideas.Text.JSON.InJSON a, Ideas.Text.JSON.InJSON b, Ideas.Text.JSON.InJSON c) => Ideas.Text.JSON.InJSON (a, b, c) instance (Ideas.Text.JSON.InJSON a, Ideas.Text.JSON.InJSON b, Ideas.Text.JSON.InJSON c, Ideas.Text.JSON.InJSON d) => Ideas.Text.JSON.InJSON (a, b, c, d) instance GHC.Show.Show Ideas.Text.JSON.JSON instance Test.QuickCheck.Arbitrary.Arbitrary Ideas.Text.JSON.JSON instance GHC.Show.Show Ideas.Text.JSON.Number instance Test.QuickCheck.Arbitrary.Arbitrary Ideas.Text.JSON.Number -- | A collection of general utility functions module Ideas.Utils.Prelude data Some f Some :: (f a) -> Some f newtype ShowString ShowString :: String -> ShowString [fromShowString] :: ShowString -> String readInt :: String -> Maybe Int readM :: (Monad m, Read a) => String -> m a subsets :: [a] -> [[a]] isSubsetOf :: Eq a => [a] -> [a] -> Bool cartesian :: [a] -> [b] -> [(a, b)] distinct :: Eq a => [a] -> Bool allsame :: Eq a => [a] -> Bool fixpoint :: Eq a => (a -> a) -> a -> a splitAtElem :: Eq a => a -> [a] -> Maybe ([a], [a]) splitsWithElem :: Eq a => a -> [a] -> [[a]] timedSeconds :: Int -> IO a -> IO a getDiffTime :: IO a -> IO (a, NominalDiffTime) fst3 :: (a, b, c) -> a snd3 :: (a, b, c) -> b thd3 :: (a, b, c) -> c headM :: Monad m => [a] -> m a findIndexM :: Monad m => (a -> Bool) -> [a] -> m Int elementAt :: Monad m => Int -> [a] -> m a changeAt :: Monad m => Int -> (a -> a) -> [a] -> m [a] replaceAt :: Monad m => Int -> a -> [a] -> m [a] list :: b -> ([a] -> b) -> [a] -> b mwhen :: Monoid a => Bool -> a -> a munless :: Monoid a => Bool -> a -> a instance GHC.Classes.Ord Ideas.Utils.Prelude.ShowString instance GHC.Classes.Eq Ideas.Utils.Prelude.ShowString instance GHC.Show.Show Ideas.Utils.Prelude.ShowString instance GHC.Read.Read Ideas.Utils.Prelude.ShowString -- | Extensions to the QuickCheck library module Ideas.Utils.QuickCheck data ArbGen a generator :: ArbGen a -> Gen a generators :: [ArbGen a] -> Gen a arbGen :: Arbitrary b => (b -> a) -> ArbGen a constGen :: a -> ArbGen a constGens :: [a] -> ArbGen a unaryGen :: (a -> a) -> ArbGen a unaryGens :: [a -> a] -> ArbGen a unaryArbGen :: Arbitrary b => (b -> a -> a) -> ArbGen a binaryGen :: (a -> a -> a) -> ArbGen a binaryGens :: [a -> a -> a] -> ArbGen a toArbGen :: Gen a -> ArbGen a common :: ArbGen a -> ArbGen a uncommon :: ArbGen a -> ArbGen a rare :: ArbGen a -> ArbGen a changeFrequency :: Rational -> ArbGen a -> ArbGen a instance GHC.Base.Semigroup (Ideas.Utils.QuickCheck.ArbGen a) instance GHC.Base.Monoid (Ideas.Utils.QuickCheck.ArbGen a) -- | References to Strings, proving a fast comparison implementation (Eq -- and Ord) that uses a hash function. Code is based on Daan Leijen's -- Lazy Virutal Machine (LVM) identifiers. module Ideas.Utils.StringRef data StringRef stringRef :: String -> StringRef toString :: StringRef -> String tableStatus :: IO String instance GHC.Classes.Ord Ideas.Utils.StringRef.StringRef instance GHC.Classes.Eq Ideas.Utils.StringRef.StringRef -- | Many entities of the Ideas framework carry an Id for -- identification. Identifiers have a hierarchical structure of an -- arbitrary depth (e.g. algebra.equation or a.b.c). -- Valid symbols for identifiers are the alpha-numerical characters, -- together with - and _. Each identifier carries a -- description and a hash value for fast comparison. -- -- Functionality for identifiers is provided by means of three type -- classes: -- -- -- -- The Id datatype implements the Monoid interface. module Ideas.Common.Id -- | Abstract data type for identifiers with a hierarchical name, carrying -- a description. The data type provides a fast comparison -- implementation. data Id -- | Type class IsId for constructing identifiers. Examples are -- newId "algebra.equation", newId ("a", "b", "c"), and -- newId () for the empty identifier. class IsId a newId :: IsId a => a -> Id concatId :: IsId a => [a] -> Id -- | Appends two identifiers. Both parameters are overloaded. (#) :: (IsId a, IsId b) => a -> b -> Id infixr 8 # -- | Type classfor accessing (and changing) the identifier of an entity. class HasId a getId :: HasId a => a -> Id changeId :: HasId a => (Id -> Id) -> a -> a -- | Get the unqualified part of the identifier (i.e., last string). unqualified :: HasId a => a -> String -- | Get the list of qualifiers of the identifier (i.e., everything but the -- last string). qualifiers :: HasId a => a -> [String] -- | Get the qualified part of the identifier. If the identifier consists -- of more than one part, the parts are separated by a period -- (.). qualification :: HasId a => a -> String -- | Give a description for the current entity. If there already is a -- description, both strings are combined. describe :: HasId a => String -> a -> a -- | Get the current description. description :: HasId a => a -> String -- | Show the identifier. showId :: HasId a => a -> String -- | Compare two identifiers based on their names. Use compare for -- a fast ordering based on hash values. compareId :: HasId a => a -> a -> Ordering -- | Type class for labeling entities with an identifier class HasId a => Identify a (@>) :: (Identify a, IsId n) => n -> a -> a instance Ideas.Common.Id.HasId Ideas.Common.Id.Id instance (Ideas.Common.Id.HasId a, Ideas.Common.Id.HasId b) => Ideas.Common.Id.HasId (Data.Either.Either a b) instance Test.QuickCheck.Arbitrary.Arbitrary Ideas.Common.Id.Id instance Ideas.Common.Id.IsId Ideas.Common.Id.Id instance Ideas.Common.Id.IsId GHC.Types.Char instance Ideas.Common.Id.IsId a => Ideas.Common.Id.IsId [a] instance Ideas.Common.Id.IsId () instance (Ideas.Common.Id.IsId a, Ideas.Common.Id.IsId b) => Ideas.Common.Id.IsId (a, b) instance (Ideas.Common.Id.IsId a, Ideas.Common.Id.IsId b, Ideas.Common.Id.IsId c) => Ideas.Common.Id.IsId (a, b, c) instance Ideas.Common.Id.IsId a => Ideas.Common.Id.IsId (GHC.Base.Maybe a) instance (Ideas.Common.Id.IsId a, Ideas.Common.Id.IsId b) => Ideas.Common.Id.IsId (Data.Either.Either a b) instance GHC.Show.Show Ideas.Common.Id.Id instance GHC.Read.Read Ideas.Common.Id.Id instance GHC.Classes.Eq Ideas.Common.Id.Id instance GHC.Classes.Ord Ideas.Common.Id.Id instance GHC.Base.Semigroup Ideas.Common.Id.Id instance GHC.Base.Monoid Ideas.Common.Id.Id instance Ideas.Text.HTML.ToHTML Ideas.Common.Id.Id -- | This module defines views on data-types, as described in "Canonical -- Forms in Interactive Exercise Assistants" module Ideas.Common.View -- | The basic arrow class. -- -- Instances should satisfy the following laws: -- -- -- -- where -- --
--   assoc ((a,b),c) = (a,(b,c))
--   
-- -- The other combinators have sensible default definitions, which may be -- overridden for efficiency. class Category a => Arrow (a :: * -> * -> *) -- | Lift a function to an arrow. arr :: Arrow a => b -> c -> a b c -- | Send the first component of the input through the argument arrow, and -- copy the rest unchanged to the output. first :: Arrow a => a b c -> a (b, d) (c, d) -- | A mirror image of first. -- -- The default definition may be overridden with a more efficient version -- if desired. second :: Arrow a => a b c -> a (d, b) (d, c) -- | Split the input between the two argument arrows and combine their -- output. Note that this is in general not a functor. -- -- The default definition may be overridden with a more efficient version -- if desired. (***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c') -- | Fanout: send the input to both argument arrows and combine their -- output. -- -- The default definition may be overridden with a more efficient version -- if desired. (&&&) :: Arrow a => a b c -> a b c' -> a b (c, c') -- | Choice, for arrows that support it. This class underlies the -- if and case constructs in arrow notation. -- -- Instances should satisfy the following laws: -- -- -- -- where -- --
--   assocsum (Left (Left x)) = Left x
--   assocsum (Left (Right y)) = Right (Left y)
--   assocsum (Right z) = Right (Right z)
--   
-- -- The other combinators have sensible default definitions, which may be -- overridden for efficiency. class Arrow a => ArrowChoice (a :: * -> * -> *) -- | Feed marked inputs through the argument arrow, passing the rest -- through unchanged to the output. left :: ArrowChoice a => a b c -> a Either b d Either c d -- | A mirror image of left. -- -- The default definition may be overridden with a more efficient version -- if desired. right :: ArrowChoice a => a b c -> a Either d b Either d c -- | Split the input between the two argument arrows, retagging and merging -- their outputs. Note that this is in general not a functor. -- -- The default definition may be overridden with a more efficient version -- if desired. (+++) :: ArrowChoice a => a b c -> a b' c' -> a Either b b' Either c c' -- | Fanin: Split the input between the two argument arrows and merge their -- outputs. -- -- The default definition may be overridden with a more efficient version -- if desired. (|||) :: ArrowChoice a => a b d -> a c d -> a Either b c d class Arrow a => ArrowZero (a :: * -> * -> *) zeroArrow :: ArrowZero a => a b c -- | A monoid on arrows. class ArrowZero a => ArrowPlus (a :: * -> * -> *) -- | An associative operation with identity zeroArrow. (<+>) :: ArrowPlus a => a b c -> a b c -> a b c -- | Left-to-right composition (>>>) :: Category cat => cat a b -> cat b c -> cat a c infixr 1 >>> -- | Right-to-left composition (<<<) :: Category cat => cat b c -> cat a b -> cat a c infixr 1 <<< class IsMatcher f match :: IsMatcher f => f a b -> a -> Maybe b matcher :: IsMatcher f => f a b -> Matcher a b -- | generalized monadic variant of match matchM :: (Monad m, IsMatcher f) => f a b -> a -> m b belongsTo :: IsMatcher f => a -> f a b -> Bool viewEquivalent :: (IsMatcher f, Eq b) => f a b -> a -> a -> Bool viewEquivalentWith :: IsMatcher f => (b -> b -> Bool) -> f a b -> a -> a -> Bool data Matcher a b makeMatcher :: (a -> Maybe b) -> Matcher a b -- | Minimal complete definition: toView or both match -- and build. class IsMatcher f => IsView f build :: IsView f => f a b -> b -> a toView :: IsView f => f a b -> View a b simplify :: IsView f => f a b -> a -> a simplifyWith :: IsView f => (b -> b) -> f a b -> a -> a simplifyWithM :: IsView f => (b -> Maybe b) -> f a b -> a -> a canonical :: IsView f => f a b -> a -> Maybe a canonicalWith :: IsView f => (b -> b) -> f a b -> a -> Maybe a canonicalWithM :: IsView f => (b -> Maybe b) -> f a b -> a -> Maybe a isCanonical :: (IsView f, Eq a) => f a b -> a -> Bool isCanonicalWith :: IsView f => (a -> a -> Bool) -> f a b -> a -> Bool data View a b identity :: Category f => f a a makeView :: (a -> Maybe b) -> (b -> a) -> View a b matcherView :: Matcher a b -> (b -> a) -> View a b data Isomorphism a b from :: Isomorphism a b -> a -> b to :: Isomorphism a b -> b -> a inverse :: Isomorphism a b -> Isomorphism b a class LiftView f liftView :: LiftView f => View a b -> f b -> f a liftViewIn :: LiftView f => View a (b, c) -> f b -> f a swapView :: Isomorphism (a, b) (b, a) -- | Specialized version of traverseView listView :: View a b -> View [a] [b] traverseView :: Traversable f => View a b -> View (f a) (f b) ($<) :: Traversable f => View a (f b) -> View b c -> View a (f c) data ViewPackage [ViewPackage] :: (Show a, Show b, Eq a) => (String -> Maybe a) -> View a b -> ViewPackage propIdempotence :: (Show a, Eq a) => Gen a -> View a b -> Property propSoundness :: Show a => (a -> a -> Bool) -> Gen a -> View a c -> Property propNormalForm :: (Show a, Eq a) => Gen a -> View a b -> Property instance Control.Arrow.ArrowChoice Ideas.Common.View.Matcher instance Control.Arrow.ArrowPlus Ideas.Common.View.Matcher instance Control.Arrow.ArrowZero Ideas.Common.View.Matcher instance Control.Arrow.Arrow Ideas.Common.View.Matcher instance Control.Category.Category Ideas.Common.View.Matcher instance Ideas.Common.Id.HasId Ideas.Common.View.ViewPackage instance Control.Category.Category Ideas.Common.View.Isomorphism instance Control.Arrow.Arrow Ideas.Common.View.Isomorphism instance Ideas.Common.Classes.BiArrow Ideas.Common.View.Isomorphism instance Control.Arrow.ArrowChoice Ideas.Common.View.Isomorphism instance Ideas.Common.View.IsMatcher Ideas.Common.View.Isomorphism instance Ideas.Common.View.IsView Ideas.Common.View.Isomorphism instance Ideas.Common.Id.HasId (Ideas.Common.View.Isomorphism a b) instance Ideas.Common.Id.Identify (Ideas.Common.View.Isomorphism a b) instance Ideas.Common.View.IsView Ideas.Common.View.View instance Control.Category.Category Ideas.Common.View.View instance Control.Arrow.Arrow Ideas.Common.View.View instance Ideas.Common.Classes.BiArrow Ideas.Common.View.View instance Control.Arrow.ArrowChoice Ideas.Common.View.View instance Ideas.Common.View.IsMatcher Ideas.Common.View.View instance Ideas.Common.Id.HasId (Ideas.Common.View.View a b) instance Ideas.Common.Id.Identify (Ideas.Common.View.View a b) instance Ideas.Common.View.IsMatcher Ideas.Common.View.Matcher module Ideas.Common.Strategy.CyclicTree data CyclicTree a b node :: a -> [CyclicTree a b] -> CyclicTree a b node0 :: a -> CyclicTree a b node1 :: a -> CyclicTree a b -> CyclicTree a b node2 :: a -> CyclicTree a b -> CyclicTree a b -> CyclicTree a b leaf :: b -> CyclicTree a b label :: IsId n => n -> CyclicTree a b -> CyclicTree a b isNode :: CyclicTree a b -> Maybe (a, [CyclicTree a b]) isLeaf :: CyclicTree a b -> Maybe b isLabel :: CyclicTree a b -> Maybe (Id, CyclicTree a b) replaceNode :: (a -> [CyclicTree a b] -> CyclicTree a b) -> CyclicTree a b -> CyclicTree a b replaceLeaf :: (b -> CyclicTree a c) -> CyclicTree a b -> CyclicTree a c replaceLabel :: (Id -> CyclicTree a b -> CyclicTree a b) -> CyclicTree a b -> CyclicTree a b shrinkTree :: CyclicTree a b -> [CyclicTree a b] fold :: CyclicTreeAlg a b t -> CyclicTree a b -> t foldUnwind :: CyclicTreeAlg a b t -> CyclicTree a b -> t data CyclicTreeAlg a b t fNode :: CyclicTreeAlg a b t -> a -> [t] -> t fLeaf :: CyclicTreeAlg a b t -> b -> t fLabel :: CyclicTreeAlg a b t -> Id -> t -> t fRec :: CyclicTreeAlg a b t -> Int -> t -> t fVar :: CyclicTreeAlg a b t -> Int -> t emptyAlg :: CyclicTreeAlg a b t monoidAlg :: Monoid m => CyclicTreeAlg a b m instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Ideas.Common.Strategy.CyclicTree.CyclicTree a b) instance Ideas.Common.Classes.BiFunctor Ideas.Common.Strategy.CyclicTree.CyclicTree instance GHC.Base.Applicative (Ideas.Common.Strategy.CyclicTree.CyclicTree d) instance Data.Foldable.Foldable (Ideas.Common.Strategy.CyclicTree.CyclicTree d) instance Data.Traversable.Traversable (Ideas.Common.Strategy.CyclicTree.CyclicTree d) instance GHC.Base.Functor (Ideas.Common.Strategy.CyclicTree.CyclicTree d) instance GHC.Base.Monad (Ideas.Common.Strategy.CyclicTree.CyclicTree d) instance Ideas.Common.Classes.Fix (Ideas.Common.Strategy.CyclicTree.CyclicTree a b) instance (Test.QuickCheck.Arbitrary.Arbitrary a, Test.QuickCheck.Arbitrary.Arbitrary b) => Test.QuickCheck.Arbitrary.Arbitrary (Ideas.Common.Strategy.CyclicTree.CyclicTree a b) -- | Representation for predicates module Ideas.Common.Predicate data Predicate a predicate :: (a -> Bool) -> Predicate a predicateView :: View a b -> Predicate a evalPredicate :: Predicate a -> a -> Bool class BoolValue a true :: BoolValue a => a false :: BoolValue a => a fromBool :: BoolValue a => Bool -> a isTrue :: BoolValue a => a -> Bool isFalse :: BoolValue a => a -> Bool class BoolValue a => Boolean a (<&&>) :: Boolean a => a -> a -> a (<||>) :: Boolean a => a -> a -> a complement :: Boolean a => a -> a ands :: Boolean a => [a] -> a ors :: Boolean a => [a] -> a implies :: Boolean a => a -> a -> a equivalent :: Boolean a => a -> a -> a instance Ideas.Common.Classes.BoolValue (Ideas.Common.Predicate.Predicate a) instance Ideas.Common.Classes.Boolean (Ideas.Common.Predicate.Predicate a) instance Ideas.Common.Id.HasId (Ideas.Common.Predicate.Predicate a) instance Ideas.Common.Id.Identify (Ideas.Common.Predicate.Predicate a) -- | module Ideas.Common.Examples data Examples a -- | One example example :: a -> Examples a -- | List of examples exampleList :: [a] -> Examples a -- | List of examples with the same difficulty examplesFor :: Difficulty -> [a] -> Examples a -- | List of examples with their own difficulty examplesWithDifficulty :: [(Difficulty, a)] -> Examples a -- | Use a random generator (from QuickCheck) as example generator random :: Gen a -> Examples a group :: Id -> Examples a -> Examples a -- | Turn examples (and random generators) into tests (and test generators) forTesting :: Examples a -> Examples a -- | Assign difficulty (to all items without a difficulty level) difficulty :: Difficulty -> Examples a -> Examples a veryEasy :: Examples a -> Examples a easy :: Examples a -> Examples a medium :: Examples a -> Examples a difficult :: Examples a -> Examples a veryDifficult :: Examples a -> Examples a -- | Tests if there ar no examples isEmpty :: Examples a -> Bool -- | Number of examples, including those in subgroups size :: Examples a -> Int -- | Flatten examples into one collection without subgroups flatten :: Examples a -> Examples a -- | Top-level groups groups :: Examples a -> [(Id, Examples a)] -- | Top-level examples topLevelExamples :: Examples a -> [(Maybe Difficulty, a)] -- | Top-level random generators topLevelRandoms :: Examples a -> [(Maybe Difficulty, Gen a)] -- | Top-level test cases topLevelTests :: Examples a -> [a] -- | Top-level test generators topLevelRandomTests :: Examples a -> [Gen a] -- | All examples (also in groups) allExamples :: Examples a -> [(Maybe Difficulty, a)] -- | All random generators (also in groups) allRandoms :: Examples a -> [(Maybe Difficulty, Gen a)] -- | All test cases (also in groups) allTests :: Examples a -> [a] -- | All test generators (also in groups) allRandomTests :: Examples a -> [Gen a] data Difficulty VeryEasy :: Difficulty Easy :: Difficulty Medium :: Difficulty Difficult :: Difficulty VeryDifficult :: Difficulty -- | Parser for difficulty levels, which ignores non-alpha charactes -- (including spaces) and upper/lower case distinction. readDifficulty :: String -> Maybe Difficulty instance GHC.Enum.Enum Ideas.Common.Examples.Difficulty instance GHC.Classes.Ord Ideas.Common.Examples.Difficulty instance GHC.Classes.Eq Ideas.Common.Examples.Difficulty instance GHC.Base.Semigroup (Ideas.Common.Examples.Examples a) instance GHC.Base.Monoid (Ideas.Common.Examples.Examples a) instance GHC.Base.Functor Ideas.Common.Examples.Examples instance GHC.Base.Functor Ideas.Common.Examples.Item instance GHC.Show.Show Ideas.Common.Examples.Difficulty instance GHC.Read.Read Ideas.Common.Examples.Difficulty -- | Constraints for constraint-based tutors module Ideas.Common.Constraint data Constraint a makeConstraint :: IsId n => n -> (a -> Result ()) -> Constraint a isRelevant :: Constraint a -> a -> Bool -- | Satisfaction condition isSatisfied :: Constraint a -> a -> Bool -- | Satisfaction condition isViolated :: Constraint a -> a -> Maybe String getResult :: Constraint a -> a -> Result () data Result a Irrelevant :: Result a Error :: String -> Result a Ok :: a -> Result a -- | Turn errors into irrelevant results relevance :: Result a -> Result a instance GHC.Show.Show a => GHC.Show.Show (Ideas.Common.Constraint.Result a) instance GHC.Show.Show (Ideas.Common.Constraint.Constraint a) instance GHC.Classes.Eq (Ideas.Common.Constraint.Constraint a) instance GHC.Classes.Ord (Ideas.Common.Constraint.Constraint a) instance Ideas.Common.Id.HasId (Ideas.Common.Constraint.Constraint a) instance Ideas.Common.View.LiftView Ideas.Common.Constraint.Constraint instance GHC.Base.Functor Ideas.Common.Constraint.Result instance GHC.Base.Applicative Ideas.Common.Constraint.Result instance GHC.Base.Alternative Ideas.Common.Constraint.Result instance GHC.Base.Monad Ideas.Common.Constraint.Result instance GHC.Base.MonadPlus Ideas.Common.Constraint.Result -- | A lightweight wrapper for organizing tests (including QuickCheck -- tests). It introduces the notion of a test suite, and it stores the -- test results for later inspection (e.g., for the generation of a test -- report). A TestSuite is a monoid. module Ideas.Utils.TestSuite data TestSuite -- | Construct a (named) test suite containing test cases and other suites suite :: String -> [TestSuite] -> TestSuite -- | Turn a QuickCheck property into the test suite. The first argument is -- a label for the property useProperty :: Testable prop => String -> prop -> TestSuite -- | Turn a QuickCheck property into the test suite, also providing a test -- configuration (Args) usePropertyWith :: Testable prop => String -> Args -> prop -> TestSuite assertTrue :: String -> Bool -> TestSuite assertNull :: Show a => String -> [a] -> TestSuite assertEquals :: (Eq a, Show a) => String -> a -> a -> TestSuite assertIO :: String -> IO Bool -> TestSuite assertMessage :: String -> Bool -> String -> TestSuite assertMessageIO :: String -> IO Message -> TestSuite -- | All errors are turned into warnings onlyWarnings :: TestSuite -> TestSuite rateOnError :: Int -> TestSuite -> TestSuite runTestSuite :: Bool -> TestSuite -> IO () runTestSuiteResult :: Bool -> TestSuite -> IO Result data Result subResults :: Result -> [(String, Result)] findSubResult :: String -> Result -> Maybe Result justOneSuite :: Result -> Maybe (String, Result) allMessages :: Result -> [(String, Message)] topMessages :: Result -> [(String, Message)] nrOfTests :: Result -> Int nrOfErrors :: Result -> Int nrOfWarnings :: Result -> Int timeInterval :: Result -> Double makeSummary :: Result -> String printSummary :: Result -> IO () data Message message :: String -> Message warning :: String -> Message messageLines :: Message -> [String] data Status class HasStatus a getStatus :: HasStatus a => a -> Status isError :: HasStatus a => a -> Bool isWarning :: HasStatus a => a -> Bool isOk :: HasStatus a => a -> Bool data Rating class HasRating a rating :: HasRating a => a -> Maybe Int rate :: HasRating a => Int -> a -> a instance GHC.Classes.Eq Ideas.Utils.TestSuite.Message instance GHC.Classes.Ord Ideas.Utils.TestSuite.Rating instance GHC.Classes.Eq Ideas.Utils.TestSuite.Rating instance GHC.Classes.Ord Ideas.Utils.TestSuite.Status instance GHC.Classes.Eq Ideas.Utils.TestSuite.Status instance Ideas.Utils.TestSuite.HasRating Ideas.Utils.TestSuite.Result instance Ideas.Utils.TestSuite.HasRating Ideas.Utils.TestSuite.Message instance Ideas.Utils.TestSuite.HasRating Ideas.Utils.TestSuite.Rating instance GHC.Show.Show Ideas.Utils.TestSuite.Result instance GHC.Base.Semigroup Ideas.Utils.TestSuite.Result instance GHC.Base.Monoid Ideas.Utils.TestSuite.Result instance Ideas.Utils.TestSuite.HasStatus Ideas.Utils.TestSuite.Result instance GHC.Base.Semigroup Ideas.Utils.TestSuite.TestSuite instance GHC.Base.Monoid Ideas.Utils.TestSuite.TestSuite instance GHC.Show.Show Ideas.Utils.TestSuite.Message instance GHC.Base.Semigroup Ideas.Utils.TestSuite.Message instance GHC.Base.Monoid Ideas.Utils.TestSuite.Message instance Ideas.Utils.TestSuite.HasStatus Ideas.Utils.TestSuite.Message instance GHC.Base.Semigroup Ideas.Utils.TestSuite.Rating instance GHC.Base.Monoid Ideas.Utils.TestSuite.Rating instance GHC.Base.Semigroup Ideas.Utils.TestSuite.Status instance GHC.Base.Monoid Ideas.Utils.TestSuite.Status module Ideas.Utils.BlackBoxTests blackBoxTests :: TestRunner -> [String] -> String -> IO TestSuite type TestRunner = String -> IO String -- | Typeable type class, with the IsTypeable data type for witnessing -- instances module Ideas.Utils.Typeable data IsTypeable a typeable :: forall a. Typeable a => IsTypeable a class HasTypeable f getTypeable :: HasTypeable f => f a -> Maybe (IsTypeable a) castFrom :: (HasTypeable f, Typeable b) => f a -> a -> Maybe b castTo :: (HasTypeable f, Typeable a) => f b -> a -> Maybe b castBetween :: (HasTypeable f, HasTypeable g) => f a -> g b -> a -> Maybe b gcastFrom :: (HasTypeable f, Typeable b) => f a -> c a -> Maybe (c b) gcastTo :: (HasTypeable f, Typeable a) => f b -> c a -> Maybe (c b) gcastBetween :: (HasTypeable f, HasTypeable g) => f a -> g b -> c a -> Maybe (c b) instance Ideas.Utils.Typeable.HasTypeable Ideas.Utils.Typeable.IsTypeable -- | Exports a subset of Data.Generics.Uniplate.Direct (the -- Uniplate type class and its utility plus constructor -- functions) module Ideas.Utils.Uniplate class Uniplate on children :: Uniplate on => on -> [on] contexts :: Uniplate on => on -> [(on, on -> on)] descend :: Uniplate on => on -> on -> on -> on descendM :: (Uniplate on, Monad m) => on -> m on -> on -> m on holes :: Uniplate on => on -> [(on, on -> on)] para :: Uniplate on => on -> [r] -> r -> on -> r rewrite :: Uniplate on => on -> Maybe on -> on -> on rewriteM :: (Monad m, Uniplate on) => on -> m Maybe on -> on -> m on transform :: Uniplate on => on -> on -> on -> on transformM :: (Monad m, Uniplate on) => on -> m on -> on -> m on uniplate :: Uniplate on => on -> (Str on, Str on -> on) universe :: Uniplate on => on -> [on] (|-) :: () => Type item -> from to -> item -> Type from to (|*) :: () => Type to -> from to -> to -> Type from to (||*) :: () => Type [to] -> from to -> [to] -> Type from to plate :: () => from -> Type from to module Ideas.Text.MathML data MathML MRow :: [MathML] -> MathML MId :: String -> MathML MNumber :: String -> MathML MOperator :: String -> MathML MString :: String -> MathML MText :: String -> MathML MSqrt :: MathML -> MathML MRoot :: MathML -> MathML -> MathML MSup :: MathML -> MathML -> MathML MSub :: MathML -> MathML -> MathML MSubSup :: MathML -> MathML -> MathML -> MathML MFrac :: MathML -> MathML -> MathML MFenced :: String -> String -> MathML -> MathML MSpace :: MathML MStyle :: MathML MPadded :: MathML MPhantom :: MathML MError :: MathML MEnclose :: MathML MUnder :: MathML MOver :: MathML MUnderOver :: MathML MTable :: MathML MTableRow :: MathML MLabeledTableRow :: MathML MTableData :: MathML xml2mathml :: XML -> Either String MathML mathml2xml :: MathML -> XML instance GHC.Classes.Eq Ideas.Text.MathML.MathML instance GHC.Show.Show Ideas.Text.MathML.MathML instance Ideas.Text.XML.ToXML Ideas.Text.MathML.MathML instance Ideas.Text.XML.InXML Ideas.Text.MathML.MathML instance Data.Generics.Uniplate.Operations.Uniplate Ideas.Text.MathML.MathML module Ideas.Common.Traversal.Navigator data Location toLocation :: [Int] -> Location fromLocation :: Location -> [Int] -- | For a minimal complete definition, provide an implemention for downs -- or allDowns. All other functions need an implementation as well, -- except for change. Note that a constructor (a -> f a) is not -- included in the type class to allow additional type class constraints -- on type a. class Navigator a up :: Navigator a => a -> Maybe a down :: Navigator a => a -> Maybe a downLast :: Navigator a => a -> Maybe a left :: Navigator a => a -> Maybe a right :: Navigator a => a -> Maybe a childnr :: Navigator a => a -> Int location :: Navigator a => a -> Location isTop :: Navigator a => a -> Bool isLeaf :: Navigator a => a -> Bool hasLeft :: Navigator a => a -> Bool hasRight :: Navigator a => a -> Bool hasUp :: Navigator a => a -> Bool hasDown :: Navigator a => a -> Bool top :: Navigator a => a -> a leftMost :: Navigator a => a -> a rightMost :: Navigator a => a -> a leftMostLeaf :: Navigator a => a -> a rightMostLeaf :: Navigator a => a -> a depth :: Navigator a => a -> Int level :: Navigator a => a -> Int levelNext :: Navigator a => a -> Maybe a levelPrevious :: Navigator a => a -> Maybe a leftMostAt :: Navigator a => Int -> a -> Maybe a rightMostAt :: Navigator a => Int -> a -> Maybe a downs :: Navigator a => a -> [a] downTo :: Navigator a => Int -> a -> Maybe a arity :: Navigator a => a -> Int navigateTo :: Navigator a => Location -> a -> Maybe a navigateTowards :: Navigator a => Location -> a -> a data PreOrder a makePreOrder :: a -> PreOrder a data PostOrder a makePostOrder :: a -> PostOrder a data LevelOrder a makeLevelOrder :: a -> LevelOrder a data Horizontal a makeHorizontal :: a -> Horizontal a data Leafs a makeLeafs :: Navigator a => a -> Leafs a data UniplateNavigator a instance GHC.Classes.Eq a => GHC.Classes.Eq (Ideas.Common.Traversal.Navigator.Leafs a) instance GHC.Show.Show a => GHC.Show.Show (Ideas.Common.Traversal.Navigator.Leafs a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Ideas.Common.Traversal.Navigator.Horizontal a) instance GHC.Show.Show a => GHC.Show.Show (Ideas.Common.Traversal.Navigator.Horizontal a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Ideas.Common.Traversal.Navigator.LevelOrder a) instance GHC.Show.Show a => GHC.Show.Show (Ideas.Common.Traversal.Navigator.LevelOrder a) instance Ideas.Common.Traversal.Navigator.Navigator a => Ideas.Common.Traversal.Iterator.Iterator (Ideas.Common.Traversal.Navigator.PostOrder a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Ideas.Common.Traversal.Navigator.PostOrder a) instance GHC.Show.Show a => GHC.Show.Show (Ideas.Common.Traversal.Navigator.PostOrder a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Ideas.Common.Traversal.Navigator.PreOrder a) instance GHC.Show.Show a => GHC.Show.Show (Ideas.Common.Traversal.Navigator.PreOrder a) instance GHC.Classes.Ord Ideas.Common.Traversal.Navigator.Location instance GHC.Classes.Eq Ideas.Common.Traversal.Navigator.Location instance (GHC.Show.Show a, Data.Generics.Uniplate.Operations.Uniplate a) => GHC.Show.Show (Ideas.Common.Traversal.Navigator.UniplateNavigator a) instance (GHC.Classes.Eq a, Data.Generics.Uniplate.Operations.Uniplate a) => GHC.Classes.Eq (Ideas.Common.Traversal.Navigator.UniplateNavigator a) instance Data.Generics.Uniplate.Operations.Uniplate a => Ideas.Common.Traversal.Navigator.Navigator (Ideas.Common.Traversal.Navigator.UniplateNavigator a) instance Ideas.Common.Traversal.Utils.Update Ideas.Common.Traversal.Navigator.UniplateNavigator instance Data.Generics.Uniplate.Operations.Uniplate a => Ideas.Common.Traversal.Utils.Focus (Ideas.Common.Traversal.Navigator.UniplateNavigator a) instance (Test.QuickCheck.Arbitrary.Arbitrary a, Data.Generics.Uniplate.Operations.Uniplate a) => Test.QuickCheck.Arbitrary.Arbitrary (Ideas.Common.Traversal.Navigator.UniplateNavigator a) instance Ideas.Common.Traversal.Iterator.Iterator (Ideas.Common.Traversal.Navigator.StrIterator a) instance Ideas.Common.Traversal.Utils.Focus (Ideas.Common.Traversal.Navigator.StrIterator a) instance Ideas.Common.Traversal.Utils.Update Ideas.Common.Traversal.Navigator.StrIterator instance Ideas.Common.Traversal.Navigator.Navigator (Ideas.Common.Traversal.Navigator.StrNavigator a) instance Ideas.Common.Traversal.Utils.Focus (Ideas.Common.Traversal.Navigator.StrNavigator a) instance Ideas.Common.Traversal.Utils.Wrapper Ideas.Common.Traversal.Navigator.Leafs instance Ideas.Common.Traversal.Utils.Update Ideas.Common.Traversal.Navigator.Leafs instance Ideas.Common.Traversal.Navigator.Navigator a => Ideas.Common.Traversal.Iterator.Iterator (Ideas.Common.Traversal.Navigator.Leafs a) instance Ideas.Common.Traversal.Utils.Wrapper Ideas.Common.Traversal.Navigator.Horizontal instance Ideas.Common.Traversal.Utils.Update Ideas.Common.Traversal.Navigator.Horizontal instance Ideas.Common.Traversal.Navigator.Navigator a => Ideas.Common.Traversal.Iterator.Iterator (Ideas.Common.Traversal.Navigator.Horizontal a) instance Ideas.Common.Traversal.Utils.Wrapper Ideas.Common.Traversal.Navigator.LevelOrder instance Ideas.Common.Traversal.Utils.Update Ideas.Common.Traversal.Navigator.LevelOrder instance Ideas.Common.Traversal.Navigator.Navigator a => Ideas.Common.Traversal.Iterator.Iterator (Ideas.Common.Traversal.Navigator.LevelOrder a) instance Ideas.Common.Traversal.Utils.Wrapper Ideas.Common.Traversal.Navigator.PostOrder instance Ideas.Common.Traversal.Utils.Update Ideas.Common.Traversal.Navigator.PostOrder instance Ideas.Common.Traversal.Utils.Wrapper Ideas.Common.Traversal.Navigator.PreOrder instance Ideas.Common.Traversal.Utils.Update Ideas.Common.Traversal.Navigator.PreOrder instance Ideas.Common.Traversal.Navigator.Navigator a => Ideas.Common.Traversal.Iterator.Iterator (Ideas.Common.Traversal.Navigator.PreOrder a) instance Ideas.Common.Traversal.Navigator.Navigator a => Ideas.Common.Traversal.Navigator.Navigator (Ideas.Common.Traversal.Utils.Mirror a) instance GHC.Show.Show Ideas.Common.Traversal.Navigator.Location instance GHC.Base.Semigroup Ideas.Common.Traversal.Navigator.Location instance GHC.Base.Monoid Ideas.Common.Traversal.Navigator.Location module Ideas.Common.Traversal.Tests testIterator :: (Show a, Eq a, Iterator a) => String -> Gen a -> TestSuite testNavigator :: (Show a, Eq a, Navigator a) => String -> Gen a -> TestSuite tests :: TestSuite uniGen :: Gen (UniplateNavigator (T Int)) listGen :: Gen (ListIterator Int) instance GHC.Classes.Eq a => GHC.Classes.Eq (Ideas.Common.Traversal.Tests.T a) instance GHC.Show.Show a => GHC.Show.Show (Ideas.Common.Traversal.Tests.T a) instance Data.Generics.Uniplate.Operations.Uniplate (Ideas.Common.Traversal.Tests.T a) instance Test.QuickCheck.Arbitrary.Arbitrary a => Test.QuickCheck.Arbitrary.Arbitrary (Ideas.Common.Traversal.Tests.T a) -- | A simple data type for term rewriting module Ideas.Common.Rewriting.Term data Symbol newSymbol :: IsId a => a -> Symbol isAssociative :: Symbol -> Bool makeAssociative :: Symbol -> Symbol nothingSymbol :: Symbol trueSymbol :: Symbol falseSymbol :: Symbol data Term TVar :: String -> Term TCon :: Symbol -> [Term] -> Term TList :: [Term] -> Term TNum :: Integer -> Term TFloat :: Double -> Term TMeta :: Int -> Term class IsTerm a toTerm :: IsTerm a => a -> Term toTermList :: IsTerm a => [a] -> Term fromTerm :: (IsTerm a, MonadPlus m) => Term -> m a fromTermList :: (IsTerm a, MonadPlus m) => Term -> m [a] termView :: IsTerm a => View Term a fromTermM :: (Monad m, IsTerm a) => Term -> m a fromTermWith :: (Monad m, IsTerm a) => (Symbol -> [a] -> m a) -> Term -> m a class WithFunctions a symbol :: WithFunctions a => Symbol -> a function :: WithFunctions a => Symbol -> [a] -> a getSymbol :: (WithFunctions a, Monad m) => a -> m Symbol getFunction :: (WithFunctions a, Monad m) => a -> m (Symbol, [a]) isSymbol :: WithFunctions a => Symbol -> a -> Bool isFunction :: (WithFunctions a, Monad m) => Symbol -> a -> m [a] unary :: WithFunctions a => Symbol -> a -> a binary :: WithFunctions a => Symbol -> a -> a -> a ternary :: WithFunctions a => Symbol -> a -> a -> a -> a isUnary :: (WithFunctions a, Monad m) => Symbol -> a -> m a isBinary :: (WithFunctions a, Monad m) => Symbol -> a -> m (a, a) class WithVars a variable :: WithVars a => String -> a getVariable :: (WithVars a, Monad m) => a -> m String isVariable :: WithVars a => a -> Bool vars :: (Uniplate a, WithVars a) => a -> [String] varSet :: (Uniplate a, WithVars a) => a -> Set String hasVar :: (Uniplate a, WithVars a) => String -> a -> Bool withoutVar :: (Uniplate a, WithVars a) => String -> a -> Bool hasSomeVar :: (Uniplate a, WithVars a) => a -> Bool hasNoVar :: (Uniplate a, WithVars a) => a -> Bool variableView :: WithVars a => View a String class WithMetaVars a metaVar :: WithMetaVars a => Int -> a getMetaVar :: (WithMetaVars a, Monad m) => a -> m Int isMetaVar :: WithMetaVars a => a -> Bool metaVars :: (Uniplate a, WithMetaVars a) => a -> [Int] metaVarSet :: (Uniplate a, WithMetaVars a) => a -> IntSet hasMetaVar :: (Uniplate a, WithMetaVars a) => Int -> a -> Bool nextMetaVar :: (Uniplate a, WithMetaVars a) => a -> Int instance GHC.Classes.Ord Ideas.Common.Rewriting.Term.Term instance GHC.Classes.Eq Ideas.Common.Rewriting.Term.Term instance GHC.Read.Read Ideas.Common.Rewriting.Term.Term instance GHC.Show.Show Ideas.Common.Rewriting.Term.Term instance Ideas.Common.Rewriting.Term.WithMetaVars Ideas.Common.Rewriting.Term.Term instance Ideas.Common.Rewriting.Term.WithVars Ideas.Common.Rewriting.Term.Term instance Data.Generics.Uniplate.Operations.Uniplate Ideas.Common.Rewriting.Term.Term instance Ideas.Common.Rewriting.Term.IsTerm GHC.Types.Bool instance Ideas.Common.Rewriting.Term.IsTerm a => Ideas.Common.Rewriting.Term.IsTerm (GHC.Base.Maybe a) instance Ideas.Common.Rewriting.Term.WithFunctions Ideas.Common.Rewriting.Term.Term instance Test.QuickCheck.Arbitrary.Arbitrary Ideas.Common.Rewriting.Term.Term instance Ideas.Common.Rewriting.Term.IsTerm Ideas.Common.Rewriting.Term.Term instance Ideas.Common.Rewriting.Term.IsTerm Ideas.Utils.Prelude.ShowString instance (Ideas.Common.Rewriting.Term.IsTerm a, Ideas.Common.Rewriting.Term.IsTerm b) => Ideas.Common.Rewriting.Term.IsTerm (a, b) instance (Ideas.Common.Rewriting.Term.IsTerm a, Ideas.Common.Rewriting.Term.IsTerm b, Ideas.Common.Rewriting.Term.IsTerm c) => Ideas.Common.Rewriting.Term.IsTerm (a, b, c) instance (Ideas.Common.Rewriting.Term.IsTerm a, Ideas.Common.Rewriting.Term.IsTerm b) => Ideas.Common.Rewriting.Term.IsTerm (Data.Either.Either a b) instance Ideas.Common.Rewriting.Term.IsTerm GHC.Types.Int instance Ideas.Common.Rewriting.Term.IsTerm GHC.Integer.Type.Integer instance Ideas.Common.Rewriting.Term.IsTerm GHC.Types.Double instance Ideas.Common.Rewriting.Term.IsTerm GHC.Types.Char instance Ideas.Common.Rewriting.Term.IsTerm a => Ideas.Common.Rewriting.Term.IsTerm [a] instance (Ideas.Common.Rewriting.Term.IsTerm a, GHC.Classes.Ord a) => Ideas.Common.Rewriting.Term.IsTerm (Data.Set.Internal.Set a) instance (Ideas.Common.Rewriting.Term.IsTerm a, Ideas.Common.Rewriting.Term.IsTerm b, GHC.Classes.Ord a) => Ideas.Common.Rewriting.Term.IsTerm (Data.Map.Internal.Map a b) instance GHC.Classes.Eq Ideas.Common.Rewriting.Term.Symbol instance GHC.Classes.Ord Ideas.Common.Rewriting.Term.Symbol instance GHC.Show.Show Ideas.Common.Rewriting.Term.Symbol instance GHC.Read.Read Ideas.Common.Rewriting.Term.Symbol instance Ideas.Common.Id.HasId Ideas.Common.Rewriting.Term.Symbol -- | Compute the difference of two terms generically, taking associativity -- into account. module Ideas.Common.Rewriting.Difference difference :: IsTerm a => a -> a -> Maybe (a, a) differenceWith :: View Term a -> a -> a -> Maybe (a, a) module Ideas.Common.Rewriting.AutoTerm toTermG :: Data a => a -> Term fromTermG :: (MonadPlus m, Data a) => Term -> m a testTermFor :: (Data a, Eq a) => a -> Bool -- | References, bindings, and heterogenous environments module Ideas.Common.Environment -- | A data type for references (without a value) data Ref a -- | A type class for types as references class (IsTerm a, Typeable a, Show a, Read a) => Reference a makeRef :: (Reference a, IsId n) => n -> Ref a makeRefList :: (Reference a, IsId n) => n -> Ref [a] mapRef :: Typeable b => Isomorphism a b -> Ref a -> Ref b data Binding makeBinding :: Ref a -> a -> Binding fromBinding :: Typeable a => Binding -> Maybe (Ref a, a) showValue :: Binding -> String getTermValue :: Binding -> Term data Environment makeEnvironment :: [Binding] -> Environment singleBinding :: Ref a -> a -> Environment class HasEnvironment env environment :: HasEnvironment env => env -> Environment setEnvironment :: HasEnvironment env => Environment -> env -> env deleteRef :: HasEnvironment env => Ref a -> env -> env insertRef :: HasEnvironment env => Ref a -> a -> env -> env changeRef :: HasEnvironment env => Ref a -> (a -> a) -> env -> env class HasRefs a getRefs :: HasRefs a => a -> [Some Ref] allRefs :: HasRefs a => a -> [Some Ref] getRefIds :: HasRefs a => a -> [Id] bindings :: HasEnvironment env => env -> [Binding] noBindings :: HasEnvironment env => env -> Bool (?) :: HasEnvironment env => Ref a -> env -> Maybe a instance GHC.Classes.Eq Ideas.Common.Environment.Environment instance Ideas.Common.Environment.HasRefs Ideas.Common.Environment.Environment instance Ideas.Common.Environment.HasEnvironment Ideas.Common.Environment.Environment instance GHC.Show.Show Ideas.Common.Environment.Environment instance GHC.Base.Semigroup Ideas.Common.Environment.Environment instance GHC.Base.Monoid Ideas.Common.Environment.Environment instance GHC.Show.Show Ideas.Common.Environment.Binding instance GHC.Classes.Eq Ideas.Common.Environment.Binding instance Ideas.Common.Id.HasId Ideas.Common.Environment.Binding instance Ideas.Common.Environment.Reference GHC.Types.Int instance Ideas.Common.Environment.Reference Ideas.Common.Rewriting.Term.Term instance Ideas.Common.Environment.Reference GHC.Types.Char instance Ideas.Common.Environment.Reference Ideas.Utils.Prelude.ShowString instance Ideas.Common.Environment.Reference a => Ideas.Common.Environment.Reference [a] instance (Ideas.Common.Environment.Reference a, Ideas.Common.Environment.Reference b) => Ideas.Common.Environment.Reference (a, b) instance GHC.Show.Show (Ideas.Common.Environment.Ref a) instance GHC.Classes.Eq (Ideas.Common.Environment.Ref a) instance Ideas.Common.Id.HasId (Ideas.Common.Environment.Ref a) instance Ideas.Utils.Typeable.HasTypeable Ideas.Common.Environment.Ref -- | Substitutions on terms. Substitutions are idempotent, and non-cyclic. module Ideas.Common.Rewriting.Substitution -- | Abstract data type for substitutions data Substitution -- | Returns the empty substitution emptySubst :: Substitution -- | Returns a singleton substitution singletonSubst :: Int -> Term -> Substitution -- | Returns the domain of a substitution (as a set) dom :: Substitution -> IntSet -- | Lookups a variable in a substitution. Nothing indicates that the -- variable is not in the domain of the substitution lookupVar :: Int -> Substitution -> Maybe Term -- | Combines two substitutions. The left-hand side substitution is first -- applied to the co-domain of the right-hand side substitution (@@) :: Substitution -> Substitution -> Substitution infixr 6 @@ -- | Apply the substitution (|->) :: Substitution -> Term -> Term infixr 5 |-> -- | Turns a list into a substitution listToSubst :: [(Int, Term)] -> Substitution composable :: Substitution -> Substitution -> Bool (@+@) :: Substitution -> Substitution -> Maybe Substitution infix 6 @+@ tests :: TestSuite instance GHC.Classes.Eq Ideas.Common.Rewriting.Substitution.Substitution instance GHC.Base.Semigroup Ideas.Common.Rewriting.Substitution.Substitution instance GHC.Base.Monoid Ideas.Common.Rewriting.Substitution.Substitution instance GHC.Show.Show Ideas.Common.Rewriting.Substitution.Substitution instance Test.QuickCheck.Arbitrary.Arbitrary Ideas.Common.Rewriting.Substitution.Substitution module Ideas.Common.Rewriting.Unification unify :: Term -> Term -> Maybe Substitution match :: MonadPlus m => Term -> Term -> m Substitution matchExtended :: Map Symbol SymbolMatch -> Term -> Term -> [(Substitution, Maybe Term, Maybe Term)] matchList :: Match Term -> Match [Term] type Match a = a -> a -> [Substitution] type SymbolMatch = Match Term -> [Term] -> Term -> [Substitution] unificationTests :: TestSuite module Ideas.Common.Rewriting.RewriteRule class Different a different :: Different a => (a, a) data RewriteRule a ruleSpecTerm :: RewriteRule a -> RuleSpec Term data RuleSpec a (:~>) :: a -> a -> RuleSpec a makeRewriteRule :: (IsId n, RuleBuilder f a) => n -> f -> RewriteRule a termRewriteRule :: (IsId n, IsTerm a, Show a) => n -> RuleSpec Term -> RewriteRule a class (IsTerm a, Show a) => RuleBuilder t a | t -> a buildRuleSpec :: RuleBuilder t a => Int -> t -> RuleSpec Term showRewriteRule :: Bool -> RewriteRule a -> Maybe String metaInRewriteRule :: RewriteRule a -> [Int] renumberRewriteRule :: Int -> RewriteRule a -> RewriteRule a symbolMatcher :: Symbol -> SymbolMatch -> RewriteRule a -> RewriteRule a symbolBuilder :: Symbol -> ([Term] -> Term) -> RewriteRule a -> RewriteRule a instance GHC.Show.Show a => GHC.Show.Show (Ideas.Common.Rewriting.RewriteRule.RuleSpec a) instance (Ideas.Common.Rewriting.Term.IsTerm a, GHC.Show.Show a) => Ideas.Common.Rewriting.RewriteRule.RuleBuilder (Ideas.Common.Rewriting.RewriteRule.RuleSpec a) a instance (Ideas.Common.Rewriting.RewriteRule.Different a, Ideas.Common.Rewriting.RewriteRule.RuleBuilder t b) => Ideas.Common.Rewriting.RewriteRule.RuleBuilder (a -> t) b instance Ideas.Common.Rewriting.RewriteRule.Different a => Ideas.Common.Rewriting.RewriteRule.Different [a] instance Ideas.Common.Rewriting.RewriteRule.Different GHC.Types.Int instance Ideas.Common.Rewriting.RewriteRule.Different GHC.Integer.Type.Integer instance Ideas.Common.Rewriting.RewriteRule.Different GHC.Types.Double instance Ideas.Common.Rewriting.RewriteRule.Different GHC.Types.Float instance Ideas.Common.Rewriting.RewriteRule.Different GHC.Real.Rational instance Ideas.Common.Rewriting.RewriteRule.Different GHC.Types.Bool instance Ideas.Common.Rewriting.RewriteRule.Different GHC.Types.Char instance Ideas.Common.Rewriting.RewriteRule.Different Ideas.Common.Rewriting.Term.Term instance (Ideas.Common.Rewriting.RewriteRule.Different a, Ideas.Common.Rewriting.RewriteRule.Different b) => Ideas.Common.Rewriting.RewriteRule.Different (a, b) instance (Ideas.Common.Rewriting.RewriteRule.Different a, Ideas.Common.Rewriting.RewriteRule.Different b, Ideas.Common.Rewriting.RewriteRule.Different c) => Ideas.Common.Rewriting.RewriteRule.Different (a, b, c) instance GHC.Show.Show (Ideas.Common.Rewriting.RewriteRule.RewriteRule a) instance Ideas.Common.Id.HasId (Ideas.Common.Rewriting.RewriteRule.RewriteRule a) instance Ideas.Common.Classes.Apply Ideas.Common.Rewriting.RewriteRule.RewriteRule instance GHC.Base.Functor Ideas.Common.Rewriting.RewriteRule.RuleSpec module Ideas.Common.Rewriting class WithMetaVars a metaVar :: WithMetaVars a => Int -> a getMetaVar :: (WithMetaVars a, Monad m) => a -> m Int class WithVars a variable :: WithVars a => String -> a getVariable :: (WithVars a, Monad m) => a -> m String class WithFunctions a symbol :: WithFunctions a => Symbol -> a function :: WithFunctions a => Symbol -> [a] -> a getSymbol :: (WithFunctions a, Monad m) => a -> m Symbol getFunction :: (WithFunctions a, Monad m) => a -> m (Symbol, [a]) class IsTerm a toTerm :: IsTerm a => a -> Term toTermList :: IsTerm a => [a] -> Term fromTerm :: (IsTerm a, MonadPlus m) => Term -> m a fromTermList :: (IsTerm a, MonadPlus m) => Term -> m [a] data Term TVar :: String -> Term TCon :: Symbol -> [Term] -> Term TList :: [Term] -> Term TNum :: Integer -> Term TFloat :: Double -> Term TMeta :: Int -> Term data Symbol newSymbol :: IsId a => a -> Symbol makeAssociative :: Symbol -> Symbol termView :: IsTerm a => View Term a trueSymbol :: Symbol falseSymbol :: Symbol nothingSymbol :: Symbol fromTermM :: (Monad m, IsTerm a) => Term -> m a fromTermWith :: (Monad m, IsTerm a) => (Symbol -> [a] -> m a) -> Term -> m a isSymbol :: WithFunctions a => Symbol -> a -> Bool isFunction :: (WithFunctions a, Monad m) => Symbol -> a -> m [a] unary :: WithFunctions a => Symbol -> a -> a binary :: WithFunctions a => Symbol -> a -> a -> a ternary :: WithFunctions a => Symbol -> a -> a -> a -> a isUnary :: (WithFunctions a, Monad m) => Symbol -> a -> m a isBinary :: (WithFunctions a, Monad m) => Symbol -> a -> m (a, a) isVariable :: WithVars a => a -> Bool vars :: (Uniplate a, WithVars a) => a -> [String] varSet :: (Uniplate a, WithVars a) => a -> Set String hasVar :: (Uniplate a, WithVars a) => String -> a -> Bool withoutVar :: (Uniplate a, WithVars a) => String -> a -> Bool hasSomeVar :: (Uniplate a, WithVars a) => a -> Bool hasNoVar :: (Uniplate a, WithVars a) => a -> Bool variableView :: WithVars a => View a String isMetaVar :: WithMetaVars a => a -> Bool metaVars :: (Uniplate a, WithMetaVars a) => a -> [Int] metaVarSet :: (Uniplate a, WithMetaVars a) => a -> IntSet hasMetaVar :: (Uniplate a, WithMetaVars a) => Int -> a -> Bool nextMetaVar :: (Uniplate a, WithMetaVars a) => a -> Int toTermG :: Data a => a -> Term fromTermG :: (MonadPlus m, Data a) => Term -> m a class (IsTerm a, Show a) => RuleBuilder t a | t -> a buildRuleSpec :: RuleBuilder t a => Int -> t -> RuleSpec Term class Different a different :: Different a => (a, a) data RewriteRule a data RuleSpec a (:~>) :: a -> a -> RuleSpec a makeRewriteRule :: (IsId n, RuleBuilder f a) => n -> f -> RewriteRule a termRewriteRule :: (IsId n, IsTerm a, Show a) => n -> RuleSpec Term -> RewriteRule a symbolMatcher :: Symbol -> SymbolMatch -> RewriteRule a -> RewriteRule a symbolBuilder :: Symbol -> ([Term] -> Term) -> RewriteRule a -> RewriteRule a showRewriteRule :: Bool -> RewriteRule a -> Maybe String metaInRewriteRule :: RewriteRule a -> [Int] renumberRewriteRule :: Int -> RewriteRule a -> RewriteRule a -- | Datatype for representing a derivation (parameterized both in the -- terms and the steps) module Ideas.Common.Derivation data Derivation s a emptyDerivation :: a -> Derivation s a prepend :: (a, s) -> Derivation s a -> Derivation s a extend :: Derivation s a -> (s, a) -> Derivation s a merge :: Eq a => Derivation s a -> Derivation s a -> Maybe (Derivation s a) mergeBy :: (a -> a -> Bool) -> Derivation s a -> Derivation s a -> Maybe (Derivation s a) mergeStep :: Derivation s a -> s -> Derivation s a -> Derivation s a derivationToList :: (s -> b) -> (a -> b) -> Derivation s a -> [b] derivationFromList :: Monad m => (b -> m s) -> (b -> m a) -> [b] -> m (Derivation s a) -- | Tests whether the derivation is empty isEmpty :: Derivation s a -> Bool -- | Returns the number of steps in a derivation derivationLength :: Derivation s a -> Int -- | All terms in a derivation terms :: Derivation s a -> [a] -- | All steps in a derivation steps :: Derivation s a -> [s] -- | The triples of a derivation, consisting of the before term, the step, -- and the after term. triples :: Derivation s a -> [(a, s, a)] firstTerm :: Derivation s a -> a lastTerm :: Derivation s a -> a lastStep :: Derivation s a -> Maybe s withoutLast :: Derivation s a -> Derivation s a updateSteps :: (a -> s -> a -> t) -> Derivation s a -> Derivation t a -- | Apply a monadic function to each term, and to each step derivationM :: Monad m => (s -> m ()) -> (a -> m ()) -> Derivation s a -> m () splitStep :: (s -> Bool) -> Derivation s a -> Maybe (Derivation s a, s, Derivation s a) instance (GHC.Classes.Eq a, GHC.Classes.Eq s) => GHC.Classes.Eq (Ideas.Common.Derivation.Derivation s a) instance (GHC.Show.Show s, GHC.Show.Show a) => GHC.Show.Show (Ideas.Common.Derivation.Derivation s a) instance GHC.Base.Functor (Ideas.Common.Derivation.Derivation s) instance Ideas.Common.Classes.BiFunctor Ideas.Common.Derivation.Derivation instance (Ideas.Common.Rewriting.Term.IsTerm s, Ideas.Common.Rewriting.Term.IsTerm a) => Ideas.Common.Rewriting.Term.IsTerm (Ideas.Common.Derivation.Derivation s a) -- | Datatype for representing derivations as a tree. The datatype stores -- all intermediate results as well as annotations for the steps. module Ideas.Common.DerivationTree data DerivationTree s a -- | Constructs a node without branches; the boolean indicates whether the -- node is an endpoint or not singleNode :: a -> Bool -> DerivationTree s a -- | Branches are attached after the existing ones (order matters) addBranches :: [(s, DerivationTree s a)] -> DerivationTree s a -> DerivationTree s a makeTree :: (a -> (Bool, [(s, a)])) -> a -> DerivationTree s a -- | The root of the tree root :: DerivationTree s a -> a -- | Is this node an endpoint? endpoint :: DerivationTree s a -> Bool -- | All branches branches :: DerivationTree s a -> [(s, DerivationTree s a)] -- | Returns all subtrees at a given node subtrees :: DerivationTree s a -> [DerivationTree s a] -- | Returns all leafs, i.e., final results in derivation. Be careful: the -- returned list may be very long leafs :: DerivationTree s a -> [a] -- | The argument supplied is the maximum number of steps; if more steps -- are needed, Nothing is returned lengthMax :: Int -> DerivationTree s a -> Maybe Int -- | Restrict the height of the tree (by cutting off branches at a certain -- depth). Nodes at this particular depth are turned into endpoints restrictHeight :: Int -> DerivationTree s a -> DerivationTree s a -- | Restrict the width of the tree (by cutting off branches). restrictWidth :: Int -> DerivationTree s a -> DerivationTree s a updateAnnotations :: (a -> s -> a -> t) -> DerivationTree s a -> DerivationTree t a cutOnStep :: (s -> Bool) -> DerivationTree s a -> DerivationTree s a mergeMaybeSteps :: DerivationTree (Maybe s) a -> DerivationTree s a sortTree :: (l -> l -> Ordering) -> DerivationTree l a -> DerivationTree l a cutOnTerm :: (a -> Bool) -> DerivationTree s a -> DerivationTree s a -- | The first derivation (if any) derivation :: DerivationTree s a -> Maybe (Derivation s a) -- | Return a random derivation (if any exists at all) randomDerivation :: RandomGen g => g -> DerivationTree s a -> Maybe (Derivation s a) -- | All possible derivations (returned in a list) derivations :: DerivationTree s a -> [Derivation s a] instance (GHC.Show.Show a, GHC.Show.Show s) => GHC.Show.Show (Ideas.Common.DerivationTree.DerivationTree s a) instance GHC.Base.Functor (Ideas.Common.DerivationTree.DerivationTree s) instance Ideas.Common.Classes.BiFunctor Ideas.Common.DerivationTree.DerivationTree -- | A type class for sequences together with the Firsts type class -- for accessing the firsts set and ready predicate. module Ideas.Common.Strategy.Sequence class Sequence a where { type family Sym a; } -- | The empty sequence. done :: Sequence a => a -- | Prepend a symbol to a sequence. (~>) :: Sequence a => Sym a -> a -> a -- | Append two sequences. (.*.) :: Sequence a => a -> a -> a -- | Singleton sequence. single :: Sequence a => Sym a -> a -- | Sequential composition. sequence :: Sequence a => [a] -> a class Firsts s where { type family Elem s; } -- | The ready predicate (we are done). ready :: Firsts s => s -> Bool -- | The firsts set. firsts :: Firsts s => s -> [(Elem s, s)] firstsTree :: Firsts s => s -> DerivationTree (Elem s) s instance Ideas.Common.Strategy.Sequence.Sequence b => Ideas.Common.Strategy.Sequence.Sequence (a -> b) -- | Processes support choices and sequences and are modelled after Hoare's -- CSP calculus. module Ideas.Common.Strategy.Process -- | Process data type with efficient support for sequences data Process a -- | Generalized equality of processes, which takes an equality function -- for the symbols. eqProcessBy :: (a -> a -> Bool) -> Process a -> Process a -> Bool menu :: Process a -> Menu a (Process a) withMenu :: Choice b => (a -> Process a -> b) -> b -> Process a -> b fold :: Choice b => (a -> b -> b) -> b -> Process a -> b runProcess :: Apply f => Process (f a) -> a -> [a] instance GHC.Classes.Eq a => GHC.Classes.Eq (Ideas.Common.Strategy.Process.Process a) instance GHC.Base.Functor Ideas.Common.Strategy.Process.Process instance Ideas.Common.Strategy.Choice.Choice (Ideas.Common.Strategy.Process.Process a) instance Ideas.Common.Strategy.Sequence.Sequence (Ideas.Common.Strategy.Process.Process a) instance Ideas.Common.Classes.Fix (Ideas.Common.Strategy.Process.Process a) instance Ideas.Common.Strategy.Sequence.Firsts (Ideas.Common.Strategy.Process.Process a) module Ideas.Common.Rewriting.Confluence isConfluent :: [RewriteRule a] -> Bool checkConfluence :: [RewriteRule a] -> IO () checkConfluenceWith :: Config -> [RewriteRule a] -> IO () somewhereM :: Uniplate a => (a -> [a]) -> a -> [a] data Config defaultConfig :: Config showTerm :: Config -> Term -> String complexity :: Config -> Term -> Int termEquality :: Config -> Term -> Term -> Bool -- | The Context datatype places a value in a context consisting of -- an environment with bindings and a point of focus. The datatype is an -- instance of the HasEnvironment type class (for accessing the -- environment) and the Navigator type class (for traversing the -- term). module Ideas.Common.Context -- | Abstract data type for a context: a context stores an environment. data Context a -- | Construct a context newContext :: ContextNavigator a -> Context a fromContext :: Monad m => Context a -> m a fromContextWith :: Monad m => (a -> b) -> Context a -> m b fromContextWith2 :: Monad m => (a -> b -> c) -> Context a -> Context b -> m c data ContextNavigator a noNavigator :: a -> ContextNavigator a navigator :: Uniplate a => a -> ContextNavigator a termNavigator :: IsTerm a => a -> ContextNavigator a -- | Lift a rule to operate on a term in a context liftToContext :: LiftView f => f a -> f (Context a) contextView :: View (Context a) (a, Context a) use :: (LiftView f, IsTerm a, IsTerm b) => f a -> f (Context b) useC :: (LiftView f, IsTerm a, IsTerm b) => f (Context a) -> f (Context b) -- | Apply a function at top-level. Afterwards, try to return the focus to -- the old position applyTop :: (a -> a) -> Context a -> Context a currentTerm :: Context a -> Maybe Term changeTerm :: (Term -> Maybe Term) -> Context a -> Maybe (Context a) replaceInContext :: a -> Context a -> Context a currentInContext :: Context a -> Maybe a changeInContext :: (a -> a) -> Context a -> Context a instance GHC.Classes.Eq a => GHC.Classes.Eq (Ideas.Common.Context.Context a) instance GHC.Show.Show a => GHC.Show.Show (Ideas.Common.Context.Context a) instance Ideas.Common.Traversal.Navigator.Navigator (Ideas.Common.Context.Context a) instance Ideas.Common.Environment.HasEnvironment (Ideas.Common.Context.Context a) -- | This module defines transformations. Given a term, a transformation -- returns a list of results (often a singleton list or the empty list). module Ideas.Common.Rule.Transformation type Transformation a = Trans a a data Trans a b -- | A type class for constructing a transformation. If possible, -- makeTrans should be used. Use specialized constructor -- functions for disambiguation. class MakeTrans f makeTrans :: MakeTrans f => (a -> f b) -> Trans a b transPure :: (a -> b) -> Trans a b transMaybe :: (a -> Maybe b) -> Trans a b transList :: (a -> [b]) -> Trans a b transGuard :: (a -> Bool) -> Trans a a transRewrite :: RewriteRule a -> Trans a a readRef :: Ref a -> Trans x a readRefDefault :: a -> Ref a -> Trans x a readRefMaybe :: Ref a -> Trans x (Maybe a) writeRef :: Ref a -> Trans a a writeRef_ :: Ref a -> Trans a () writeRefMaybe :: Ref a -> Trans (Maybe a) () transUseEnvironment :: Trans a b -> Trans (a, Environment) (b, Environment) transLiftView :: View a b -> Transformation b -> Transformation a transLiftViewIn :: View a (b, c) -> Transformation b -> Transformation a transLiftContext :: Transformation a -> Transformation (Context a) transLiftContextIn :: Transformation (a, Environment) -> Transformation (Context a) transApply :: Trans a b -> a -> [(b, Environment)] transApplyWith :: Environment -> Trans a b -> a -> [(b, Environment)] getRewriteRules :: Trans a b -> [Some RewriteRule] instance Ideas.Common.Rule.Transformation.MakeTrans GHC.Base.Maybe instance Ideas.Common.Rule.Transformation.MakeTrans [] instance Control.Category.Category Ideas.Common.Rule.Transformation.Trans instance Control.Arrow.Arrow Ideas.Common.Rule.Transformation.Trans instance Control.Arrow.ArrowZero Ideas.Common.Rule.Transformation.Trans instance Control.Arrow.ArrowPlus Ideas.Common.Rule.Transformation.Trans instance Control.Arrow.ArrowChoice Ideas.Common.Rule.Transformation.Trans instance GHC.Base.Semigroup (Ideas.Common.Rule.Transformation.Trans a b) instance GHC.Base.Monoid (Ideas.Common.Rule.Transformation.Trans a b) instance GHC.Base.Functor (Ideas.Common.Rule.Transformation.Trans a) instance GHC.Base.Applicative (Ideas.Common.Rule.Transformation.Trans a) instance GHC.Base.Alternative (Ideas.Common.Rule.Transformation.Trans a) instance Ideas.Common.Environment.HasRefs (Ideas.Common.Rule.Transformation.Trans a b) module Ideas.Common.Rule.Recognizer class Recognizable f recognizer :: Recognizable f => f a -> Recognizer a recognizeAll :: Recognizable f => f a -> a -> a -> [Environment] recognize :: Recognizable f => f a -> a -> a -> Maybe Environment recognizeTrans :: Recognizable f => f a -> Trans (a, a) () data Recognizer a makeRecognizer :: (a -> a -> Bool) -> Recognizer a makeRecognizerTrans :: Trans (a, a) () -> Recognizer a instance Ideas.Common.Rule.Recognizer.Recognizable Ideas.Common.Rule.Recognizer.Recognizer instance Ideas.Common.View.LiftView Ideas.Common.Rule.Recognizer.Recognizer instance GHC.Base.Semigroup (Ideas.Common.Rule.Recognizer.Recognizer a) instance GHC.Base.Monoid (Ideas.Common.Rule.Recognizer.Recognizer a) instance Ideas.Common.Environment.HasRefs (Ideas.Common.Rule.Recognizer.Recognizer a) -- | A rule is just a transformation with some meta-information, such as a -- name (which should be unique) and properties such as "buggy" or -- "minor". Rules can be lifted with a view using the LiftView type -- class. module Ideas.Common.Rule.Abstract -- | Abstract data type for representing rules data Rule a transformation :: Rule a -> Transformation a recognizer :: Recognizable f => f a -> Recognizer a checkReferences :: Rule a -> Environment -> Maybe String makeRule :: (IsId n, MakeTrans f) => n -> (a -> f a) -> Rule a ruleMaybe :: IsId n => n -> (a -> Maybe a) -> Rule a ruleList :: IsId n => n -> (a -> [a]) -> Rule a ruleTrans :: IsId n => n -> Transformation a -> Rule a ruleRewrite :: RewriteRule a -> Rule a buggyRule :: (IsId n, MakeTrans f) => n -> (a -> f a) -> Rule a minorRule :: (IsId n, MakeTrans f) => n -> (a -> f a) -> Rule a rewriteRule :: (IsId n, RuleBuilder f a) => n -> f -> Rule a rewriteRules :: (IsId n, RuleBuilder f a) => n -> [f] -> Rule a -- | A special (minor) rule that always returns the identity idRule :: IsId n => n -> Rule a -- | A special (minor) rule that checks a predicate (and returns the -- identity if the predicate holds) checkRule :: IsId n => n -> (a -> Bool) -> Rule a -- | A special (minor) rule that is never applicable (i.e., this rule -- always fails) emptyRule :: IsId n => n -> Rule a ruleSiblings :: Rule a -> [Id] siblingOf :: HasId b => b -> Rule a -> Rule a isRewriteRule :: Rule a -> Bool -- | Perform the function after the rule has been fired doAfter :: (a -> a) -> Rule a -> Rule a addRecognizer :: Recognizer a -> Rule a -> Rule a addRecognizerBool :: (a -> a -> Bool) -> Rule a -> Rule a addTransRecognizer :: (a -> a -> Bool) -> Rule a -> Rule a instance GHC.Show.Show (Ideas.Common.Rule.Abstract.Rule a) instance GHC.Classes.Eq (Ideas.Common.Rule.Abstract.Rule a) instance GHC.Classes.Ord (Ideas.Common.Rule.Abstract.Rule a) instance Ideas.Common.Classes.Apply Ideas.Common.Rule.Abstract.Rule instance Ideas.Common.Id.HasId (Ideas.Common.Rule.Abstract.Rule a) instance Ideas.Common.View.LiftView Ideas.Common.Rule.Abstract.Rule instance Ideas.Common.Rule.Recognizer.Recognizable Ideas.Common.Rule.Abstract.Rule instance Ideas.Common.Classes.Buggy (Ideas.Common.Rule.Abstract.Rule a) instance Ideas.Common.Classes.Minor (Ideas.Common.Rule.Abstract.Rule a) instance Ideas.Common.Environment.HasRefs (Ideas.Common.Rule.Abstract.Rule a) -- | This module defines transformations. Given a term, a transformation -- returns a list of results (often a singleton list or the empty list). -- A transformation can be parameterized with one or more Bindables. -- Transformations rules can be lifted to work on more complex domains -- with the LiftView type class. module Ideas.Common.Rule.Parameter input :: Ref i -> Trans (i, a) b -> Trans a b inputWith :: Trans a i -> Trans (i, a) b -> Trans a b transInput1 :: Ref i -> (i -> a -> Maybe b) -> Trans a b transInput2 :: Ref i1 -> Ref i2 -> (i1 -> i2 -> a -> Maybe b) -> Trans a b transInput3 :: Ref i1 -> Ref i2 -> Ref i3 -> (i1 -> i2 -> i3 -> a -> Maybe b) -> Trans a b transInputWith :: MakeTrans f => Trans a i -> (i -> a -> f b) -> Trans a b readRef2 :: Ref a -> Ref b -> Trans x (a, b) readRef3 :: Ref a -> Ref b -> Ref c -> Trans x (a, b, c) output :: Ref o -> Trans a (b, o) -> Trans a b outputWith :: Trans o x -> Trans a (b, o) -> Trans a b outputOnly :: Ref o -> Trans a o -> Trans a a outputOnly2 :: Ref o1 -> Ref o2 -> Trans a (o1, o2) -> Trans a a outputOnly3 :: Ref o1 -> Ref o2 -> Ref o3 -> Trans a (o1, o2, o3) -> Trans a a outputOnlyWith :: Trans o x -> Trans a o -> Trans a a writeRef2 :: Ref a -> Ref b -> Trans (a, b) (a, b) writeRef3 :: Ref a -> Ref b -> Ref c -> Trans (a, b, c) (a, b, c) writeRef2_ :: Ref a -> Ref b -> Trans (a, b) () writeRef3_ :: Ref a -> Ref b -> Ref c -> Trans (a, b, c) () type ParamTrans i a = Trans (i, a) a parameter1 :: Ref a -> (a -> b -> Maybe b) -> ParamTrans a b parameter2 :: Ref a -> Ref b -> (a -> b -> c -> Maybe c) -> ParamTrans (a, b) c parameter3 :: Ref a -> Ref b -> Ref c -> (a -> b -> c -> d -> Maybe d) -> ParamTrans (a, b, c) d transRef :: Ref a -> Trans a a supplyParameters :: ParamTrans b a -> Trans a b -> Transformation (Context a) module Ideas.Common.Rule -- | This module defines special symbols for labeling and atomicity. module Ideas.Common.Strategy.Symbol class Eq a => AtomicSymbol a atomicOpen :: AtomicSymbol a => a atomicClose :: AtomicSymbol a => a class Eq a => LabelSymbol a isEnterSymbol :: LabelSymbol a => a -> Bool enterRule :: Id -> Rule a exitRule :: Id -> Rule a isEnterRule :: Rule a -> Maybe Id isExitRule :: Rule a -> Maybe Id instance Ideas.Common.Strategy.Symbol.LabelSymbol (Ideas.Common.Rule.Abstract.Rule a) instance Ideas.Common.Strategy.Symbol.AtomicSymbol (Ideas.Common.Rule.Abstract.Rule a) -- | This module defines extra combinators. module Ideas.Common.Strategy.Derived -- | Allows all permutations of the list permute :: (Choice a, Sequence a) => [a] -> a many :: (Sequence a, Fix a, Choice a) => a -> a many1 :: (Sequence a, Fix a, Choice a) => a -> a replicate :: Sequence a => Int -> a -> a -- | Apply a certain strategy or do nothing (non-greedy) option :: (Choice a, Sequence a) => a -> a -- | Apply a certain strategy if this is possible (greedy version of -- option) try :: (Choice a, Sequence a) => a -> a -- | Repeat a strategy zero or more times (greedy version of many) repeat :: (Sequence a, Fix a, Choice a) => a -> a -- | Apply a certain strategy at least once (greedy version of -- many1) repeat1 :: (Sequence a, Fix a, Choice a) => a -> a -- | Apply the strategies from the list exhaustively (until this is no -- longer possible) exhaustive :: (Sequence a, Fix a, Choice a) => [a] -> a atomic :: AtomicSymbol a => Process a -> Process a (<%>) :: (AtomicSymbol a, LabelSymbol a) => Process a -> Process a -> Process a interleave :: (AtomicSymbol a, LabelSymbol a) => [Process a] -> Process a (<@>) :: AtomicSymbol a => Process a -> Process a -> Process a (!*>) :: AtomicSymbol a => Process a -> Process a -> Process a inits :: AtomicSymbol a => Process a -> Process a filterP :: (a -> Bool) -> Process a -> Process a hide :: (a -> Bool) -> Process a -> Process a -- | Representation of a strategy as a cyclic tree with explicit -- fixed-points. The nodes in the tree are named strategy combinators. -- The leafs are rules. module Ideas.Common.Strategy.StrategyTree type StrategyTree a = CyclicTree (Decl Nary) (Leaf a) data Leaf a LeafRule :: (Rule a) -> Leaf a LeafDyn :: (Dynamic a) -> Leaf a treeToProcess :: StrategyTree a -> Process (Leaf a) mapRulesInTree :: (Rule a -> Rule a) -> StrategyTree a -> StrategyTree a data Decl f type Combinator f = forall a. f (Process (Leaf a)) associative :: Decl f -> Decl f isAssociative :: Decl f -> Bool combinator :: Decl f -> Combinator f (.=.) :: IsId n => n -> Combinator f -> Decl f infix 1 .=. applyDecl :: Arity f => Decl f -> f (StrategyTree a) data Dynamic a makeDynamic :: (IsId n, IsTerm a) => n -> (a -> StrategyTree a) -> Dynamic a dynamicToTerm :: Dynamic a -> a -> Maybe Term dynamicTree :: Dynamic a -> a -> Maybe (StrategyTree a) dynamicFromTerm :: Dynamic a -> Term -> Maybe (StrategyTree a) class Arity f listify :: Arity f => f a -> [a] -> Maybe a toArity :: Arity f => ([a] -> a) -> f a liftIso :: Arity f => Isomorphism a b -> f a -> f b newtype Nullary a Nullary :: a -> Nullary a [fromNullary] :: Nullary a -> a newtype Unary a Unary :: a -> a -> Unary a [fromUnary] :: Unary a -> a -> a newtype Binary a Binary :: a -> a -> a -> Binary a [fromBinary] :: Binary a -> a -> a -> a newtype Nary a Nary :: [a] -> a -> Nary a [fromNary] :: Nary a -> [a] -> a instance GHC.Show.Show (Ideas.Common.Strategy.StrategyTree.Leaf a) instance GHC.Classes.Eq (Ideas.Common.Strategy.StrategyTree.Leaf a) instance Ideas.Common.Id.HasId (Ideas.Common.Strategy.StrategyTree.Leaf a) instance Ideas.Common.Strategy.Symbol.AtomicSymbol (Ideas.Common.Strategy.StrategyTree.Leaf a) instance Ideas.Common.Strategy.Symbol.LabelSymbol (Ideas.Common.Strategy.StrategyTree.Leaf a) instance Ideas.Common.Classes.Minor (Ideas.Common.Strategy.StrategyTree.Leaf a) instance Ideas.Common.Classes.Apply Ideas.Common.Strategy.StrategyTree.Leaf instance Ideas.Common.View.LiftView Ideas.Common.Strategy.StrategyTree.Leaf instance Ideas.Common.Id.HasId (Ideas.Common.Strategy.StrategyTree.Dynamic a) instance Ideas.Common.Classes.Apply Ideas.Common.Strategy.StrategyTree.Dynamic instance Ideas.Common.View.LiftView Ideas.Common.Strategy.StrategyTree.Dynamic instance GHC.Show.Show (Ideas.Common.Strategy.StrategyTree.Decl f) instance GHC.Classes.Eq (Ideas.Common.Strategy.StrategyTree.Decl f) instance Ideas.Common.Id.HasId (Ideas.Common.Strategy.StrategyTree.Decl f) instance Ideas.Common.Strategy.StrategyTree.Arity Ideas.Common.Strategy.StrategyTree.Nary instance Ideas.Common.Strategy.StrategyTree.Arity Ideas.Common.Strategy.StrategyTree.Binary instance Ideas.Common.Strategy.StrategyTree.Arity Ideas.Common.Strategy.StrategyTree.Unary instance Ideas.Common.Strategy.StrategyTree.Arity Ideas.Common.Strategy.StrategyTree.Nullary -- | Basic machinery for fully executing a strategy expression, or only -- partially. Partial execution results in a prefix that keeps the -- current locations in the strategy (a list of Paths) for -- continuing the execution later on. A path can be used to reconstruct -- the sequence of steps already performed (a so-called trace). Prefixes -- can be merged with the Monoid operation. module Ideas.Common.Strategy.Prefix data Prefix a -- | The error prefix (i.e., without a location in the strategy). noPrefix :: Prefix a -- | Make a prefix from a core strategy and a start term. makePrefix :: Process (Leaf a) -> a -> Prefix a firstsOrdered :: (Rule a -> Rule a -> Ordering) -> Prefix a -> [((Rule a, a, Environment), Prefix a)] -- | Construct a prefix by replaying a path in a core strategy: the third -- argument is the current term. replayProcess :: Path -> Process (Leaf a) -> ([Rule a], a -> Prefix a) isEmptyPrefix :: Prefix a -> Bool -- | Transforms the prefix such that only major steps are kept in the -- remaining strategy. majorPrefix :: Prefix a -> Prefix a -- | The searchModePrefix transformation changes the process in such a way -- that all intermediate states can only be reached by one path. A -- prerequisite is that symbols are unique (or only used once). searchModePrefix :: Prefix a -> Prefix a -- | Returns the current Path. prefixPaths :: Prefix a -> [Path] -- | A path encodes a location in a strategy. Paths are represented as a -- list of integers and terms (the latter act as input for the dynamic -- strategies). data Path -- | The empty path. emptyPath :: Path readPath :: Monad m => String -> m Path readPaths :: Monad m => String -> m [Path] instance GHC.Classes.Eq Ideas.Common.Strategy.Prefix.Path instance GHC.Classes.Eq Ideas.Common.Strategy.Prefix.PathItem instance GHC.Show.Show (Ideas.Common.Strategy.Prefix.Prefix a) instance GHC.Base.Semigroup (Ideas.Common.Strategy.Prefix.Prefix a) instance GHC.Base.Monoid (Ideas.Common.Strategy.Prefix.Prefix a) instance Ideas.Common.Strategy.Sequence.Firsts (Ideas.Common.Strategy.Prefix.Prefix a) instance GHC.Show.Show Ideas.Common.Strategy.Prefix.Path instance GHC.Show.Show Ideas.Common.Strategy.Prefix.PathItem instance GHC.Read.Read Ideas.Common.Strategy.Prefix.PathItem -- | Abstract data type for a Strategy and a LabeledStrategy. module Ideas.Common.Strategy.Abstract -- | Abstract data type for strategies data Strategy a -- | A strategy which is labeled with an identifier data LabeledStrategy a -- | Labels a strategy with an identifier. Labels are used to identify -- substrategies and to specialize feedback messages. The first argument -- of label can be of type String, in which case the string -- is used as identifier (and not as description). label :: (IsId l, IsStrategy f) => l -> f a -> LabeledStrategy a -- | Removes the label from a strategy unlabel :: LabeledStrategy a -> Strategy a -- | Type class to turn values into strategies class IsStrategy f toStrategy :: IsStrategy f => f a -> Strategy a liftS :: IsStrategy f => (Strategy a -> Strategy a) -> f a -> Strategy a liftS2 :: (IsStrategy f, IsStrategy g) => (Strategy a -> Strategy a -> Strategy a) -> f a -> g a -> Strategy a liftSn :: IsStrategy f => ([Strategy a] -> Strategy a) -> [f a] -> Strategy a -- | Construct the empty prefix for a labeled strategy emptyPrefix :: IsStrategy f => f a -> a -> Prefix a -- | Construct a prefix for a path and a labeled strategy. The third -- argument is the current term. replayPath :: IsStrategy f => Path -> f a -> a -> ([Rule a], Prefix a) -- | Construct a prefix for a list of paths and a labeled strategy. The -- third argument is the current term. replayPaths :: IsStrategy f => [Path] -> f a -> a -> Prefix a -- | Construct a prefix for a path and a labeled strategy. The third -- argument is the initial term. replayStrategy :: (Monad m, IsStrategy f) => Path -> f a -> a -> m (a, Prefix a) -- | Returns a list of all major rules that are part of a labeled strategy rulesInStrategy :: IsStrategy f => f a -> [Rule a] -- | Apply a function to all the rules that make up a labeled strategy mapRules :: (Rule a -> Rule a) -> LabeledStrategy a -> LabeledStrategy a mapRulesS :: (Rule a -> Rule a) -> Strategy a -> Strategy a -- | Use a function as do-after hook for all rules in a labeled strategy, -- but also use the function beforehand cleanUpStrategy :: (a -> a) -> LabeledStrategy a -> LabeledStrategy a -- | Use a function as do-after hook for all rules in a labeled strategy cleanUpStrategyAfter :: (a -> a) -> LabeledStrategy a -> LabeledStrategy a derivationList :: IsStrategy f => (Rule a -> Rule a -> Ordering) -> f a -> a -> [Derivation (Rule a, Environment) a] toStrategyTree :: IsStrategy f => f a -> StrategyTree a onStrategyTree :: IsStrategy f => (StrategyTree a -> StrategyTree a) -> f a -> Strategy a useDecl :: Arity f => Decl f -> f (Strategy a) decl0 :: Decl Nullary -> Strategy a decl1 :: IsStrategy f => Decl Unary -> f a -> Strategy a decl2 :: (IsStrategy f, IsStrategy g) => Decl Binary -> f a -> g a -> Strategy a declN :: IsStrategy f => Decl Nary -> [f a] -> Strategy a instance Ideas.Common.Strategy.Abstract.IsStrategy Ideas.Common.Strategy.Abstract.LabeledStrategy instance GHC.Show.Show (Ideas.Common.Strategy.Abstract.LabeledStrategy a) instance Ideas.Common.Classes.Apply Ideas.Common.Strategy.Abstract.LabeledStrategy instance Ideas.Common.Id.HasId (Ideas.Common.Strategy.Abstract.LabeledStrategy a) instance Ideas.Common.View.LiftView Ideas.Common.Strategy.Abstract.LabeledStrategy instance Ideas.Common.Strategy.Sequence.Sequence (Ideas.Common.Strategy.Abstract.Strategy a) instance Ideas.Common.Strategy.Abstract.IsStrategy Ideas.Common.Strategy.Abstract.Strategy instance Ideas.Common.Strategy.Abstract.IsStrategy Ideas.Common.Rule.Abstract.Rule instance Ideas.Common.Strategy.Abstract.IsStrategy Ideas.Common.Rewriting.RewriteRule.RewriteRule instance Ideas.Common.Strategy.Abstract.IsStrategy Ideas.Common.Strategy.StrategyTree.Dynamic instance GHC.Show.Show (Ideas.Common.Strategy.Abstract.Strategy a) instance Ideas.Common.Classes.Apply Ideas.Common.Strategy.Abstract.Strategy instance Ideas.Common.Strategy.Choice.Choice (Ideas.Common.Strategy.Abstract.Strategy a) instance Ideas.Common.Classes.Fix (Ideas.Common.Strategy.Abstract.Strategy a) instance Ideas.Common.View.LiftView Ideas.Common.Strategy.Abstract.Strategy -- | Locations that correspond to the labels in a strategy module Ideas.Common.Strategy.Location checkLocation :: Id -> LabeledStrategy a -> Bool subTaskLocation :: LabeledStrategy a -> Id -> Id -> Id nextTaskLocation :: LabeledStrategy a -> Id -> Id -> Id -- | Returns a list of all strategy locations, paired with the label strategyLocations :: LabeledStrategy a -> [([Int], Id)] -- | Strategies can be configured at their labeled positions. Possible -- actions are removereinsert, collapseexpand, and hide/reveal. module Ideas.Common.Strategy.Configuration data StrategyCfg byName :: HasId a => ConfigAction -> a -> StrategyCfg data ConfigAction Remove :: ConfigAction Reinsert :: ConfigAction Collapse :: ConfigAction Expand :: ConfigAction Hide :: ConfigAction Reveal :: ConfigAction configure :: StrategyCfg -> LabeledStrategy a -> LabeledStrategy a configureS :: StrategyCfg -> Strategy a -> Strategy a remove :: IsStrategy f => f a -> Strategy a collapse :: IsStrategy f => f a -> Strategy a hide :: IsStrategy f => f a -> Strategy a -- | Apply a strategy at least once, but collapse into a single step multi :: (IsId l, IsStrategy f) => l -> f a -> Strategy a isConfigId :: HasId a => a -> Bool instance GHC.Classes.Eq Ideas.Common.Strategy.Configuration.ConfigAction instance GHC.Show.Show Ideas.Common.Strategy.Configuration.ConfigAction instance GHC.Show.Show Ideas.Common.Strategy.Configuration.StrategyCfg instance GHC.Base.Semigroup Ideas.Common.Strategy.Configuration.StrategyCfg instance GHC.Base.Monoid Ideas.Common.Strategy.Configuration.StrategyCfg instance GHC.Read.Read Ideas.Common.Strategy.Configuration.ConfigAction instance GHC.Show.Show Ideas.Common.Strategy.Configuration.ConfigLocation -- | Converting a strategy to XML, and the other way around. module Ideas.Encoding.StrategyInfo strategyToXML :: IsStrategy f => f a -> XML -- | A collection of strategy combinators: all lifted to work on different -- data types module Ideas.Common.Strategy.Combinators -- | Put two strategies in sequence (first do this, then do that) (.*.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 5 .*. -- | Choose between the two strategies (either do this or do that) (.|.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 3 .|. -- | Interleave two strategies (.%.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 2 .%. -- | Alternate two strategies (.@.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 2 .@. -- | Prefixing a basic rule to a strategy atomically (!~>) :: IsStrategy f => Rule a -> f a -> Strategy a infixr 5 !~> -- | Initial prefixes (allows the strategy to stop succesfully at any time) inits :: IsStrategy f => f a -> Strategy a -- | The strategy that always succeeds (without doing anything) succeed :: Strategy a -- | The strategy that always fails fail :: Strategy a -- | Makes a strategy atomic (w.r.t. parallel composition) atomic :: IsStrategy f => f a -> Strategy a -- | Puts a list of strategies into a sequence sequence :: IsStrategy f => [f a] -> Strategy a -- | Combines a list of alternative strategies choice :: IsStrategy f => [f a] -> Strategy a -- | Combines a list of strategies with left-preference preference :: IsStrategy f => [f a] -> Strategy a -- | Combines a list of strategies with left-biased choice orelse :: IsStrategy f => [f a] -> Strategy a -- | Merges a list of strategies (in parallel) interleave :: IsStrategy f => [f a] -> Strategy a noInterleaving :: IsStrategy f => f a -> Strategy a interleaveId :: Id -- | Allows all permutations of the list permute :: IsStrategy f => [f a] -> Strategy a -- | Repeat a strategy zero or more times (non-greedy) many :: IsStrategy f => f a -> Strategy a -- | Apply a certain strategy at least once (non-greedy) many1 :: IsStrategy f => f a -> Strategy a -- | Apply a strategy a certain number of times replicate :: IsStrategy f => Int -> f a -> Strategy a -- | Apply a certain strategy or do nothing (non-greedy) option :: IsStrategy f => f a -> Strategy a -- | Checks whether a predicate holds for the current term. The check is -- considered to be a minor step. check :: (a -> Bool) -> Strategy a -- | Check whether or not the argument strategy cannot be applied: the -- result strategy only succeeds if this is not the case (otherwise it -- fails). not :: IsStrategy f => f a -> Strategy a -- | Repeat a strategy zero or more times (greedy version of many) repeat :: IsStrategy f => f a -> Strategy a -- | Apply a certain strategy at least once (greedy version of -- many1) repeat1 :: IsStrategy f => f a -> Strategy a -- | Apply a certain strategy if this is possible (greedy version of -- option) try :: IsStrategy f => f a -> Strategy a -- | Choose between the two strategies, with a preference for steps from -- the left hand-side strategy. (./.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 4 ./. -- | Left-biased choice: if the left-operand strategy can be applied, do -- so. Otherwise, try the right-operand strategy (|>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 4 |> -- | Repeat the strategy as long as the predicate holds while :: IsStrategy f => (a -> Bool) -> f a -> Strategy a -- | Repeat the strategy until the predicate holds until :: IsStrategy f => (a -> Bool) -> f a -> Strategy a -- | Apply the strategies from the list exhaustively (until this is no -- longer possible) exhaustive :: IsStrategy f => [f a] -> Strategy a -- | The structure of a dynamic strategy depends on the current term dynamic :: (IsId n, IsStrategy f, IsTerm a) => n -> (a -> f a) -> Strategy a type DependencyGraph node key = [(node, key, [key])] -- | Create a strategy from a dependency graph with strategies as nodes -- Does not check for cycles dependencyGraph :: (IsStrategy f, Ord key) => DependencyGraph (f a) key -> Strategy a -- | Parameterized traversals based on the strategy language. module Ideas.Common.Strategy.Traversal layer :: (IsStrategy f, Navigator a) => [Option a] -> f a -> Strategy a traverse :: (IsStrategy f, Navigator a) => [Option a] -> f a -> Strategy a data Option a topdown :: Option a bottomup :: Option a leftToRight :: Option a rightToLeft :: Option a full :: Option a spine :: Option a stop :: Option a once :: Option a leftmost :: Option a rightmost :: Option a traversalFilter :: (a -> Bool) -> Option a parentFilter :: Navigator a => (a -> [Int]) -> Option a fulltd :: (IsStrategy f, Navigator a) => f a -> Strategy a fullbu :: (IsStrategy f, Navigator a) => f a -> Strategy a oncetd :: (IsStrategy f, Navigator a) => f a -> Strategy a oncebu :: (IsStrategy f, Navigator a) => f a -> Strategy a leftmostbu :: (IsStrategy f, Navigator a) => f a -> Strategy a leftmosttd :: (IsStrategy f, Navigator a) => f a -> Strategy a somewhere :: (IsStrategy f, Navigator a) => f a -> Strategy a somewhereWhen :: (IsStrategy g, Navigator a) => (a -> Bool) -> g a -> Strategy a oncetdPref :: (IsStrategy f, Navigator a) => f a -> Strategy a oncebuPref :: (IsStrategy f, Navigator a) => f a -> Strategy a -- | left-most innermost traversal. innermost :: (IsStrategy f, Navigator a) => f a -> Strategy a -- | left-most outermost traversal. outermost :: (IsStrategy f, Navigator a) => f a -> Strategy a ruleUp :: Navigator a => Rule a ruleDown :: Navigator a => Rule a ruleDownLast :: Navigator a => Rule a ruleLeft :: Navigator a => Rule a ruleRight :: Navigator a => Rule a instance GHC.Base.Semigroup (Ideas.Common.Strategy.Traversal.Option a) instance GHC.Base.Monoid (Ideas.Common.Strategy.Traversal.Option a) -- | Legacy strategy combinators (before the Functor-Applicative-Monad -- proposal) module Ideas.Common.Strategy.Legacy (<%>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 2 <%> (<@>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 2 <@> (<|>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 3 <|> (>|>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 4 >|> (<*>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 5 <*> alternatives :: IsStrategy f => [f a] -> Strategy a -- | A strategy is a context-free grammar with rules as symbols. Strategies -- can be labeled with strings. The type class IsStrategy is -- introduced to lift functions and combinators that work on strategies -- to also accept rules and labeled strategies. This module re-exports -- the most important functionality of the underlying modules. module Ideas.Common.Strategy -- | Abstract data type for strategies data Strategy a -- | A strategy which is labeled with an identifier data LabeledStrategy a -- | Type class to turn values into strategies class IsStrategy f toStrategy :: IsStrategy f => f a -> Strategy a derivationList :: IsStrategy f => (Rule a -> Rule a -> Ordering) -> f a -> a -> [Derivation (Rule a, Environment) a] -- | Put two strategies in sequence (first do this, then do that) (.*.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 5 .*. -- | Choose between the two strategies (either do this or do that) (.|.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 3 .|. -- | Interleave two strategies (.%.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 2 .%. -- | Alternate two strategies (.@.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 2 .@. -- | Prefixing a basic rule to a strategy atomically (!~>) :: IsStrategy f => Rule a -> f a -> Strategy a infixr 5 !~> -- | The strategy that always succeeds (without doing anything) succeed :: Strategy a -- | The strategy that always fails fail :: Strategy a -- | Makes a strategy atomic (w.r.t. parallel composition) atomic :: IsStrategy f => f a -> Strategy a -- | Labels a strategy with an identifier. Labels are used to identify -- substrategies and to specialize feedback messages. The first argument -- of label can be of type String, in which case the string -- is used as identifier (and not as description). label :: (IsId l, IsStrategy f) => l -> f a -> LabeledStrategy a -- | Initial prefixes (allows the strategy to stop succesfully at any time) inits :: IsStrategy f => f a -> Strategy a -- | Puts a list of strategies into a sequence sequence :: IsStrategy f => [f a] -> Strategy a -- | Combines a list of alternative strategies choice :: IsStrategy f => [f a] -> Strategy a -- | Combines a list of strategies with left-preference preference :: IsStrategy f => [f a] -> Strategy a -- | Combines a list of strategies with left-biased choice orelse :: IsStrategy f => [f a] -> Strategy a alternatives :: IsStrategy f => [f a] -> Strategy a -- | Merges a list of strategies (in parallel) interleave :: IsStrategy f => [f a] -> Strategy a -- | Allows all permutations of the list permute :: IsStrategy f => [f a] -> Strategy a -- | Repeat a strategy zero or more times (non-greedy) many :: IsStrategy f => f a -> Strategy a -- | Apply a certain strategy at least once (non-greedy) many1 :: IsStrategy f => f a -> Strategy a -- | Apply a strategy a certain number of times replicate :: IsStrategy f => Int -> f a -> Strategy a -- | Apply a certain strategy or do nothing (non-greedy) option :: IsStrategy f => f a -> Strategy a -- | Checks whether a predicate holds for the current term. The check is -- considered to be a minor step. check :: (a -> Bool) -> Strategy a -- | Check whether or not the argument strategy cannot be applied: the -- result strategy only succeeds if this is not the case (otherwise it -- fails). not :: IsStrategy f => f a -> Strategy a -- | Repeat a strategy zero or more times (greedy version of many) repeat :: IsStrategy f => f a -> Strategy a -- | Apply a certain strategy at least once (greedy version of -- many1) repeat1 :: IsStrategy f => f a -> Strategy a -- | Apply a certain strategy if this is possible (greedy version of -- option) try :: IsStrategy f => f a -> Strategy a -- | Left-biased choice: if the left-operand strategy can be applied, do -- so. Otherwise, try the right-operand strategy (|>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 4 |> -- | Choose between the two strategies, with a preference for steps from -- the left hand-side strategy. (./.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 4 ./. -- | Apply the strategies from the list exhaustively (until this is no -- longer possible) exhaustive :: IsStrategy f => [f a] -> Strategy a -- | Repeat the strategy as long as the predicate holds while :: IsStrategy f => (a -> Bool) -> f a -> Strategy a -- | Repeat the strategy until the predicate holds until :: IsStrategy f => (a -> Bool) -> f a -> Strategy a -- | The structure of a dynamic strategy depends on the current term dynamic :: (IsId n, IsStrategy f, IsTerm a) => n -> (a -> f a) -> Strategy a type DependencyGraph node key = [(node, key, [key])] -- | Create a strategy from a dependency graph with strategies as nodes -- Does not check for cycles dependencyGraph :: (IsStrategy f, Ord key) => DependencyGraph (f a) key -> Strategy a data Option a layer :: (IsStrategy f, Navigator a) => [Option a] -> f a -> Strategy a traverse :: (IsStrategy f, Navigator a) => [Option a] -> f a -> Strategy a topdown :: Option a bottomup :: Option a leftToRight :: Option a rightToLeft :: Option a leftmost :: Option a rightmost :: Option a traversalFilter :: (a -> Bool) -> Option a parentFilter :: Navigator a => (a -> [Int]) -> Option a fulltd :: (IsStrategy f, Navigator a) => f a -> Strategy a fullbu :: (IsStrategy f, Navigator a) => f a -> Strategy a oncetd :: (IsStrategy f, Navigator a) => f a -> Strategy a oncetdPref :: (IsStrategy f, Navigator a) => f a -> Strategy a oncebu :: (IsStrategy f, Navigator a) => f a -> Strategy a oncebuPref :: (IsStrategy f, Navigator a) => f a -> Strategy a leftmostbu :: (IsStrategy f, Navigator a) => f a -> Strategy a leftmosttd :: (IsStrategy f, Navigator a) => f a -> Strategy a somewhere :: (IsStrategy f, Navigator a) => f a -> Strategy a somewhereWhen :: (IsStrategy g, Navigator a) => (a -> Bool) -> g a -> Strategy a -- | left-most innermost traversal. innermost :: (IsStrategy f, Navigator a) => f a -> Strategy a -- | left-most outermost traversal. outermost :: (IsStrategy f, Navigator a) => f a -> Strategy a ruleUp :: Navigator a => Rule a ruleDown :: Navigator a => Rule a ruleDownLast :: Navigator a => Rule a ruleLeft :: Navigator a => Rule a ruleRight :: Navigator a => Rule a -- | Returns a list of all strategy locations, paired with the label strategyLocations :: LabeledStrategy a -> [([Int], Id)] checkLocation :: Id -> LabeledStrategy a -> Bool subTaskLocation :: LabeledStrategy a -> Id -> Id -> Id nextTaskLocation :: LabeledStrategy a -> Id -> Id -> Id data Prefix a -- | Construct the empty prefix for a labeled strategy emptyPrefix :: IsStrategy f => f a -> a -> Prefix a -- | The error prefix (i.e., without a location in the strategy). noPrefix :: Prefix a -- | Construct a prefix for a path and a labeled strategy. The third -- argument is the current term. replayPath :: IsStrategy f => Path -> f a -> a -> ([Rule a], Prefix a) -- | Construct a prefix for a list of paths and a labeled strategy. The -- third argument is the current term. replayPaths :: IsStrategy f => [Path] -> f a -> a -> Prefix a -- | Construct a prefix for a path and a labeled strategy. The third -- argument is the initial term. replayStrategy :: (Monad m, IsStrategy f) => Path -> f a -> a -> m (a, Prefix a) -- | A path encodes a location in a strategy. Paths are represented as a -- list of integers and terms (the latter act as input for the dynamic -- strategies). data Path -- | The empty path. emptyPath :: Path readPath :: Monad m => String -> m Path readPaths :: Monad m => String -> m [Path] -- | Returns the current Path. prefixPaths :: Prefix a -> [Path] -- | Transforms the prefix such that only major steps are kept in the -- remaining strategy. majorPrefix :: Prefix a -> Prefix a isEmptyPrefix :: Prefix a -> Bool -- | Use a function as do-after hook for all rules in a labeled strategy, -- but also use the function beforehand cleanUpStrategy :: (a -> a) -> LabeledStrategy a -> LabeledStrategy a -- | Use a function as do-after hook for all rules in a labeled strategy cleanUpStrategyAfter :: (a -> a) -> LabeledStrategy a -> LabeledStrategy a -- | Returns a list of all major rules that are part of a labeled strategy rulesInStrategy :: IsStrategy f => f a -> [Rule a] -- | The Exercise record defines all the components that are needed -- for calculating feedback for one class of exercises. The fields of an -- exercise have to be consistent; consistency can be checked with the -- Ideas.Common.ExerciseTests module. module Ideas.Common.Exercise -- | For constructing an empty exercise, use function emptyExercise -- or makeExercise. data Exercise a NewExercise :: Id -> Status -> String -> Either String a -> a -> String -> Context a -> Context a -> Bool -> Context a -> Context a -> Bool -> Predicate a -> Predicate a -> LabeledStrategy (Context a) -> Bool -> [Rule (Context a)] -> Rule (Context a) -> Rule (Context a) -> Ordering -> [Constraint (Context a)] -> a -> ContextNavigator a -> Examples a -> Maybe (View Term a) -> Maybe (IsTypeable a) -> Map Id (Dynamic a) -> Exercise a -- | Identifier that uniquely determines the exercise: see HasId for -- how to use values with identifiers. [exerciseId] :: Exercise a -> Id -- | The status of the exercise. [status] :: Exercise a -> Status -- | Parser for expressions of the exercise class, which either results in -- an error (Left) or a result (Right). [parser] :: Exercise a -> String -> Either String a -- | Pretty-printer for expressions of the exercise class. Pretty-printing -- should be the inverse of parsing. [prettyPrinter] :: Exercise a -> a -> String -- | Tests wether two expressions (with their contexts) are semantically -- equivalent. Use withoutContext for defining the equivalence -- check when the context is not relevant. [equivalence] :: Exercise a -> Context a -> Context a -> Bool -- | Tests wether two expressions (with their contexts) are syntactically -- the same, or nearly so. Expressions that are similar must also be -- equivalent. Use withoutContext if the context is not relevant -- for the similarity check. [similarity] :: Exercise a -> Context a -> Context a -> Bool -- | Predicate suitable identifies which expressions can be solved by the -- strategy of the exercise class. It acts as the pre-condition of the -- strategy. [suitable] :: Exercise a -> Predicate a -- | Predicate ready checks if an expression is in a solved form (accepted -- as a final solution). It acts as the post-condition of the strategy. [ready] :: Exercise a -> Predicate a -- | The rewrite strategy that specifies how to solve an exercise. [strategy] :: Exercise a -> LabeledStrategy (Context a) -- | Is it possible to restart the rewrite strategy at any point in time? -- Restarting the strategy is needed when a student deviates from the -- strategy (detour). By default, restarting is assumed to be possible. [canBeRestarted] :: Exercise a -> Bool -- | Are there extra rules, possibly buggy, that do not appear in the -- strategy? Use ruleset to get all rules. [extraRules] :: Exercise a -> [Rule (Context a)] -- | The rule ordering is a tiebreaker in situations where more than one -- rule can be used (e.g. feedback services onefirst and derivation; -- other feedback services return all possible rules). [ruleOrdering] :: Exercise a -> Rule (Context a) -> Rule (Context a) -> Ordering -- | Constraints for constraint-based tutors. A constraint contains a -- relevance condition and a satisfaction condition. [constraints] :: Exercise a -> [Constraint (Context a)] -- | A navigator is needed for traversing the expression and for using the -- traversal strategy combinators. By default, an exercise has no -- navigator. [navigation] :: Exercise a -> a -> ContextNavigator a -- | A finite list of examples, each with an assigned difficulty. [examples] :: Exercise a -> Examples a -- | Conversion to and from the (generic) Term datatype. Needed for -- representing the expression in the OpenMath standard. [hasTermView] :: Exercise a -> Maybe (View Term a) -- | Representation of the type of expression: this provides a back door -- for exercise-specific functionality. [hasTypeable] :: Exercise a -> Maybe (IsTypeable a) -- | Extra exercise-specific properties, not used by the default feedback -- services. [properties] :: Exercise a -> Map Id (Dynamic a) -- | The emptyExercise constructor function provides sensible -- defaults for all fields of the Exercise record. emptyExercise :: Exercise a -- | In addition to the defaults of emptyExercise, this constructor -- sets the fields prettyPrinter, similarity, and -- hasTermView. makeExercise :: (Show a, Eq a, IsTerm a) => Exercise a -- | Pretty print a value in its context. prettyPrinterContext :: Exercise a -> Context a -> String -- | Checks if an expression is in a solved form. isReady :: Exercise a -> a -> Bool -- | Checks if the expression is suitable and can be solved by the -- strategy. isSuitable :: Exercise a -> a -> Bool -- | Returns a sorted list of rules, without duplicates. ruleset :: Exercise a -> [Rule (Context a)] -- | Finds a rule of an exercise based on its identifier. getRule :: Monad m => Exercise a -> Id -> m (Rule (Context a)) -- | Makes a rule ordering based on a list of values with identifiers -- (e.g., a list of rules). Rules with identifiers that are not in the -- list are considered after the rules in the list, and are sorted based -- on their identifier. ruleOrderingWith :: HasId b => [b] -> Rule a -> Rule a -> Ordering -- | Get all constraint violations violations :: Exercise a -> Context a -> [(Constraint (Context a), String)] -- | The status of an exercise class. data Status -- | A released exercise that has undergone some thorough testing Stable :: Status -- | A released exercise, possibly with some deficiencies Provisional :: Status -- | An exercise that is under development Alpha :: Status -- | An exercise for experimentation purposes only Experimental :: Status -- | An exercise with the status Stable or Provisional isPublic :: Exercise a -> Bool -- | An exercise that is not public isPrivate :: Exercise a -> Bool data Examples a data Difficulty VeryEasy :: Difficulty Easy :: Difficulty Medium :: Difficulty Difficult :: Difficulty VeryDifficult :: Difficulty -- | Parser for difficulty levels, which ignores non-alpha charactes -- (including spaces) and upper/lower case distinction. readDifficulty :: String -> Maybe Difficulty -- | List of examples with the same difficulty examplesFor :: Difficulty -> [a] -> Examples a -- | List of examples with their own difficulty examplesWithDifficulty :: [(Difficulty, a)] -> Examples a -- | Returns the examples of an exercise class lifted to a context. examplesContext :: Exercise a -> Examples (Context a) examplesAsList :: Exercise a -> [a] -- | An exercise generator for testing purposes (including corner cases); -- first generator only. testGenerator :: Exercise a -> Maybe (Gen a) -- | Returns a random exercise of a certain difficulty with some random -- number generator. The field randomExercise is used; if this -- is not defined (i.e., Nothing), one of the examples is used instead. randomTerm :: QCGen -> Exercise a -> Maybe Difficulty -> Maybe a -- | Returns a list of randomly generated terms of a certain difficulty. randomTerms :: QCGen -> Exercise a -> Maybe Difficulty -> [a] -- | Puts a value into a context with an empty environment. inContext :: Exercise a -> a -> Context a -- | Function for defining equivalence or similarity without taking the -- context into account. withoutContext :: (a -> a -> Bool) -> Context a -> Context a -> Bool -- | Encapsulates a type representation (use for hasTypeable field). useTypeable :: Typeable a => Maybe (IsTypeable a) castFrom :: (HasTypeable f, Typeable b) => f a -> a -> Maybe b castTo :: (HasTypeable f, Typeable a) => f b -> a -> Maybe b -- | Set an exercise-specific property (with a dynamic type) setProperty :: (IsId n, Typeable val) => n -> val -> Exercise a -> Exercise a -- | Get an exercise-specific property (of a dynamic type) getProperty :: (IsId n, Typeable val) => n -> Exercise a -> Maybe val -- | Set an exercise-specific property (with a dynamic type) that is -- parameterized over the exercise term. setPropertyF :: (IsId n, Typeable f) => n -> f a -> Exercise a -> Exercise a -- | Get an exercise-specific property (of a dynamic type) that is -- parameterized over the exercise term. getPropertyF :: (IsId n, Typeable f) => n -> Exercise a -> Maybe (f a) -- | Shows the default derivation for a given start term. The specified -- rule ordering is used for selection. showDerivation :: Exercise a -> a -> String -- | Shows all derivations for a given start term. Warning: there can be -- many derivations. showDerivations :: Exercise a -> a -> String -- | Prints the default derivation for a given start term. The specified -- rule ordering is used for selection. printDerivation :: Exercise a -> a -> IO () -- | Prints all derivations for a given start term. Warning: there can be -- many derivations. printDerivations :: Exercise a -> a -> IO () -- | Adds the difference of the environments in a derivation to the steps. -- Bindings with identifier location are ignored. This utility -- function is useful for printing derivations. diffEnvironment :: HasEnvironment a => Derivation s a -> Derivation (s, Environment) a defaultDerivation :: Exercise a -> a -> Maybe (Derivation (Rule (Context a), Environment) (Context a)) allDerivations :: Exercise a -> a -> [Derivation (Rule (Context a), Environment) (Context a)] instance GHC.Classes.Eq Ideas.Common.Exercise.Status instance GHC.Show.Show Ideas.Common.Exercise.Status instance GHC.Classes.Eq (Ideas.Common.Exercise.Exercise a) instance GHC.Classes.Ord (Ideas.Common.Exercise.Exercise a) instance Ideas.Common.Classes.Apply Ideas.Common.Exercise.Exercise instance Ideas.Common.Id.HasId (Ideas.Common.Exercise.Exercise a) instance Ideas.Utils.Typeable.HasTypeable Ideas.Common.Exercise.Exercise -- | Exports most from package Common module Ideas.Common.Library -- | The basic arrow class. -- -- Instances should satisfy the following laws: -- -- -- -- where -- --
--   assoc ((a,b),c) = (a,(b,c))
--   
-- -- The other combinators have sensible default definitions, which may be -- overridden for efficiency. class Category a => Arrow (a :: * -> * -> *) -- | Lift a function to an arrow. arr :: Arrow a => b -> c -> a b c -- | Send the first component of the input through the argument arrow, and -- copy the rest unchanged to the output. first :: Arrow a => a b c -> a (b, d) (c, d) -- | A mirror image of first. -- -- The default definition may be overridden with a more efficient version -- if desired. second :: Arrow a => a b c -> a (d, b) (d, c) -- | Split the input between the two argument arrows and combine their -- output. Note that this is in general not a functor. -- -- The default definition may be overridden with a more efficient version -- if desired. (***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c') -- | Fanout: send the input to both argument arrows and combine their -- output. -- -- The default definition may be overridden with a more efficient version -- if desired. (&&&) :: Arrow a => a b c -> a b c' -> a b (c, c') class Arrow a => ArrowZero (a :: * -> * -> *) zeroArrow :: ArrowZero a => a b c -- | A monoid on arrows. class ArrowZero a => ArrowPlus (a :: * -> * -> *) -- | An associative operation with identity zeroArrow. (<+>) :: ArrowPlus a => a b c -> a b c -> a b c -- | Choice, for arrows that support it. This class underlies the -- if and case constructs in arrow notation. -- -- Instances should satisfy the following laws: -- -- -- -- where -- --
--   assocsum (Left (Left x)) = Left x
--   assocsum (Left (Right y)) = Right (Left y)
--   assocsum (Right z) = Right (Right z)
--   
-- -- The other combinators have sensible default definitions, which may be -- overridden for efficiency. class Arrow a => ArrowChoice (a :: * -> * -> *) -- | Feed marked inputs through the argument arrow, passing the rest -- through unchanged to the output. left :: ArrowChoice a => a b c -> a Either b d Either c d -- | A mirror image of left. -- -- The default definition may be overridden with a more efficient version -- if desired. right :: ArrowChoice a => a b c -> a Either d b Either d c -- | Split the input between the two argument arrows, retagging and merging -- their outputs. Note that this is in general not a functor. -- -- The default definition may be overridden with a more efficient version -- if desired. (+++) :: ArrowChoice a => a b c -> a b' c' -> a Either b b' Either c c' -- | Fanin: Split the input between the two argument arrows and merge their -- outputs. -- -- The default definition may be overridden with a more efficient version -- if desired. (|||) :: ArrowChoice a => a b d -> a c d -> a Either b c d -- | Left-to-right composition (>>>) :: Category cat => cat a b -> cat b c -> cat a c infixr 1 >>> -- | Right-to-left composition (<<<) :: Category cat => cat b c -> cat a b -> cat a c infixr 1 <<< class Minor a minor :: Minor a => a -> a setMinor :: Minor a => Bool -> a -> a isMinor :: Minor a => a -> Bool isMajor :: Minor a => a -> Bool class Buggy a buggy :: Buggy a => a -> a setBuggy :: Buggy a => Bool -> a -> a isBuggy :: Buggy a => a -> Bool class BoolValue a => Boolean a (<&&>) :: Boolean a => a -> a -> a (<||>) :: Boolean a => a -> a -> a complement :: Boolean a => a -> a class BoolValue a true :: BoolValue a => a false :: BoolValue a => a fromBool :: BoolValue a => Bool -> a isTrue :: BoolValue a => a -> Bool isFalse :: BoolValue a => a -> Bool class Fix a fix :: Fix a => (a -> a) -> a class BiFunctor f biMap :: BiFunctor f => (a -> c) -> (b -> d) -> f a b -> f c d mapFirst :: BiFunctor f => (a -> b) -> f a c -> f b c mapSecond :: BiFunctor f => (b -> c) -> f a b -> f a c -- | Type class for bi-directional arrows. - should be used -- instead of arr from the arrow interface. Minimal complete -- definition: -. class Arrow arr => BiArrow arr (<->) :: BiArrow arr => (a -> b) -> (b -> a) -> arr a b (!->) :: BiArrow arr => (a -> b) -> arr a b (<-!) :: BiArrow arr => (b -> a) -> arr a b -- | Instances should satisfy the following law: getSingleton . -- singleton == Just class Container f singleton :: Container f => a -> f a getSingleton :: Container f => f a -> Maybe a -- | A type class for functors that can be applied to a value. -- Transformation, Rule, and Strategy are all instances of this type -- class. class Apply t applyAll :: Apply t => t a -> a -> [a] -- | Returns zero or one results apply :: Apply t => t a -> a -> Maybe a -- | Checks whether the functor is applicable (at least one result) applicable :: Apply t => t a -> a -> Bool -- | If not applicable, return the current value (as default) applyD :: Apply t => t a -> a -> a -- | Same as apply, except that the result (at most one) is returned in -- some monad applyM :: (Apply t, Monad m) => t a -> a -> m a applyList :: Apply t => [t a] -> a -> Maybe a mapBoth :: BiFunctor f => (a -> b) -> f a a -> f b b ands :: Boolean a => [a] -> a ors :: Boolean a => [a] -> a implies :: Boolean a => a -> a -> a equivalent :: Boolean a => a -> a -> a data Some f Some :: (f a) -> Some f readM :: (Monad m, Read a) => String -> m a -- | Type classfor accessing (and changing) the identifier of an entity. class HasId a getId :: HasId a => a -> Id changeId :: HasId a => (Id -> Id) -> a -> a -- | Type class for labeling entities with an identifier class HasId a => Identify a (@>) :: (Identify a, IsId n) => n -> a -> a -- | Type class IsId for constructing identifiers. Examples are -- newId "algebra.equation", newId ("a", "b", "c"), and -- newId () for the empty identifier. class IsId a newId :: IsId a => a -> Id concatId :: IsId a => [a] -> Id -- | Abstract data type for identifiers with a hierarchical name, carrying -- a description. The data type provides a fast comparison -- implementation. data Id -- | Appends two identifiers. Both parameters are overloaded. (#) :: (IsId a, IsId b) => a -> b -> Id infixr 8 # -- | Get the unqualified part of the identifier (i.e., last string). unqualified :: HasId a => a -> String -- | Get the list of qualifiers of the identifier (i.e., everything but the -- last string). qualifiers :: HasId a => a -> [String] -- | Get the qualified part of the identifier. If the identifier consists -- of more than one part, the parts are separated by a period -- (.). qualification :: HasId a => a -> String -- | Get the current description. description :: HasId a => a -> String -- | Give a description for the current entity. If there already is a -- description, both strings are combined. describe :: HasId a => String -> a -> a -- | Show the identifier. showId :: HasId a => a -> String -- | Compare two identifiers based on their names. Use compare for -- a fast ordering based on hash values. compareId :: HasId a => a -> a -> Ordering data ViewPackage [ViewPackage] :: (Show a, Show b, Eq a) => (String -> Maybe a) -> View a b -> ViewPackage class LiftView f liftView :: LiftView f => View a b -> f b -> f a liftViewIn :: LiftView f => View a (b, c) -> f b -> f a data Isomorphism a b data View a b -- | Minimal complete definition: toView or both match -- and build. class IsMatcher f => IsView f build :: IsView f => f a b -> b -> a toView :: IsView f => f a b -> View a b data Matcher a b class IsMatcher f match :: IsMatcher f => f a b -> a -> Maybe b matcher :: IsMatcher f => f a b -> Matcher a b -- | generalized monadic variant of match matchM :: (Monad m, IsMatcher f) => f a b -> a -> m b belongsTo :: IsMatcher f => a -> f a b -> Bool viewEquivalent :: (IsMatcher f, Eq b) => f a b -> a -> a -> Bool viewEquivalentWith :: IsMatcher f => (b -> b -> Bool) -> f a b -> a -> a -> Bool makeMatcher :: (a -> Maybe b) -> Matcher a b canonical :: IsView f => f a b -> a -> Maybe a canonicalWith :: IsView f => (b -> b) -> f a b -> a -> Maybe a canonicalWithM :: IsView f => (b -> Maybe b) -> f a b -> a -> Maybe a isCanonical :: (IsView f, Eq a) => f a b -> a -> Bool isCanonicalWith :: IsView f => (a -> a -> Bool) -> f a b -> a -> Bool simplify :: IsView f => f a b -> a -> a simplifyWith :: IsView f => (b -> b) -> f a b -> a -> a simplifyWithM :: IsView f => (b -> Maybe b) -> f a b -> a -> a makeView :: (a -> Maybe b) -> (b -> a) -> View a b matcherView :: Matcher a b -> (b -> a) -> View a b identity :: Category f => f a a inverse :: Isomorphism a b -> Isomorphism b a swapView :: Isomorphism (a, b) (b, a) -- | Specialized version of traverseView listView :: View a b -> View [a] [b] traverseView :: Traversable f => View a b -> View (f a) (f b) ($<) :: Traversable f => View a (f b) -> View b c -> View a (f c) propIdempotence :: (Show a, Eq a) => Gen a -> View a b -> Property propSoundness :: Show a => (a -> a -> Bool) -> Gen a -> View a c -> Property propNormalForm :: (Show a, Eq a) => Gen a -> View a b -> Property data Predicate a predicate :: (a -> Bool) -> Predicate a predicateView :: View a b -> Predicate a evalPredicate :: Predicate a -> a -> Bool data Difficulty VeryEasy :: Difficulty Easy :: Difficulty Medium :: Difficulty Difficult :: Difficulty VeryDifficult :: Difficulty data Examples a -- | List of examples with the same difficulty examplesFor :: Difficulty -> [a] -> Examples a -- | List of examples with their own difficulty examplesWithDifficulty :: [(Difficulty, a)] -> Examples a -- | Parser for difficulty levels, which ignores non-alpha charactes -- (including spaces) and upper/lower case distinction. readDifficulty :: String -> Maybe Difficulty data Constraint a makeConstraint :: IsId n => n -> (a -> Result ()) -> Constraint a isRelevant :: Constraint a -> a -> Bool -- | Satisfaction condition isSatisfied :: Constraint a -> a -> Bool -- | Satisfaction condition isViolated :: Constraint a -> a -> Maybe String -- | Turn errors into irrelevant results relevance :: Result a -> Result a castFrom :: (HasTypeable f, Typeable b) => f a -> a -> Maybe b castTo :: (HasTypeable f, Typeable a) => f b -> a -> Maybe b location :: Navigator a => a -> Location data Location toLocation :: [Int] -> Location top :: Navigator a => a -> a arity :: Navigator a => a -> Int class WithMetaVars a metaVar :: WithMetaVars a => Int -> a getMetaVar :: (WithMetaVars a, Monad m) => a -> m Int class WithVars a variable :: WithVars a => String -> a getVariable :: (WithVars a, Monad m) => a -> m String class WithFunctions a symbol :: WithFunctions a => Symbol -> a function :: WithFunctions a => Symbol -> [a] -> a getSymbol :: (WithFunctions a, Monad m) => a -> m Symbol getFunction :: (WithFunctions a, Monad m) => a -> m (Symbol, [a]) class IsTerm a toTerm :: IsTerm a => a -> Term toTermList :: IsTerm a => [a] -> Term fromTerm :: (IsTerm a, MonadPlus m) => Term -> m a fromTermList :: (IsTerm a, MonadPlus m) => Term -> m [a] data Term TVar :: String -> Term TCon :: Symbol -> [Term] -> Term TList :: [Term] -> Term TNum :: Integer -> Term TFloat :: Double -> Term TMeta :: Int -> Term data Symbol newSymbol :: IsId a => a -> Symbol makeAssociative :: Symbol -> Symbol termView :: IsTerm a => View Term a trueSymbol :: Symbol falseSymbol :: Symbol nothingSymbol :: Symbol fromTermM :: (Monad m, IsTerm a) => Term -> m a fromTermWith :: (Monad m, IsTerm a) => (Symbol -> [a] -> m a) -> Term -> m a isSymbol :: WithFunctions a => Symbol -> a -> Bool isFunction :: (WithFunctions a, Monad m) => Symbol -> a -> m [a] unary :: WithFunctions a => Symbol -> a -> a binary :: WithFunctions a => Symbol -> a -> a -> a ternary :: WithFunctions a => Symbol -> a -> a -> a -> a isUnary :: (WithFunctions a, Monad m) => Symbol -> a -> m a isBinary :: (WithFunctions a, Monad m) => Symbol -> a -> m (a, a) isVariable :: WithVars a => a -> Bool vars :: (Uniplate a, WithVars a) => a -> [String] varSet :: (Uniplate a, WithVars a) => a -> Set String hasVar :: (Uniplate a, WithVars a) => String -> a -> Bool withoutVar :: (Uniplate a, WithVars a) => String -> a -> Bool hasSomeVar :: (Uniplate a, WithVars a) => a -> Bool hasNoVar :: (Uniplate a, WithVars a) => a -> Bool variableView :: WithVars a => View a String isMetaVar :: WithMetaVars a => a -> Bool metaVars :: (Uniplate a, WithMetaVars a) => a -> [Int] metaVarSet :: (Uniplate a, WithMetaVars a) => a -> IntSet hasMetaVar :: (Uniplate a, WithMetaVars a) => Int -> a -> Bool nextMetaVar :: (Uniplate a, WithMetaVars a) => a -> Int toTermG :: Data a => a -> Term fromTermG :: (MonadPlus m, Data a) => Term -> m a class HasRefs a getRefs :: HasRefs a => a -> [Some Ref] allRefs :: HasRefs a => a -> [Some Ref] getRefIds :: HasRefs a => a -> [Id] class HasEnvironment env environment :: HasEnvironment env => env -> Environment setEnvironment :: HasEnvironment env => Environment -> env -> env deleteRef :: HasEnvironment env => Ref a -> env -> env insertRef :: HasEnvironment env => Ref a -> a -> env -> env changeRef :: HasEnvironment env => Ref a -> (a -> a) -> env -> env data Environment data Binding -- | A type class for types as references class (IsTerm a, Typeable a, Show a, Read a) => Reference a makeRef :: (Reference a, IsId n) => n -> Ref a makeRefList :: (Reference a, IsId n) => n -> Ref [a] -- | A data type for references (without a value) data Ref a mapRef :: Typeable b => Isomorphism a b -> Ref a -> Ref b makeBinding :: Ref a -> a -> Binding fromBinding :: Typeable a => Binding -> Maybe (Ref a, a) showValue :: Binding -> String getTermValue :: Binding -> Term makeEnvironment :: [Binding] -> Environment singleBinding :: Ref a -> a -> Environment bindings :: HasEnvironment env => env -> [Binding] noBindings :: HasEnvironment env => env -> Bool (?) :: HasEnvironment env => Ref a -> env -> Maybe a class (IsTerm a, Show a) => RuleBuilder t a | t -> a buildRuleSpec :: RuleBuilder t a => Int -> t -> RuleSpec Term class Different a different :: Different a => (a, a) data RewriteRule a data RuleSpec a (:~>) :: a -> a -> RuleSpec a makeRewriteRule :: (IsId n, RuleBuilder f a) => n -> f -> RewriteRule a termRewriteRule :: (IsId n, IsTerm a, Show a) => n -> RuleSpec Term -> RewriteRule a symbolMatcher :: Symbol -> SymbolMatch -> RewriteRule a -> RewriteRule a symbolBuilder :: Symbol -> ([Term] -> Term) -> RewriteRule a -> RewriteRule a showRewriteRule :: Bool -> RewriteRule a -> Maybe String metaInRewriteRule :: RewriteRule a -> [Int] renumberRewriteRule :: Int -> RewriteRule a -> RewriteRule a data Derivation s a emptyDerivation :: a -> Derivation s a prepend :: (a, s) -> Derivation s a -> Derivation s a extend :: Derivation s a -> (s, a) -> Derivation s a merge :: Eq a => Derivation s a -> Derivation s a -> Maybe (Derivation s a) mergeBy :: (a -> a -> Bool) -> Derivation s a -> Derivation s a -> Maybe (Derivation s a) mergeStep :: Derivation s a -> s -> Derivation s a -> Derivation s a derivationToList :: (s -> b) -> (a -> b) -> Derivation s a -> [b] derivationFromList :: Monad m => (b -> m s) -> (b -> m a) -> [b] -> m (Derivation s a) -- | Tests whether the derivation is empty isEmpty :: Derivation s a -> Bool -- | Returns the number of steps in a derivation derivationLength :: Derivation s a -> Int -- | All terms in a derivation terms :: Derivation s a -> [a] -- | All steps in a derivation steps :: Derivation s a -> [s] -- | The triples of a derivation, consisting of the before term, the step, -- and the after term. triples :: Derivation s a -> [(a, s, a)] firstTerm :: Derivation s a -> a lastTerm :: Derivation s a -> a lastStep :: Derivation s a -> Maybe s withoutLast :: Derivation s a -> Derivation s a updateSteps :: (a -> s -> a -> t) -> Derivation s a -> Derivation t a -- | Apply a monadic function to each term, and to each step derivationM :: Monad m => (s -> m ()) -> (a -> m ()) -> Derivation s a -> m () splitStep :: (s -> Bool) -> Derivation s a -> Maybe (Derivation s a, s, Derivation s a) data ContextNavigator a -- | Abstract data type for a context: a context stores an environment. data Context a fromContext :: Monad m => Context a -> m a fromContextWith :: Monad m => (a -> b) -> Context a -> m b fromContextWith2 :: Monad m => (a -> b -> c) -> Context a -> Context b -> m c -- | Construct a context newContext :: ContextNavigator a -> Context a noNavigator :: a -> ContextNavigator a navigator :: Uniplate a => a -> ContextNavigator a termNavigator :: IsTerm a => a -> ContextNavigator a contextView :: View (Context a) (a, Context a) -- | Lift a rule to operate on a term in a context liftToContext :: LiftView f => f a -> f (Context a) -- | Apply a function at top-level. Afterwards, try to return the focus to -- the old position applyTop :: (a -> a) -> Context a -> Context a use :: (LiftView f, IsTerm a, IsTerm b) => f a -> f (Context b) useC :: (LiftView f, IsTerm a, IsTerm b) => f (Context a) -> f (Context b) currentTerm :: Context a -> Maybe Term changeTerm :: (Term -> Maybe Term) -> Context a -> Maybe (Context a) currentInContext :: Context a -> Maybe a changeInContext :: (a -> a) -> Context a -> Context a replaceInContext :: a -> Context a -> Context a -- | A type class for constructing a transformation. If possible, -- makeTrans should be used. Use specialized constructor -- functions for disambiguation. class MakeTrans f makeTrans :: MakeTrans f => (a -> f b) -> Trans a b data Trans a b type Transformation a = Trans a a transPure :: (a -> b) -> Trans a b transMaybe :: (a -> Maybe b) -> Trans a b transList :: (a -> [b]) -> Trans a b transGuard :: (a -> Bool) -> Trans a a transRewrite :: RewriteRule a -> Trans a a readRef :: Ref a -> Trans x a readRefDefault :: a -> Ref a -> Trans x a readRefMaybe :: Ref a -> Trans x (Maybe a) writeRef :: Ref a -> Trans a a writeRef_ :: Ref a -> Trans a () writeRefMaybe :: Ref a -> Trans (Maybe a) () transUseEnvironment :: Trans a b -> Trans (a, Environment) (b, Environment) transLiftView :: View a b -> Transformation b -> Transformation a transLiftViewIn :: View a (b, c) -> Transformation b -> Transformation a transLiftContext :: Transformation a -> Transformation (Context a) transLiftContextIn :: Transformation (a, Environment) -> Transformation (Context a) transApply :: Trans a b -> a -> [(b, Environment)] transApplyWith :: Environment -> Trans a b -> a -> [(b, Environment)] getRewriteRules :: Trans a b -> [Some RewriteRule] data Recognizer a class Recognizable f recognizer :: Recognizable f => f a -> Recognizer a recognizeAll :: Recognizable f => f a -> a -> a -> [Environment] recognize :: Recognizable f => f a -> a -> a -> Maybe Environment recognizeTrans :: Recognizable f => f a -> Trans (a, a) () makeRecognizer :: (a -> a -> Bool) -> Recognizer a makeRecognizerTrans :: Trans (a, a) () -> Recognizer a -- | Abstract data type for representing rules data Rule a transformation :: Rule a -> Transformation a checkReferences :: Rule a -> Environment -> Maybe String makeRule :: (IsId n, MakeTrans f) => n -> (a -> f a) -> Rule a ruleMaybe :: IsId n => n -> (a -> Maybe a) -> Rule a ruleList :: IsId n => n -> (a -> [a]) -> Rule a ruleTrans :: IsId n => n -> Transformation a -> Rule a ruleRewrite :: RewriteRule a -> Rule a rewriteRule :: (IsId n, RuleBuilder f a) => n -> f -> Rule a rewriteRules :: (IsId n, RuleBuilder f a) => n -> [f] -> Rule a buggyRule :: (IsId n, MakeTrans f) => n -> (a -> f a) -> Rule a minorRule :: (IsId n, MakeTrans f) => n -> (a -> f a) -> Rule a -- | A special (minor) rule that is never applicable (i.e., this rule -- always fails) emptyRule :: IsId n => n -> Rule a -- | A special (minor) rule that always returns the identity idRule :: IsId n => n -> Rule a -- | A special (minor) rule that checks a predicate (and returns the -- identity if the predicate holds) checkRule :: IsId n => n -> (a -> Bool) -> Rule a isRewriteRule :: Rule a -> Bool siblingOf :: HasId b => b -> Rule a -> Rule a -- | Perform the function after the rule has been fired doAfter :: (a -> a) -> Rule a -> Rule a addRecognizer :: Recognizer a -> Rule a -> Rule a addRecognizerBool :: (a -> a -> Bool) -> Rule a -> Rule a addTransRecognizer :: (a -> a -> Bool) -> Rule a -> Rule a type ParamTrans i a = Trans (i, a) a input :: Ref i -> Trans (i, a) b -> Trans a b inputWith :: Trans a i -> Trans (i, a) b -> Trans a b transInput1 :: Ref i -> (i -> a -> Maybe b) -> Trans a b transInput2 :: Ref i1 -> Ref i2 -> (i1 -> i2 -> a -> Maybe b) -> Trans a b transInput3 :: Ref i1 -> Ref i2 -> Ref i3 -> (i1 -> i2 -> i3 -> a -> Maybe b) -> Trans a b transInputWith :: MakeTrans f => Trans a i -> (i -> a -> f b) -> Trans a b readRef2 :: Ref a -> Ref b -> Trans x (a, b) readRef3 :: Ref a -> Ref b -> Ref c -> Trans x (a, b, c) output :: Ref o -> Trans a (b, o) -> Trans a b outputWith :: Trans o x -> Trans a (b, o) -> Trans a b outputOnly :: Ref o -> Trans a o -> Trans a a outputOnly2 :: Ref o1 -> Ref o2 -> Trans a (o1, o2) -> Trans a a outputOnly3 :: Ref o1 -> Ref o2 -> Ref o3 -> Trans a (o1, o2, o3) -> Trans a a outputOnlyWith :: Trans o x -> Trans a o -> Trans a a writeRef2 :: Ref a -> Ref b -> Trans (a, b) (a, b) writeRef2_ :: Ref a -> Ref b -> Trans (a, b) () writeRef3 :: Ref a -> Ref b -> Ref c -> Trans (a, b, c) (a, b, c) writeRef3_ :: Ref a -> Ref b -> Ref c -> Trans (a, b, c) () parameter1 :: Ref a -> (a -> b -> Maybe b) -> ParamTrans a b parameter2 :: Ref a -> Ref b -> (a -> b -> c -> Maybe c) -> ParamTrans (a, b) c parameter3 :: Ref a -> Ref b -> Ref c -> (a -> b -> c -> d -> Maybe d) -> ParamTrans (a, b, c) d transRef :: Ref a -> Trans a a supplyParameters :: ParamTrans b a -> Trans a b -> Transformation (Context a) -- | A path encodes a location in a strategy. Paths are represented as a -- list of integers and terms (the latter act as input for the dynamic -- strategies). data Path data Prefix a -- | The error prefix (i.e., without a location in the strategy). noPrefix :: Prefix a isEmptyPrefix :: Prefix a -> Bool -- | Transforms the prefix such that only major steps are kept in the -- remaining strategy. majorPrefix :: Prefix a -> Prefix a -- | Returns the current Path. prefixPaths :: Prefix a -> [Path] -- | The empty path. emptyPath :: Path readPath :: Monad m => String -> m Path readPaths :: Monad m => String -> m [Path] -- | A strategy which is labeled with an identifier data LabeledStrategy a -- | Type class to turn values into strategies class IsStrategy f toStrategy :: IsStrategy f => f a -> Strategy a -- | Abstract data type for strategies data Strategy a -- | Labels a strategy with an identifier. Labels are used to identify -- substrategies and to specialize feedback messages. The first argument -- of label can be of type String, in which case the string -- is used as identifier (and not as description). label :: (IsId l, IsStrategy f) => l -> f a -> LabeledStrategy a -- | Construct the empty prefix for a labeled strategy emptyPrefix :: IsStrategy f => f a -> a -> Prefix a -- | Construct a prefix for a path and a labeled strategy. The third -- argument is the current term. replayPath :: IsStrategy f => Path -> f a -> a -> ([Rule a], Prefix a) -- | Construct a prefix for a list of paths and a labeled strategy. The -- third argument is the current term. replayPaths :: IsStrategy f => [Path] -> f a -> a -> Prefix a -- | Construct a prefix for a path and a labeled strategy. The third -- argument is the initial term. replayStrategy :: (Monad m, IsStrategy f) => Path -> f a -> a -> m (a, Prefix a) derivationList :: IsStrategy f => (Rule a -> Rule a -> Ordering) -> f a -> a -> [Derivation (Rule a, Environment) a] -- | Returns a list of all major rules that are part of a labeled strategy rulesInStrategy :: IsStrategy f => f a -> [Rule a] -- | Use a function as do-after hook for all rules in a labeled strategy, -- but also use the function beforehand cleanUpStrategy :: (a -> a) -> LabeledStrategy a -> LabeledStrategy a -- | Use a function as do-after hook for all rules in a labeled strategy cleanUpStrategyAfter :: (a -> a) -> LabeledStrategy a -> LabeledStrategy a checkLocation :: Id -> LabeledStrategy a -> Bool subTaskLocation :: LabeledStrategy a -> Id -> Id -> Id nextTaskLocation :: LabeledStrategy a -> Id -> Id -> Id -- | Returns a list of all strategy locations, paired with the label strategyLocations :: LabeledStrategy a -> [([Int], Id)] data ConfigAction Remove :: ConfigAction Reinsert :: ConfigAction Collapse :: ConfigAction Expand :: ConfigAction Hide :: ConfigAction Reveal :: ConfigAction data StrategyCfg byName :: HasId a => ConfigAction -> a -> StrategyCfg configure :: StrategyCfg -> LabeledStrategy a -> LabeledStrategy a configureS :: StrategyCfg -> Strategy a -> Strategy a isConfigId :: HasId a => a -> Bool remove :: IsStrategy f => f a -> Strategy a collapse :: IsStrategy f => f a -> Strategy a hide :: IsStrategy f => f a -> Strategy a -- | Apply a strategy at least once, but collapse into a single step multi :: (IsId l, IsStrategy f) => l -> f a -> Strategy a type DependencyGraph node key = [(node, key, [key])] -- | Put two strategies in sequence (first do this, then do that) (.*.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 5 .*. -- | Choose between the two strategies (either do this or do that) (.|.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 3 .|. -- | Interleave two strategies (.%.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 2 .%. -- | Alternate two strategies (.@.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 2 .@. -- | Prefixing a basic rule to a strategy atomically (!~>) :: IsStrategy f => Rule a -> f a -> Strategy a infixr 5 !~> -- | Initial prefixes (allows the strategy to stop succesfully at any time) inits :: IsStrategy f => f a -> Strategy a -- | The strategy that always succeeds (without doing anything) succeed :: Strategy a -- | Makes a strategy atomic (w.r.t. parallel composition) atomic :: IsStrategy f => f a -> Strategy a -- | Combines a list of alternative strategies choice :: IsStrategy f => [f a] -> Strategy a -- | Combines a list of strategies with left-preference preference :: IsStrategy f => [f a] -> Strategy a -- | Combines a list of strategies with left-biased choice orelse :: IsStrategy f => [f a] -> Strategy a -- | Merges a list of strategies (in parallel) interleave :: IsStrategy f => [f a] -> Strategy a -- | Allows all permutations of the list permute :: IsStrategy f => [f a] -> Strategy a -- | Repeat a strategy zero or more times (non-greedy) many :: IsStrategy f => f a -> Strategy a -- | Apply a certain strategy at least once (non-greedy) many1 :: IsStrategy f => f a -> Strategy a -- | Apply a certain strategy or do nothing (non-greedy) option :: IsStrategy f => f a -> Strategy a -- | Checks whether a predicate holds for the current term. The check is -- considered to be a minor step. check :: (a -> Bool) -> Strategy a -- | Apply a certain strategy at least once (greedy version of -- many1) repeat1 :: IsStrategy f => f a -> Strategy a -- | Apply a certain strategy if this is possible (greedy version of -- option) try :: IsStrategy f => f a -> Strategy a -- | Choose between the two strategies, with a preference for steps from -- the left hand-side strategy. (./.) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 4 ./. -- | Left-biased choice: if the left-operand strategy can be applied, do -- so. Otherwise, try the right-operand strategy (|>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy a infixr 4 |> -- | Repeat the strategy as long as the predicate holds while :: IsStrategy f => (a -> Bool) -> f a -> Strategy a -- | Apply the strategies from the list exhaustively (until this is no -- longer possible) exhaustive :: IsStrategy f => [f a] -> Strategy a -- | The structure of a dynamic strategy depends on the current term dynamic :: (IsId n, IsStrategy f, IsTerm a) => n -> (a -> f a) -> Strategy a -- | Create a strategy from a dependency graph with strategies as nodes -- Does not check for cycles dependencyGraph :: (IsStrategy f, Ord key) => DependencyGraph (f a) key -> Strategy a data Option a layer :: (IsStrategy f, Navigator a) => [Option a] -> f a -> Strategy a traverse :: (IsStrategy f, Navigator a) => [Option a] -> f a -> Strategy a topdown :: Option a bottomup :: Option a leftToRight :: Option a rightToLeft :: Option a leftmost :: Option a rightmost :: Option a traversalFilter :: (a -> Bool) -> Option a parentFilter :: Navigator a => (a -> [Int]) -> Option a fulltd :: (IsStrategy f, Navigator a) => f a -> Strategy a fullbu :: (IsStrategy f, Navigator a) => f a -> Strategy a oncetd :: (IsStrategy f, Navigator a) => f a -> Strategy a oncetdPref :: (IsStrategy f, Navigator a) => f a -> Strategy a oncebu :: (IsStrategy f, Navigator a) => f a -> Strategy a oncebuPref :: (IsStrategy f, Navigator a) => f a -> Strategy a leftmostbu :: (IsStrategy f, Navigator a) => f a -> Strategy a leftmosttd :: (IsStrategy f, Navigator a) => f a -> Strategy a somewhere :: (IsStrategy f, Navigator a) => f a -> Strategy a somewhereWhen :: (IsStrategy g, Navigator a) => (a -> Bool) -> g a -> Strategy a -- | left-most innermost traversal. innermost :: (IsStrategy f, Navigator a) => f a -> Strategy a -- | left-most outermost traversal. outermost :: (IsStrategy f, Navigator a) => f a -> Strategy a ruleUp :: Navigator a => Rule a ruleDown :: Navigator a => Rule a ruleDownLast :: Navigator a => Rule a ruleLeft :: Navigator a => Rule a ruleRight :: Navigator a => Rule a alternatives :: IsStrategy f => [f a] -> Strategy a -- | The status of an exercise class. data Status -- | A released exercise that has undergone some thorough testing Stable :: Status -- | A released exercise, possibly with some deficiencies Provisional :: Status -- | An exercise that is under development Alpha :: Status -- | An exercise for experimentation purposes only Experimental :: Status -- | For constructing an empty exercise, use function emptyExercise -- or makeExercise. data Exercise a NewExercise :: Id -> Status -> String -> Either String a -> a -> String -> Context a -> Context a -> Bool -> Context a -> Context a -> Bool -> Predicate a -> Predicate a -> LabeledStrategy (Context a) -> Bool -> [Rule (Context a)] -> Rule (Context a) -> Rule (Context a) -> Ordering -> [Constraint (Context a)] -> a -> ContextNavigator a -> Examples a -> Maybe (View Term a) -> Maybe (IsTypeable a) -> Map Id (Dynamic a) -> Exercise a -- | Identifier that uniquely determines the exercise: see HasId for -- how to use values with identifiers. [exerciseId] :: Exercise a -> Id -- | The status of the exercise. [status] :: Exercise a -> Status -- | Parser for expressions of the exercise class, which either results in -- an error (Left) or a result (Right). [parser] :: Exercise a -> String -> Either String a -- | Pretty-printer for expressions of the exercise class. Pretty-printing -- should be the inverse of parsing. [prettyPrinter] :: Exercise a -> a -> String -- | Tests wether two expressions (with their contexts) are semantically -- equivalent. Use withoutContext for defining the equivalence -- check when the context is not relevant. [equivalence] :: Exercise a -> Context a -> Context a -> Bool -- | Tests wether two expressions (with their contexts) are syntactically -- the same, or nearly so. Expressions that are similar must also be -- equivalent. Use withoutContext if the context is not relevant -- for the similarity check. [similarity] :: Exercise a -> Context a -> Context a -> Bool -- | Predicate suitable identifies which expressions can be solved by the -- strategy of the exercise class. It acts as the pre-condition of the -- strategy. [suitable] :: Exercise a -> Predicate a -- | Predicate ready checks if an expression is in a solved form (accepted -- as a final solution). It acts as the post-condition of the strategy. [ready] :: Exercise a -> Predicate a -- | The rewrite strategy that specifies how to solve an exercise. [strategy] :: Exercise a -> LabeledStrategy (Context a) -- | Is it possible to restart the rewrite strategy at any point in time? -- Restarting the strategy is needed when a student deviates from the -- strategy (detour). By default, restarting is assumed to be possible. [canBeRestarted] :: Exercise a -> Bool -- | Are there extra rules, possibly buggy, that do not appear in the -- strategy? Use ruleset to get all rules. [extraRules] :: Exercise a -> [Rule (Context a)] -- | The rule ordering is a tiebreaker in situations where more than one -- rule can be used (e.g. feedback services onefirst and derivation; -- other feedback services return all possible rules). [ruleOrdering] :: Exercise a -> Rule (Context a) -> Rule (Context a) -> Ordering -- | Constraints for constraint-based tutors. A constraint contains a -- relevance condition and a satisfaction condition. [constraints] :: Exercise a -> [Constraint (Context a)] -- | A navigator is needed for traversing the expression and for using the -- traversal strategy combinators. By default, an exercise has no -- navigator. [navigation] :: Exercise a -> a -> ContextNavigator a -- | A finite list of examples, each with an assigned difficulty. [examples] :: Exercise a -> Examples a -- | Conversion to and from the (generic) Term datatype. Needed for -- representing the expression in the OpenMath standard. [hasTermView] :: Exercise a -> Maybe (View Term a) -- | Representation of the type of expression: this provides a back door -- for exercise-specific functionality. [hasTypeable] :: Exercise a -> Maybe (IsTypeable a) -- | Extra exercise-specific properties, not used by the default feedback -- services. [properties] :: Exercise a -> Map Id (Dynamic a) -- | The emptyExercise constructor function provides sensible -- defaults for all fields of the Exercise record. emptyExercise :: Exercise a -- | In addition to the defaults of emptyExercise, this constructor -- sets the fields prettyPrinter, similarity, and -- hasTermView. makeExercise :: (Show a, Eq a, IsTerm a) => Exercise a -- | Pretty print a value in its context. prettyPrinterContext :: Exercise a -> Context a -> String -- | Checks if an expression is in a solved form. isReady :: Exercise a -> a -> Bool -- | Checks if the expression is suitable and can be solved by the -- strategy. isSuitable :: Exercise a -> a -> Bool -- | Returns a sorted list of rules, without duplicates. ruleset :: Exercise a -> [Rule (Context a)] -- | Finds a rule of an exercise based on its identifier. getRule :: Monad m => Exercise a -> Id -> m (Rule (Context a)) -- | Makes a rule ordering based on a list of values with identifiers -- (e.g., a list of rules). Rules with identifiers that are not in the -- list are considered after the rules in the list, and are sorted based -- on their identifier. ruleOrderingWith :: HasId b => [b] -> Rule a -> Rule a -> Ordering -- | Get all constraint violations violations :: Exercise a -> Context a -> [(Constraint (Context a), String)] -- | An exercise with the status Stable or Provisional isPublic :: Exercise a -> Bool -- | An exercise that is not public isPrivate :: Exercise a -> Bool -- | Returns the examples of an exercise class lifted to a context. examplesContext :: Exercise a -> Examples (Context a) examplesAsList :: Exercise a -> [a] -- | Returns a random exercise of a certain difficulty with some random -- number generator. The field randomExercise is used; if this -- is not defined (i.e., Nothing), one of the examples is used instead. randomTerm :: QCGen -> Exercise a -> Maybe Difficulty -> Maybe a -- | Returns a list of randomly generated terms of a certain difficulty. randomTerms :: QCGen -> Exercise a -> Maybe Difficulty -> [a] -- | An exercise generator for testing purposes (including corner cases); -- first generator only. testGenerator :: Exercise a -> Maybe (Gen a) -- | Puts a value into a context with an empty environment. inContext :: Exercise a -> a -> Context a -- | Function for defining equivalence or similarity without taking the -- context into account. withoutContext :: (a -> a -> Bool) -> Context a -> Context a -> Bool -- | Encapsulates a type representation (use for hasTypeable field). useTypeable :: Typeable a => Maybe (IsTypeable a) -- | Set an exercise-specific property (with a dynamic type) setProperty :: (IsId n, Typeable val) => n -> val -> Exercise a -> Exercise a -- | Set an exercise-specific property (with a dynamic type) that is -- parameterized over the exercise term. setPropertyF :: (IsId n, Typeable f) => n -> f a -> Exercise a -> Exercise a -- | Get an exercise-specific property (of a dynamic type) getProperty :: (IsId n, Typeable val) => n -> Exercise a -> Maybe val -- | Get an exercise-specific property (of a dynamic type) that is -- parameterized over the exercise term. getPropertyF :: (IsId n, Typeable f) => n -> Exercise a -> Maybe (f a) -- | Shows the default derivation for a given start term. The specified -- rule ordering is used for selection. showDerivation :: Exercise a -> a -> String -- | Shows all derivations for a given start term. Warning: there can be -- many derivations. showDerivations :: Exercise a -> a -> String -- | Prints the default derivation for a given start term. The specified -- rule ordering is used for selection. printDerivation :: Exercise a -> a -> IO () -- | Prints all derivations for a given start term. Warning: there can be -- many derivations. printDerivations :: Exercise a -> a -> IO () -- | Adds the difference of the environments in a derivation to the steps. -- Bindings with identifier location are ignored. This utility -- function is useful for printing derivations. diffEnvironment :: HasEnvironment a => Derivation s a -> Derivation (s, Environment) a defaultDerivation :: Exercise a -> a -> Maybe (Derivation (Rule (Context a), Environment) (Context a)) allDerivations :: Exercise a -> a -> [Derivation (Rule (Context a), Environment) (Context a)] -- | Alias for strategy combinator fail failS :: Strategy a -- | Alias for strategy combinator not notS :: IsStrategy f => f a -> Strategy a -- | Alias for strategy combinator repeat repeatS :: IsStrategy f => f a -> Strategy a -- | Alias for strategy combinator replicate replicateS :: IsStrategy f => Int -> f a -> Strategy a -- | Alias for strategy combinator sequence sequenceS :: IsStrategy f => [f a] -> Strategy a -- | Alias for strategy combinator until untilS :: IsStrategy f => (a -> Bool) -> f a -> Strategy a data Some f Some :: (f a) -> Some f -- | The information maintained for a learner trying to complete a -- derivation. module Ideas.Service.State data State a startState :: QCGen -> Exercise a -> Maybe String -> a -> State a makeState :: Exercise a -> Prefix (Context a) -> Context a -> State a makeNoState :: Exercise a -> Context a -> State a emptyStateContext :: Exercise a -> Context a -> State a emptyState :: Exercise a -> a -> State a exercise :: State a -> Exercise a statePrefix :: State a -> Prefix (Context a) stateContext :: State a -> Context a stateTerm :: State a -> a stateUser :: State a -> Maybe String stateSession :: State a -> Maybe String stateStartTerm :: State a -> Maybe String restart :: State a -> State a withoutPrefix :: State a -> Bool stateLabels :: State a -> [[Id]] suitable :: State a -> Bool finished :: State a -> Bool -- | The firsts set. firsts :: Firsts s => s -> [(Elem s, s)] microsteps :: State a -> [((Rule (Context a), Context a, Environment), State a)] instance GHC.Show.Show (Ideas.Service.State.State a) instance Ideas.Common.Id.HasId (Ideas.Service.State.State a) instance Ideas.Common.Environment.HasEnvironment (Ideas.Service.State.State a) instance Ideas.Common.Strategy.Sequence.Firsts (Ideas.Service.State.State a) -- | Abstract syntax for feedback scripts, and pretty-printer (Show -- instance) module Ideas.Service.FeedbackScript.Syntax data Script makeScript :: [Decl] -> Script scriptDecls :: Script -> [Decl] makeText :: String -> Text textItems :: Text -> [Text] data Decl NameSpace :: [Id] -> Decl Supports :: [Id] -> Decl Include :: [FilePath] -> Decl Simple :: DeclType -> [Id] -> Text -> Decl Guarded :: DeclType -> [Id] -> [(Condition, Text)] -> Decl data DeclType TextForId :: DeclType StringDecl :: DeclType Feedback :: DeclType data Text TextString :: String -> Text TextTerm :: Term -> Text TextRef :: Id -> Text TextEmpty :: Text (:<>:) :: Text -> Text -> Text data Condition RecognizedIs :: Id -> Condition MotivationIs :: Id -> Condition CondNot :: Condition -> Condition CondConst :: Bool -> Condition CondRef :: Id -> Condition includes :: Script -> [FilePath] feedbackDecl :: HasId a => a -> Text -> Decl textForIdDecl :: HasId a => a -> Text -> Decl instance GHC.Show.Show Ideas.Service.FeedbackScript.Syntax.Script instance GHC.Base.Semigroup Ideas.Service.FeedbackScript.Syntax.Script instance GHC.Base.Monoid Ideas.Service.FeedbackScript.Syntax.Script instance GHC.Show.Show Ideas.Service.FeedbackScript.Syntax.Decl instance GHC.Show.Show Ideas.Service.FeedbackScript.Syntax.Condition instance Data.Generics.Uniplate.Operations.Uniplate Ideas.Service.FeedbackScript.Syntax.Condition instance GHC.Show.Show Ideas.Service.FeedbackScript.Syntax.Text instance GHC.Base.Semigroup Ideas.Service.FeedbackScript.Syntax.Text instance GHC.Base.Monoid Ideas.Service.FeedbackScript.Syntax.Text instance Data.Generics.Uniplate.Operations.Uniplate Ideas.Service.FeedbackScript.Syntax.Text instance GHC.Show.Show Ideas.Service.FeedbackScript.Syntax.DeclType module Ideas.Service.Types data Service makeService :: String -> String -> (forall a. TypedValue (Type a)) -> Service deprecate :: Service -> Service serviceDeprecated :: Service -> Bool serviceFunction :: Service -> forall a. TypedValue (Type a) data TypeRep f t [Iso] :: Isomorphism t1 t2 -> TypeRep f t1 -> TypeRep f t2 [:->] :: TypeRep f t1 -> TypeRep f t2 -> TypeRep f (t1 -> t2) [IO] :: TypeRep f t -> TypeRep f (IO t) [Tag] :: String -> TypeRep f t1 -> TypeRep f t1 [List] :: TypeRep f t -> TypeRep f [t] [Pair] :: TypeRep f t1 -> TypeRep f t2 -> TypeRep f (t1, t2) [:|:] :: TypeRep f t1 -> TypeRep f t2 -> TypeRep f (Either t1 t2) [Unit] :: TypeRep f () [Const] :: f t -> TypeRep f t data Const a t [Service] :: Const a Service [Exercise] :: Const a (Exercise a) [Strategy] :: Const a (Strategy (Context a)) [State] :: Const a (State a) [Rule] :: Const a (Rule (Context a)) [Constraint] :: Const a (Constraint (Context a)) [Context] :: Const a (Context a) [Id] :: Const a Id [Location] :: Const a Location [Script] :: Const a Script [StratCfg] :: Const a StrategyCfg [Environment] :: Const a Environment [Term] :: Const a Term [Text] :: Const a Text [QCGen] :: Const a QCGen [Result] :: Const a Result [SomeExercise] :: Const a (Some Exercise) [MathML] :: Const a MathML [XML] :: Const a XML [Bool] :: Const a Bool [Int] :: Const a Int [String] :: Const a String type Type a = TypeRep (Const a) data TypedValue f [:::] :: t -> f t -> TypedValue f class Equal f equal :: Equal f => f a -> f b -> Maybe (a -> b) class ShowF f showF :: ShowF f => f a -> String equalM :: Monad m => Type a t1 -> Type a t2 -> m (t1 -> t2) tEnvironment :: Type a Environment tLocation :: Type a Location tRule :: Type a (Rule (Context a)) tConstraint :: Type a (Constraint (Context a)) tUnit :: Type a () tTuple3 :: Type a t1 -> Type a t2 -> Type a t3 -> Type a (t1, t2, t3) tTuple4 :: Type a t1 -> Type a t2 -> Type a t3 -> Type a t4 -> Type a (t1, t2, t3, t4) tTuple5 :: Type a t1 -> Type a t2 -> Type a t3 -> Type a t4 -> Type a t5 -> Type a (t1, t2, t3, t4, t5) tPair :: Type a t1 -> Type a t2 -> Type a (t1, t2) tTerm :: Type a Term tStrategy :: Type a (Strategy (Context a)) tTree :: Type a t -> Type a (Tree t) tState :: Type a (State a) tBool :: Type a Bool tMaybe :: Type a t -> Type a (Maybe t) tString :: Type a String tList :: Type a t -> Type a [t] tId :: Type a Id tService :: Type a Service tSomeExercise :: Type a (Some Exercise) tText :: Type a Text tDifficulty :: Type a Difficulty tUserId :: Type a String tContext :: Type a (Context a) tDerivation :: Type a t1 -> Type a t2 -> Type a (Derivation t1 t2) tError :: Type a t -> Type a (Either String t) (.->) :: Type a t1 -> Type a t2 -> Type a (t1 -> t2) infixr 5 .-> tIO :: Type a t -> Type a (IO t) tExercise :: Type a (Exercise a) tTestSuiteResult :: Type a Result tQCGen :: Type a QCGen tScript :: Type a Script tExamples :: Type a (Examples (Context a)) tStrategyCfg :: Type a StrategyCfg tMathML :: Type a MathML tInt :: Type a Int tXML :: Type a XML findValuesOfType :: Type a t -> TypedValue (Type a) -> [t] instance Ideas.Service.Types.ShowF f => Ideas.Service.Types.ShowF (Ideas.Service.Types.TypeRep f) instance Ideas.Service.Types.ShowF f => GHC.Show.Show (Ideas.Service.Types.TypeRep f t) instance GHC.Show.Show (Ideas.Service.Types.Const a t) instance Ideas.Service.Types.ShowF (Ideas.Service.Types.Const a) instance GHC.Show.Show Ideas.Service.Types.Service instance Ideas.Common.Id.HasId Ideas.Service.Types.Service instance Ideas.Service.Types.Equal (Ideas.Service.Types.Const a) instance GHC.Show.Show (Ideas.Service.Types.TypedValue (Ideas.Service.Types.Const a)) instance Ideas.Service.Types.Equal f => Ideas.Service.Types.Equal (Ideas.Service.Types.TypeRep f) instance GHC.Show.Show (Ideas.Service.Types.TypedValue f) => GHC.Show.Show (Ideas.Service.Types.TypedValue (Ideas.Service.Types.TypeRep f)) module Ideas.Service.ProblemDecomposition problemDecomposition :: Maybe Id -> State a -> Maybe (Answer a) -> Either String (Reply a) data Reply a Ok :: Id -> (State a) -> Reply a Incorrect :: Bool -> Id -> (State a) -> Environment -> Reply a data Answer a tAnswer :: Type a (Answer a) tReply :: Type a (Reply a) -- | Simple parser for feedback scripts module Ideas.Service.FeedbackScript.Parser parseScript :: FilePath -> IO Script parseScriptSafe :: FilePath -> IO Script data Script module Ideas.Service.DomainReasoner data DomainReasoner DR :: Id -> [Some Exercise] -> [Service] -> [ViewPackage] -> [(Id, Id)] -> [(Id, FilePath)] -> TestSuite -> String -> String -> DomainReasoner [reasonerId] :: DomainReasoner -> Id [exercises] :: DomainReasoner -> [Some Exercise] [services] :: DomainReasoner -> [Service] [views] :: DomainReasoner -> [ViewPackage] [aliases] :: DomainReasoner -> [(Id, Id)] [scripts] :: DomainReasoner -> [(Id, FilePath)] [testSuite] :: DomainReasoner -> TestSuite [version] :: DomainReasoner -> String [fullVersion] :: DomainReasoner -> String tDomainReasoner :: Type a DomainReasoner newDomainReasoner :: IsId a => a -> DomainReasoner exercisesSorted :: DomainReasoner -> [Some Exercise] servicesSorted :: DomainReasoner -> [Service] findExercise :: Monad m => DomainReasoner -> Id -> m (Some Exercise) findService :: Monad m => DomainReasoner -> Id -> m Service defaultScript :: DomainReasoner -> Id -> IO Script instance GHC.Base.Semigroup Ideas.Service.DomainReasoner.DomainReasoner instance GHC.Base.Monoid Ideas.Service.DomainReasoner.DomainReasoner instance Ideas.Common.Id.HasId Ideas.Service.DomainReasoner.DomainReasoner module Ideas.Service.BasicServices stepsremaining :: State a -> Either String Int findbuggyrules :: State a -> Context a -> [(Rule (Context a), Location, Environment)] allfirsts :: State a -> Either String [(StepInfo a, State a)] solution :: Maybe StrategyCfg -> State a -> Either String (Derivation (Rule (Context a), Environment) (Context a)) solutionMaxSteps :: Int -> Maybe StrategyCfg -> State a -> Either String (Derivation (Rule (Context a), Environment) (Context a)) onefirst :: State a -> Either String (StepInfo a, State a) onefinal :: State a -> Either String (Context a) applicable :: Location -> State a -> [Rule (Context a)] allapplications :: State a -> [(Rule (Context a), Location, State a)] apply :: Rule (Context a) -> Location -> Environment -> State a -> Either String (State a) generate :: QCGen -> Exercise a -> Maybe Difficulty -> Maybe String -> Either String (State a) create :: QCGen -> Exercise a -> String -> Maybe String -> Either String (State a) type StepInfo a = (Rule (Context a), Location, Environment) tStepInfo :: Type a (StepInfo a) exampleDerivations :: Exercise a -> Either String [Derivation (Rule (Context a), Environment) (Context a)] recognizeRule :: Exercise a -> Rule (Context a) -> Context a -> Context a -> [(Location, Environment)] -- | Diagnose a term submitted by a student module Ideas.Service.Diagnose data Diagnosis a SyntaxError :: String -> Diagnosis a Buggy :: Environment -> (Rule (Context a)) -> Diagnosis a NotEquivalent :: String -> Diagnosis a Similar :: Bool -> (State a) -> Diagnosis a WrongRule :: Bool -> (State a) -> (Maybe (Rule (Context a))) -> Diagnosis a Expected :: Bool -> (State a) -> (Rule (Context a)) -> Diagnosis a Detour :: Bool -> (State a) -> Environment -> (Rule (Context a)) -> Diagnosis a Correct :: Bool -> (State a) -> Diagnosis a Unknown :: Bool -> (State a) -> Diagnosis a tDiagnosis :: Type a (Diagnosis a) diagnose :: State a -> Context a -> Maybe Id -> Diagnosis a getState :: Diagnosis a -> Maybe (State a) getStateAndReady :: Diagnosis a -> Maybe (State a, Bool) difference :: Exercise a -> a -> a -> Maybe (a, a) instance GHC.Show.Show (Ideas.Service.Diagnose.Diagnosis a) -- | Diagnose a term submitted by a student. Deprecated (see diagnose -- service). module Ideas.Service.Submit submit :: State a -> Context a -> Result a data Result a Buggy :: [Rule (Context a)] -> Result a NotEquivalent :: String -> Result a Ok :: [Rule (Context a)] -> (State a) -> Result a Detour :: [Rule (Context a)] -> (State a) -> Result a Unknown :: (State a) -> Result a tResult :: Type a (Result a) getState :: Result a -> Maybe (State a) -- | Run a feedbackscript module Ideas.Service.FeedbackScript.Run data Script data Environment a Env :: Bool -> Maybe (Rule (Context a)) -> Maybe (Rule (Context a)) -> Maybe (Rule (Context a)) -> Maybe (String, String) -> Maybe Term -> Maybe Term -> Maybe String -> Environment a [oldReady] :: Environment a -> Bool [expected] :: Environment a -> Maybe (Rule (Context a)) [recognized] :: Environment a -> Maybe (Rule (Context a)) [motivation] :: Environment a -> Maybe (Rule (Context a)) [diffPair] :: Environment a -> Maybe (String, String) [before] :: Environment a -> Maybe Term [after] :: Environment a -> Maybe Term [afterText] :: Environment a -> Maybe String newEnvironment :: State a -> Maybe (Rule (Context a)) -> Environment a feedbackDiagnosis :: Diagnosis a -> Environment a -> Script -> Text feedbackHint :: Id -> Environment a -> Script -> Text feedbackHints :: Id -> [((Rule (Context a), b, c), State a)] -> State a -> Maybe (Rule (Context a)) -> Script -> [Text] ruleToString :: Environment a -> Script -> Rule b -> String feedbackIds :: [Id] attributeIds :: [Id] conditionIds :: [Id] eval :: Environment a -> Script -> Either Id Text -> Maybe Text module Ideas.Service.FeedbackText data Message tMessage :: Type a Message accept :: Message -> Maybe Bool text :: Message -> Text onefirsttext :: Script -> State a -> Maybe String -> (Message, Maybe (State a)) submittext :: Script -> State a -> String -> (Message, State a) derivationtext :: Script -> State a -> Either String (Derivation String (Context a)) feedbacktext :: Script -> State a -> Context a -> Maybe Id -> (Message, State a) -- | Analysis of a feedbackscript module Ideas.Service.FeedbackScript.Analysis makeScriptFor :: IsId a => DomainReasoner -> a -> IO () parseAndAnalyzeScript :: DomainReasoner -> FilePath -> IO () analyzeScript :: [Some Exercise] -> Script -> [Message] data Message UnknownExercise :: Id -> Message UnknownFeedback :: Id -> Message FeedbackUndefined :: Id -> Message NoTextForRule :: Id -> Id -> Message UnknownAttribute :: Id -> Message UnknownCondAttr :: Id -> Message instance GHC.Show.Show Ideas.Service.FeedbackScript.Analysis.Message module Ideas.Encoding.RulePresenter ruleToHTML :: Some Exercise -> Rule a -> HTMLBuilder module Ideas.Encoding.Request data Request Request :: Maybe Id -> Maybe Id -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe Schema -> Maybe Int -> Maybe DataFormat -> [Encoding] -> Request [serviceId] :: Request -> Maybe Id [exerciseId] :: Request -> Maybe Id [source] :: Request -> Maybe String [feedbackScript] :: Request -> Maybe String [requestInfo] :: Request -> Maybe String [cgiBinary] :: Request -> Maybe String [logSchema] :: Request -> Maybe Schema [randomSeed] :: Request -> Maybe Int [dataformat] :: Request -> Maybe DataFormat [encoding] :: Request -> [Encoding] data Schema V1 :: Schema V2 :: Schema NoLogging :: Schema readSchema :: Monad m => String -> m Schema data DataFormat XML :: DataFormat JSON :: DataFormat data Encoding EncHTML :: Encoding EncOpenMath :: Encoding EncString :: Encoding EncCompact :: Encoding EncPretty :: Encoding EncJSON :: Encoding htmlOutput :: Request -> Bool compactOutput :: Request -> Bool useOpenMath :: Request -> Bool useJSONTerm :: Request -> Bool useLogging :: Request -> Bool discoverDataFormat :: Monad m => String -> m DataFormat readEncoding :: Monad m => String -> m [Encoding] instance GHC.Classes.Eq Ideas.Encoding.Request.Encoding instance GHC.Show.Show Ideas.Encoding.Request.DataFormat instance GHC.Classes.Eq Ideas.Encoding.Request.Schema instance GHC.Show.Show Ideas.Encoding.Request.Schema instance GHC.Base.Semigroup Ideas.Encoding.Request.Request instance GHC.Base.Monoid Ideas.Encoding.Request.Request instance GHC.Show.Show Ideas.Encoding.Request.Encoding -- | Facilities to create a log database module Ideas.Encoding.Logging -- | The Record datatype is based on the Ideas Request Logging Schema -- version 2. data Record Record :: Bool -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> Time -> Diff -> String -> String -> String -> String -> String -> String -> String -> String -> Record [useLogging] :: Record -> Bool [service] :: Record -> String [exerciseid] :: Record -> String [source] :: Record -> String [script] :: Record -> String [requestinfo] :: Record -> String [dataformat] :: Record -> String [encoding] :: Record -> String [userid] :: Record -> String [sessionid] :: Record -> String [taskid] :: Record -> String [time] :: Record -> Time [responsetime] :: Record -> Diff [ipaddress] :: Record -> String [binary] :: Record -> String [version] :: Record -> String [errormsg] :: Record -> String [serviceinfo] :: Record -> String [ruleid] :: Record -> String [input] :: Record -> String [output] :: Record -> String -- | Add record information from the Request datatype addRequest :: Request -> Record -> Record -- | Add record information from the state (userid, sessionid, taskid) addState :: State a -> Record -> Record data LogRef makeLogRef :: FilePath -> Schema -> IO LogRef defaultLogRef :: IO LogRef enableLogging :: LogRef -> IO () disableLogging :: LogRef -> IO () changeLog :: LogRef -> (Record -> Record) -> IO () logEnabled :: Bool logRecord :: LogRef -> IO () logRecordWith :: IConnection c => LogRef -> c -> IO () printLog :: LogRef -> IO () selectFrom :: FilePath -> String -> [String] -> ([String] -> IO a) -> IO [a] getRecord :: LogRef -> IO Record getFilePath :: LogRef -> Maybe FilePath instance GHC.Show.Show Ideas.Encoding.Logging.Record instance GHC.Base.Semigroup Ideas.Encoding.Logging.LogRef instance GHC.Base.Monoid Ideas.Encoding.Logging.LogRef -- | Command-Line Options module Ideas.Main.CmdLineOptions data CmdLineOption Version :: CmdLineOption Help :: CmdLineOption PrintLog :: CmdLineOption InputFile :: String -> CmdLineOption Rerun :: String -> CmdLineOption Test :: FilePath -> CmdLineOption MakeScriptFor :: String -> CmdLineOption AnalyzeScript :: FilePath -> CmdLineOption getCmdLineOptions :: IO [CmdLineOption] versionText :: String helpText :: String shortVersion :: String fullVersion :: String instance GHC.Classes.Eq Ideas.Main.CmdLineOptions.CmdLineOption module Ideas.Encoding.Options data Options makeOptions :: DomainReasoner -> Request -> IO Options optionBaseUrl :: String -> Options -> Options script :: Options -> Script request :: Options -> Request qcGen :: Options -> Maybe QCGen baseUrl :: Options -> Maybe String maxTime :: Options -> Maybe Int logRef :: Options -> LogRef cgiBin :: Options -> Maybe String optionCgiBin :: String -> Options -> Options optionHtml :: Options -> Options instance GHC.Base.Semigroup Ideas.Encoding.Options.Options instance GHC.Base.Monoid Ideas.Encoding.Options.Options module Ideas.Encoding.OpenMathSupport toOpenMath :: Monad m => Exercise a -> a -> m OMOBJ fromOpenMath :: MonadPlus m => Exercise a -> OMOBJ -> m a noMixedFractions :: OMOBJ -> OMOBJ toOMOBJ :: IsTerm a => a -> OMOBJ fromOMOBJ :: (MonadPlus m, IsTerm a) => OMOBJ -> m a module Ideas.Encoding.RulesInfo rulesInfoXML :: Exercise a -> (a -> XMLBuilder) -> XMLBuilder rewriteRuleToFMP :: Bool -> RewriteRule a -> FMP collectExamples :: Exercise a -> ExampleMap a type ExampleMap a = Map Id [(a, a)] module Ideas.Encoding.Encoder getExercise :: DecoderX a s (Exercise a) getOptions :: DecoderX a s Options getRequest :: DecoderX a s Request withExercise :: (Exercise a -> DecoderX a s t) -> DecoderX a s t getBaseUrl :: DecoderX a s String getQCGen :: DecoderX a s QCGen getScript :: DecoderX a s Script (//) :: Decoder env s a -> s -> Decoder env s2 a withJSONTerm :: (Bool -> DecoderX a s t) -> DecoderX a s t withOpenMath :: (Bool -> DecoderX a s t) -> DecoderX a s t hasJSONView :: Exercise a -> Maybe (View JSON a) addJSONView :: View JSON a -> Exercise a -> Exercise a jsonEncoding :: InJSON a => Exercise a -> Exercise a termToJSON :: Term -> JSON jsonToTerm :: JSON -> Term hasLatexEncoding :: Exercise a -> Bool -- | Uses exercise pretty-printer in case latex encoding is missing. latexPrinter :: Exercise a -> a -> Latex -- | Uses exercise pretty-printer in case latex encoding is missing. latexPrinterContext :: Exercise a -> Context a -> Latex latexEncoding :: ToLatex a => Exercise a -> Exercise a latexEncodingWith :: (a -> Latex) -> Exercise a -> Exercise a type EncoderX a = Encoder (Exercise a, Options) type TypedEncoder a b = TypedValue (Type a) -> EncoderX a b () :: (t -> EncoderX a b, Type a t) -> TypedEncoder a b -> TypedEncoder a b infixr 5 encodeTyped :: (t -> EncoderX a b) -> Type a t -> TypedEncoder a b type DecoderX a = Decoder (Exercise a, Options) type TypedDecoder a s = forall t. Type a t -> Decoder (Exercise a, Options) s t module Ideas.Encoding.Evaluator data Evaluator a b c Evaluator :: (TypedDecoder a b) -> (TypedEncoder a c) -> Evaluator a b c evalService :: Exercise a -> Options -> Evaluator a b c -> Service -> b -> IO c -- | Services using XML notation module Ideas.Encoding.EncoderXML type XMLEncoder a = EncoderX a XMLBuilder xmlEncoder :: TypedEncoder a XMLBuilder encodeState :: State a -> XMLEncoder a -- | Manages links to information module Ideas.Encoding.LinkManager data LinkManager LinkManager :: String -> String -> String -> String -> String -> String -> String -> String -> Service -> String -> forall a. Exercise a -> String -> forall a. Exercise a -> String -> forall a. Exercise a -> String -> forall a. Exercise a -> String -> forall a. Exercise a -> String -> forall a. Exercise a -> String -> forall a. Exercise a -> Rule (Context a) -> String -> forall a. Exercise a -> String -> forall a. Exercise a -> Difficulty -> String -> forall a. State a -> String -> forall a. State a -> String -> forall a. State a -> String -> forall a. State a -> String -> forall a. State a -> String -> LinkManager [urlForCSS] :: LinkManager -> String -> String [urlForImage] :: LinkManager -> String -> String [urlForRequest] :: LinkManager -> String [urlForIndex] :: LinkManager -> String [urlForExercises] :: LinkManager -> String [urlForServices] :: LinkManager -> String [urlForService] :: LinkManager -> Service -> String [urlForExercise] :: LinkManager -> forall a. Exercise a -> String [urlForStrategy] :: LinkManager -> forall a. Exercise a -> String [urlForRules] :: LinkManager -> forall a. Exercise a -> String [urlForConstraints] :: LinkManager -> forall a. Exercise a -> String [urlForExamples] :: LinkManager -> forall a. Exercise a -> String [urlForDerivations] :: LinkManager -> forall a. Exercise a -> String [urlForRule] :: LinkManager -> forall a. Exercise a -> Rule (Context a) -> String [urlForTestReport] :: LinkManager -> forall a. Exercise a -> String [urlForRandomExample] :: LinkManager -> forall a. Exercise a -> Difficulty -> String [urlForState] :: LinkManager -> forall a. State a -> String [urlForFirsts] :: LinkManager -> forall a. State a -> String [urlForApplications] :: LinkManager -> forall a. State a -> String [urlForDerivation] :: LinkManager -> forall a. State a -> String [urlForMicrosteps] :: LinkManager -> forall a. State a -> String makeLinkManager :: String -> String -> LinkManager stateToXML :: State a -> XMLBuilder linkToIndex :: LinkManager -> HTMLBuilder -> HTMLBuilder linkToExercises :: LinkManager -> HTMLBuilder -> HTMLBuilder linkToServices :: LinkManager -> HTMLBuilder -> HTMLBuilder linkToService :: LinkManager -> Service -> HTMLBuilder -> HTMLBuilder linkToExercise :: LinkManager -> Exercise a -> HTMLBuilder -> HTMLBuilder linkToStrategy :: LinkManager -> Exercise a -> HTMLBuilder -> HTMLBuilder linkToRules :: LinkManager -> Exercise a -> HTMLBuilder -> HTMLBuilder linkToExamples :: LinkManager -> Exercise a -> HTMLBuilder -> HTMLBuilder linkToDerivations :: LinkManager -> Exercise a -> HTMLBuilder -> HTMLBuilder linkToRule :: LinkManager -> Exercise a -> Rule (Context a) -> HTMLBuilder -> HTMLBuilder linkToRandomExample :: LinkManager -> Exercise a -> Difficulty -> HTMLBuilder -> HTMLBuilder linkToTestReport :: LinkManager -> Exercise a -> HTMLBuilder -> HTMLBuilder linkToState :: LinkManager -> State a -> HTMLBuilder -> HTMLBuilder linkToFirsts :: LinkManager -> State a -> HTMLBuilder -> HTMLBuilder linkToApplications :: LinkManager -> State a -> HTMLBuilder -> HTMLBuilder linkToDerivation :: LinkManager -> State a -> HTMLBuilder -> HTMLBuilder linkToMicrosteps :: LinkManager -> State a -> HTMLBuilder -> HTMLBuilder escapeInURL :: String -> String -- | Services using JSON notation module Ideas.Encoding.EncoderJSON jsonEncoder :: TypedEncoder a JSON -- | Encoding in HTML module Ideas.Encoding.EncoderHTML type HTMLEncoder a = EncoderX a HTMLBuilder htmlEncoder :: DomainReasoner -> TypedEncoder a HTMLPage -- | Services using XML notation module Ideas.Encoding.DecoderXML type XMLDecoder a t = DecoderX a XML t xmlDecoder :: TypedDecoder a XML -- | Services using XML notation module Ideas.Encoding.ModeXML processXML :: Options -> DomainReasoner -> String -> IO (Request, String, String) -- | Services using JSON notation module Ideas.Encoding.DecoderJSON type JSONDecoder a t = DecoderX a JSON t jsonDecoder :: TypedDecoder a JSON -- | Services using JSON notation module Ideas.Encoding.ModeJSON processJSON :: Options -> DomainReasoner -> String -> IO (Request, String, String) module Ideas.Common.ExerciseTests checkExercise :: Exercise a -> IO () exerciseTestSuite :: QCGen -> Exercise a -> TestSuite data ShowAs a S :: a -> String -> a -> ShowAs a [showS] :: ShowAs a -> a -> String [fromS] :: ShowAs a -> a showAs :: (a -> String) -> Gen a -> Gen (ShowAs a) checkParserPretty :: (a -> a -> Bool) -> (String -> Either String a) -> (a -> String) -> a -> Bool checkParserPrettyEx :: Exercise a -> Context a -> Bool propRule :: Show a => (a -> a -> Bool) -> Rule a -> Gen a -> Property checkExamples :: QCGen -> Exercise a -> TestSuite checksForTerm :: Bool -> QCGen -> Exercise a -> a -> [TestSuite] checksForDerivation :: Exercise a -> Derivation (Rule (Context a), Environment) (Context a) -> [TestSuite] instance GHC.Show.Show (Ideas.Common.ExerciseTests.ShowAs a) module Ideas.Service.ServiceList serviceList :: [Service] metaServiceList :: DomainReasoner -> [Service] -- | Main module for feedback services module Ideas.Main.Default defaultMain :: DomainReasoner -> IO () defaultMainWith :: Options -> DomainReasoner -> IO () defaultCGI :: Options -> DomainReasoner -> IO () serviceList :: [Service] metaServiceList :: DomainReasoner -> [Service] data Service