diff options
author | Jed Barber <jjbarber@y7mail.com> | 2012-05-15 01:06:39 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2012-05-15 01:07:55 +1000 |
commit | 19ca657d6b247c1acab1329ccf0c54d896178c87 (patch) | |
tree | cdd8d0440c1697b3d328f7f88bac1931dcac8bbc | |
parent | 7a0eb21089bc60cf779469d04fe35632aec43f0e (diff) |
Fixed a number of compilation errors
-rw-r--r-- | Parse.hs | 13 | ||||
-rw-r--r-- | Term.hs | 19 | ||||
-rw-r--r-- | TypeVar.hs | 9 |
3 files changed, 29 insertions, 12 deletions
@@ -1,3 +1,14 @@ +module Parse ( + getLines, + stripReturn, + removeEscChars, + removeQuotes, + separateBy, + isComment, + isNumber, + isName + ) where + import Control.Monad( liftM ) import qualified Data.Char as Char @@ -22,7 +33,7 @@ removeQuotes :: String -> String removeQuotes = init . tail -separateBy :: String -> Char -> [String] +separateBy :: Char -> String -> [String] separateBy char list = let f = (\x -> if (x == char) then ' ' @@ -5,9 +5,11 @@ module Term ( alphaConvert, alphaConvertList, substitute, - containsVars, + boundVars, + freeVars, rename, typeOf, + typeVarsInTerm, mkEquals, isEq, getlhs, @@ -16,6 +18,7 @@ module Term ( +import Data.List import qualified Data.Set as Set import TypeVar @@ -108,21 +111,21 @@ substitute (tymap,vmap) term = in vdone -boundVars :: Term -> Set Var +boundVars :: Term -> Set.Set Var boundVars (TConst a b) = Set.empty boundVars (TApp a b) = Set.union (boundVars a) (boundVars b) boundVars (TVar a) = Set.empty -boundVars (TAbs a b) = Set.insert a (boundVars b) +boundVars (TAbs a b) = Set.insert (tVar a) (boundVars b) -freeVars :: Term -> Set Var +freeVars :: Term -> Set.Set Var freeVars (TConst a b) = Set.empty freeVars (TApp a b) = Set.union (freeVars a) (freeVars b) freeVars (TVar a) = Set.singleton a -freeVars (TAbs a b) = Set.delete a (freeVars b) +freeVars (TAbs a b) = Set.delete (tVar a) (freeVars b) -rename :: Term -> Set Var -> Term +rename :: Term -> Set.Set Var -> Term rename (TAbs (TVar v) t) vars = let doRename = (\x y z -> case x of @@ -155,10 +158,10 @@ typeOf (TApp f _) = last . aType . typeOf $ f -typeVarsInTerm :: Term -> Set Type +typeVarsInTerm :: Term -> Set.Set Type typeVarsInTerm (TConst _ ty) = typeVarsInType ty typeVarsInTerm (TVar v) = typeVarsInType . varTy $ v -typeVarsInTerm (TAbs v t) = Set.union (typeVarsInType . varTy $ v) (typeVarsInTerm t) +typeVarsInTerm (TAbs v t) = Set.union (typeVarsInType . varTy . tVar $ v) (typeVarsInTerm t) typeVarsInTerm (TApp f x) = Set.union (typeVarsInTerm f) (typeVarsInTerm x) @@ -12,12 +12,15 @@ module TypeVar ( Var(..), mkEqualsType, - typeFunc + typeFunc, + typeBool, + typeVarsInType ) where import Data.List +import qualified Data.Set as Set @@ -69,6 +72,6 @@ typeBool :: Type typeBool = AType [] (TypeOp (Name [] "bool")) -typeVarsInType :: Type -> Set Type +typeVarsInType :: Type -> Set.Set Type typeVarsInType (TypeVar t) = Set.singleton (TypeVar t) -typeVarsInType (AType list _) = unions . (map typeVarsInType) $ list +typeVarsInType (AType list _) = Set.unions . (map typeVarsInType) $ list |