Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: Averethel/OCamlMin
base: 50ee5ba3c3
...
head fork: Averethel/OCamlMin
compare: da1bab7ff9
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 44 additions and 1 deletion.
  1. +1 −1  Syntax/Expr.hs
  2. +4 −0 Types.hs
  3. +39 −0 Types/Base.hs
View
2  Syntax/Expr.hs
@@ -83,7 +83,7 @@ module Syntax.Expr (
iNewline, pprExpr e ]
pprExpr (Eapply e args) = pprApplication e args
pprExpr (Etuple es) = iConcat [ iStr "(", iInterleave (iStr ", ") $
- map pprExpr es, iStr ")" ]
+ map pprAExpr es, iStr ")" ]
pprExpr (Econs e1 e2) = pprAExpr e1 `iAppend` iStr " :: "
`iAppend` pprAExpr e2
pprExpr (Eif e1 e2 e3) = iConcat [ iStr "if ( ", pprExpr e1,
View
4 Types.hs
@@ -0,0 +1,4 @@
+module Types (
+ Type(..)
+) where
+ import Types.Base
View
39 Types/Base.hs
@@ -0,0 +1,39 @@
+module Types.Base where
+ import Utils.Iseq
+
+ data Type =
+ Tint
+ | Tbool
+ | Tunit
+ | Tvar String
+ | Tlist Type
+ | Tref Type
+ | Ttuple [Type]
+ | Tfun [Type] Type
+ deriving Eq
+
+ isAtomicType :: Type -> Bool
+ isAtomicType (Tfun _ _) = False
+ isAtomicType (Tlist _) = False
+ isAtomicType (Tref _) = False
+ isAtomicType _ = True
+
+ pprAType :: Type -> Iseq
+ pprAType t
+ | isAtomicType t = pprType t
+ | otherwise = iStr "(" `iAppend` pprType t `iAppend` iStr ")"
+
+ pprType :: Type -> Iseq
+ pprType Tint = iStr "int"
+ pprType Tbool = iStr "bool"
+ pprType Tunit = iStr "unit"
+ pprType (Tvar v) = iStr v
+ pprType (Tlist t) = pprAType t `iAppend` iStr " list"
+ pprType (Tref t) = pprType t `iAppend` iStr " ref"
+ pprType (Ttuple ts) = iConcat [ iStr "(", iInterleave (iStr ", ") $
+ map pprAType ts, iStr ")" ]
+ pprType (Tfun ts t) = iConcat [ iInterleave (iStr " -> ") $ map pprAType ts,
+ iStr " -> ", pprType t ]
+
+ instance Show Type where
+ show = show . pprType

No commit comments for this range

Something went wrong with that request. Please try again.