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 ])
37time = SuperType "Time" (Set.fromList [ int, float ])
39element = tipe "Element"
40direction = tipe "Direction"
45point = tupleOf [int,int]
47listOf t = ADT "List" [t]
48signalOf t = ADT "Signal" [t]
49tupleOf ts = ADT ("Tuple" ++ show (length ts)) ts
50maybeOf t = ADT "Maybe" [t]
53jsNumber = tipe "JSNumber"
54jsString = tipe "JSString"
55jsElement = tipe "JSElement"
56jsArray t = ADT "JSArray" [t]
57jsTuple ts = ADT ("JSTuple" ++ show (length ts)) ts
60t1 ==> t2 = LambdaT t1 t2
63name -: tipe = (,) name $ Forall [] [] tipe
67parens = ("("++) . (++")")
69instance Show Type where
72 { LambdaT t1@(LambdaT _ _) t2 -> parens (show t1) ++ " -> " ++ show t2
73 ; LambdaT t1 t2 -> show t1 ++ " -> " ++ show t2
75 ; ADT "List" [tipe] -> "[" ++ show tipe ++ "]"
78 then parens . intercalate "," $ map show cs
79 else case cs of [] -> name
80 _ -> parens $ name ++ " " ++ unwords (map show cs)
83instance Show SuperType where
84 show (SuperType n ts) = "" ++ n ++ " (a type in {" ++ subs ++ "})"
85 where subs = intercalate "," . map show $ Set.toList ts
87isTupleString 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