4import Data.Char (isDigit)
5import Data.List (intercalate,isPrefixOf)
6import qualified Data.Set as Set
10data Type = LambdaT Type Type
15data Scheme = Forall [X] [Constraint] Type deriving (Eq, Ord, Show)
17data SuperType = SuperType String (Set.Set Type) deriving (Eq, Ord)
19data Constraint = Type :=: Type
22 deriving (Eq, Ord, Show)
29number = SuperType "Number" (Set.fromList [ int, float ])
34string = listOf char -- tipe "String"
37time = SuperType "Time" (Set.fromList [ int, float, tipe "Number" ])
39element = tipe "Element"
40direction = tipe "Direction"
46listOf t = ADT "List" [t]
47signalOf t = ADT "Signal" [t]
48tupleOf ts = ADT ("Tuple" ++ show (length ts)) ts
49maybeOf t = ADT "Maybe" [t]
50pairOf t = tupleOf [t,t]
52appendable t = SuperType "Appendable" (Set.fromList [ string, text, listOf t ])
53comparable = SuperType "Comparable" (Set.fromList [ int, float, char, string, tipe "Number", tipe "Time" ])
54transformable = SuperType "Transformable" (Set.fromList [ shape, line ])
57jsNumber = tipe "JSNumber"
58jsString = tipe "JSString"
59jsElement = tipe "JSElement"
60jsArray t = ADT "JSArray" [t]
61jsTuple ts = ADT ("JSTuple" ++ show (length ts)) ts
62jsonValue = tipe "JsonValue"
63jsonObject = tipe "JsonObject"
66t1 ==> t2 = LambdaT t1 t2
69name -: tipe = (,) name $ Forall [] [] tipe
73parens = ("("++) . (++")")
75instance Show Type where
78 { LambdaT t1@(LambdaT _ _) t2 -> parens (show t1) ++ " -> " ++ show t2
79 ; LambdaT t1 t2 -> show t1 ++ " -> " ++ show t2
80 ; VarT x -> 't' : show x
81 ; ADT "List" [ADT "Char" []] -> "String"
82 ; ADT "List" [tipe] -> "[" ++ show tipe ++ "]"
85 then parens . intercalate "," $ map show cs
86 else case cs of [] -> name
87 _ -> parens $ name ++ " " ++ unwords (map show cs)
90instance Show SuperType where
91 show (SuperType n ts) = "" ++ n ++ " (a type in {" ++ subs ++ "})"
92 where subs = intercalate "," . map show $ Set.toList ts
94isTupleString str = "Tuple" `isPrefixOf` str && all isDigit (drop 5 str)
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