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
12 | ImportEvent String (Expr.LExpr tipe var) String Type
13 | ExportEvent String String Type
14 | Fixity Assoc Int String
20instance Show Assoc where
27instance Pretty (Declaration t v) where
30 Definition def -> pretty def
32 Datatype tipe tvars ctors ->
33 P.hang (P.text "data" <+> P.text tipe <+> P.hsep (map P.text tvars)) 4
34 (P.sep $ zipWith join ("=" : repeat "|") ctors)
36 join c ctor = P.text c <+> prettyCtor ctor
37 prettyCtor (name, tipes) =
38 P.hang (P.text name) 2 (P.sep (map prettyParens tipes))
40 TypeAlias name tvars tipe ->
41 let alias = P.text name <+> P.hsep (map P.text tvars) in
42 P.hang (P.text "type" <+> alias <+> P.equals) 4 (pretty tipe)
44 -- TODO: Actually write out the contained data in these cases.
45 ImportEvent _ _ _ _ -> P.text (show decl)
46 ExportEvent _ _ _ -> P.text (show decl)
47 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