@@ -72,10 +72,13 @@ instance Ord FixDecl where
73data Plicity = Imp | Exp deriving Show
73data Plicity = Imp | Exp deriving Show
75−data PDecl' t = PFix Fixity [String] -- fixity declaration
75+data PDecl' t = PFix Fixity [String] -- fixity declaration
76− | PTy Name t -- type declaration
76+ | PTy Name t -- type declaration
77− | PClause t t -- pattern clause
77+ | PClauses [PClause' t] -- pattern clause
78− | PData (PData' t) -- data declaration
78+ | PData (PData' t) -- data declaration
81+data PClause' t = PClause Name t t
79 deriving Functor
82 deriving Functor
81data PData' t = PDatadecl { d_name :: Name,
84data PData' t = PDatadecl { d_name :: Name,
@@ -86,9 +89,9 @@ data PData' t = PDatadecl { d_name :: Name,
86-- Handy to get a free function for applying PTerm -> PTerm functions
89-- Handy to get a free function for applying PTerm -> PTerm functions
87-- across a program, by deriving Functor
90-- across a program, by deriving Functor
89−type PDecl = PDecl' PTerm
92+type PDecl = PDecl' PTerm
90−type PData = PData' PTerm
93+type PData = PData' PTerm
91−
94+type PClause = PClause' PTerm
92-- High level language terms
95-- High level language terms
94data PTerm = PQuote Raw
97data PTerm = PQuote Raw
@@ -100,18 +103,26 @@ data PTerm = PQuote Raw
101 | Placeholder
104 | Placeholder
106+--- Pretty printing declarations and terms
103instance Show PTerm where
108instance Show PTerm where
104 show tm = showImp False tm
109 show tm = showImp False tm
106instance Show PDecl where
111instance Show PDecl where
107 show (PFix f ops) = show f ++ " " ++ showSep ", " ops
112 show (PFix f ops) = show f ++ " " ++ showSep ", " ops
108 show (PTy n ty) = show n ++ " : " ++ show ty
113 show (PTy n ty) = show n ++ " : " ++ show ty
109− show (PClause l r) = show l ++ " = " ++ show r
114+ show (PClauses c) = showSep "\n" (map show c)
110 show (PData d) = show d
115 show (PData d) = show d
117+instance Show PClause where
118+ show c = showCImp False c
112instance Show PData where
120instance Show PData where
113 show d = showDImp False d
121 show d = showDImp False d
123+showCImp :: Bool -> PClause -> String
124+showCImp impl (PClause n l r) = showImp impl l ++ " = " ++ showImp impl r
115showDImp :: Bool -> PData -> String
126showDImp :: Bool -> PData -> String
116showDImp impl (PDatadecl n ty cons)
127showDImp impl (PDatadecl n ty cons)
117 = "data " ++ show n ++ " : " ++ showImp impl ty ++ " where\n\t"
128 = "data " ++ show n ++ " : " ++ showImp impl ty ++ " where\n\t"