UserRulesHetCATS.hs revision 73dfcef93ee2ba07fedf4f3c74bace31853d1b9f
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel HausmannModule : $Header$
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel HausmannCopyright : (c) K. L�ttich, C. Maeder and Uni Bremen 2002-2006
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel HausmannLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel HausmannMaintainer : maeder@tzi.de
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel HausmannStability : provisional
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel HausmannPortability : portable
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmanngenerate ShATermConvertible instances
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmannmodule UserRulesHetCATS (hetcatsrules) where
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmannimport RuleUtils -- gives some examples
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmannhetcatsrules :: [RuleDef]
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmannhetcatsrules = [ ("ShATermConvertible", shatermfn, "", "", Nothing)
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmann , ("Typeable", typeablefn, "", "", Nothing)
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmann , ("UpPos", updateposfn, "", "", Nothing)]
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmann-- useful helper things
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel HausmannaddPrime doc = doc <> char '\''
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel HausmannppCons b vs = let c = ppCons' b vs in
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmann if null vs then c else parens c
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel HausmannppCons' b vs = fsep $ text (constructor b) : vs
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmann-- begin of PosItem derivation
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmannupdateposfn dat =
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmann if any ((elem posLC) . types) (body dat) then
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmann instanceSkeleton "PosItem" [ (makeGetPosFn, empty) ] dat
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel HausmannposLC = Con "Range"
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel HausmannmakeGetPosFn b =
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmann let (e, vs) = mapAccumL accFun empty (types b)
6a4fa2d53294f484fa8788a75656eff4ad1fd703Daniel Hausmann accFun d t = if isEmpty d && t == posLC