1module SourceSyntax.Declaration where
3import qualified SourceSyntax.Expression as Expr
4import SourceSyntax.Type
5import SourceSyntax.PrettyPrint
6import Text.PrettyPrint as P
8data Declaration tipe var
9 = Definition (Expr.Def tipe var)
10 | Datatype String [String] [(String,[Type])]
11 | TypeAlias String [String] Type [Deriveable]
12 | ImportEvent String (Expr.LExpr tipe var) String Type
13 | ExportEvent String String Type
14 | Fixity Assoc Int String
20data Deriveable = Json | Binary | RecordConstructor
23instance Show Assoc where
30instance Pretty (Declaration t v) where
33 Definition def -> pretty def
35 Datatype tipe tvars ctors ->
36 P.hang (P.text "data" <+> P.text tipe <+> P.hsep (map P.text tvars)) 4
37 (P.sep $ zipWith join ("=" : repeat "|") ctors)
39 join c ctor = P.text c <+> prettyCtor ctor
40 prettyCtor (name, tipes) =
41 P.hang (P.text name) 2 (P.sep (map prettyParens tipes))
43 TypeAlias name tvars tipe deriveables ->
44 P.hang (P.text "type" <+> alias <+> P.equals) 4 (pretty tipe) <+> deriving'
46 alias = P.text name <+> P.hsep (map P.text tvars)
50 [d] -> P.text "deriving" <+> P.text (show d)
51 ds -> P.text "deriving" <+>
52 P.parens (P.hsep $ P.punctuate P.comma $ map (P.text . show) ds)
54 -- TODO: Actually write out the contained data in these cases.
55 ImportEvent _ _ _ _ -> P.text (show decl)
56 ExportEvent _ _ _ -> P.text (show decl)
57 Fixity _ _ _ -> P.text (show decl)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list