1{-# LANGUAGE DeriveDataTypeable #-}
2module SourceSyntax.Declaration where
5import qualified SourceSyntax.Expression as Expr
6import SourceSyntax.Type
7import SourceSyntax.PrettyPrint
8import Text.PrettyPrint as P
10data Declaration tipe var
11 = Definition (Expr.Def tipe var)
12 | Datatype String [String] [(String,[Type])]
13 | TypeAlias String [String] Type
14 | ImportEvent String (Expr.LExpr tipe var) String Type
15 | ExportEvent String String Type
16 | Fixity Assoc Int String
22instance Show Assoc where
29instance Pretty (Declaration t v) where
32 Definition def -> pretty def
34 Datatype tipe tvars ctors ->
35 P.hang (P.text "data" <+> P.text tipe <+> P.hsep (map P.text tvars)) 4
36 (P.sep $ zipWith join ("=" : repeat "|") ctors)
38 join c ctor = P.text c <+> prettyCtor ctor
39 prettyCtor (name, tipes) =
40 P.hang (P.text name) 2 (P.sep (map prettyParens tipes))
42 TypeAlias name tvars tipe ->
43 let alias = P.text name <+> P.hsep (map P.text tvars) in
44 P.hang (P.text "type" <+> alias <+> P.equals) 4 (pretty tipe)
46 -- TODO: actually write out the other cases. They are currently unused, but
47 -- this is probably going to be a bug someday.
48 _ -> 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