Skip to content

Commit

Permalink
Fix traversable typeChecking
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Zalewski committed Apr 14, 2020
1 parent e891d13 commit 631ab6a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
12 changes: 6 additions & 6 deletions field/TinyLang/Field/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import GHC.Generics
import Quiet

-- | Basic wrapper of statements
newtype Statements stmt f = Statements { unStatements :: [stmt f] }
deriving (Generic, Eq)
deriving (Show) via (Quiet (Statements stmt f))
newtype Statements stmt = Statements { unStatements :: [stmt] }
deriving (Generic, Eq, Functor, Foldable, Traversable)
deriving (Show) via (Quiet (Statements stmt))

-- | Basic wrapper of program
newtype Program stmt f = Program { unProgram :: (Statements stmt f) }
deriving (Generic, Eq)
deriving (Show) via (Quiet (Program stmt f))
newtype Program stmt = Program { unProgram :: (Statements stmt) }
deriving (Generic, Eq, Functor, Foldable, Traversable)
deriving (Show) via (Quiet (Program stmt))
12 changes: 6 additions & 6 deletions field/TinyLang/Field/Raw/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ statement level; the operations acting on statement level are not necessarily
mappable over a list of statements.
-}

type Program v = C.Program (Statement v)
type Statements v = C.Statements (Statement v)
type Program v f = C.Program (Statement v f)
type Statements v f = C.Statements (Statement v f)

mkProgram :: Statements v f -> Program v f
mkProgram = C.Program
Expand Down Expand Up @@ -106,7 +106,7 @@ data UnOp

{-| = Utility Type Aliases
-}
type RawProgram = Program Var
type RawStatements = Statements Var
type RawStatement = Statement Var
type RawExpr = Expr Var
type RawProgram f = Program Var f
type RawStatements f = Statements Var f
type RawStatement f = Statement Var f
type RawExpr f = Expr Var f
4 changes: 2 additions & 2 deletions field/TinyLang/Field/Typed/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ data BinOp f a b c where
BAt :: BinOp f (AField f) (Vector Bool) Bool


type Program = C.Program Statement
type Statements = C.Statements Statement
type Program f = C.Program (Statement f)
type Statements f = C.Statements (Statement f)

mkProgram :: Statements f -> Program f
mkProgram = C.Program
Expand Down
4 changes: 1 addition & 3 deletions field/TinyLang/Field/Typed/TypeChecker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ checkExpr m = do
checkProgram
:: forall m f. (MonadTypeChecker m, TextField f)
=> R.Program R.Var f -> m (T.Program f)
checkProgram =
-- fmap (T.mkProgram . T.mkStatements) . mapM checkStatement . R.unStatements . R.unProgram
traverse checkStatement
checkProgram = traverse checkStatement


{-| Type checking judgement for statements of form
Expand Down

0 comments on commit 631ab6a

Please sign in to comment.