2module SourceSyntax.Type where
4import qualified Data.Map as Map
5import SourceSyntax.PrettyPrint
6import Text.PrettyPrint as P
8data Type = Lambda Type Type
12 | Record (Map.Map String [Type]) Type
15fieldMap :: [(String,Type)] -> Map.Map String [Type]
17 foldl (\r (x,t) -> Map.insertWith (++) x [t] r) Map.empty fields
19recordOf :: [(String,Type)] -> Type
20recordOf fields = Record (fieldMap fields) EmptyRecord
23listOf t = Data "List" [t]
25tupleOf :: [Type] -> Type
26tupleOf ts = Data ("_Tuple" ++ show (length ts)) ts
29instance Pretty Type where
32 Lambda t1 t2 -> P.sep [ t, P.sep (map (P.text "->" <+>) ts) ]
33 where t:ts = collectLambdas tipe
35 Data name tipes -> P.hang (P.text name) 2 (P.sep $ map prettyParens tipes)
36 EmptyRecord -> P.braces P.empty
37 Record fields ext -> error "not done yet"
41 Lambda arg@(Lambda _ _) body -> P.parens (pretty arg) : collectLambdas body
42 Lambda arg body -> pretty arg : collectLambdas body
45prettyParens tipe = parensIf needed (pretty tipe)
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