2module Types.Hints (hints) where
4import Control.Monad (liftM,mapM)
5import Control.Arrow (first)
7import Types.Substitutions (rescheme)
10-------- Text and Elements --------
12str2elem = hasType (string ==> element) [ "image","video","plainText" ]
14textToText = [ "header", "italic", "bold", "underline"
15 , "overline", "strikeThrough", "monospace" ]
17textAttrs = [ "toText" -: string ==> text
18 , "link" -: string ==> text ==> text
19 , numScheme (\t -> t ==> text ==> text) "Text.height"
20 ] ++ hasType (text ==> text) textToText
22elements = let iee = int ==> element ==> element in
23 [ "flow" -: direction ==> listOf element ==> element
24 , "layers" -: listOf element ==> element
25 , "text" -: text ==> element
26 , "opacity" -: float ==> element ==> element
29 , "size" -: int ==> iee
31 , "rightedText" -: text ==> element
32 , "centeredText" -: text ==> element
33 , "justifiedText" -: text ==> element
34 , "asText" -:: a ==> element
35 , "show" -:: a ==> text
36 , "collage" -: int ==> int ==> listOf form ==> element
39directions = hasType direction ["up","down","left","right","inward","outward"]
40colors = [ numScheme (\n -> n ==> n ==> n ==> color) "rgb"
41 , numScheme (\n -> n ==> n ==> n ==> n ==> color) "rgba"
42 ] ++ hasType color ["red","green","blue","black","white"
43 ,"yellow","cyan","magenta","grey","gray"]
45lineTypes = [ numScheme (\n -> listOf (pairOf n) ==> line) "line"
46 , "customLine" -: listOf int ==> color ==> line ==> form
47 ] ++ hasType (color ==> line ==> form) ["solid","dashed","dotted"]
49shapes = [ twoNums (\n m -> listOf (pairOf n) ==> pairOf m ==> shape) "polygon"
50 , "filled" -: color ==> shape ==> form
51 , "outlined" -: color ==> shape ==> form
52 , "customOutline" -: listOf int ==> color ==> shape ==> form
53 , scheme2 number transformable (\n t -> n ==> n ==> t ==> t) "move"
54 , scheme2 number transformable (\n t -> n ==> t ==> t) "rotate"
55 , scheme2 number transformable (\n t -> n ==> t ==> t) "scale"
56 ] ++ map (twoNums (\n m -> n ==> n ==> pairOf m ==> shape)) [ "ngon"
61-------- Foreign --------
64 [ "castJSBoolToBool" -: jsBool ==> bool
65 , "castBoolToJSBool" -: bool ==> jsBool
66 , "castJSNumberToInt" -: jsNumber ==> int
67 , "castIntToJSNumber" -: int ==> jsNumber
68 , "castJSElementToElement" -: int ==> int ==> jsElement ==> element
69 , "castElementToJSElement" -: element ==> jsElement
70 , "castJSStringToString" -: jsString ==> string
71 , "castStringToJSString" -: string ==> jsString
72 , "castJSNumberToFloat" -: jsNumber ==> float
73 , "castFloatToJSNumber" -: float ==> jsNumber
76castToTuple n = (,) name $ Forall [1..n] [] (jsTuple vs ==> tupleOf vs)
77 where vs = map VarT [1..n]
78 name = "castJSTupleToTuple" ++ show n
79castToJSTuple n = (,) name $ Forall [1..n] [] (tupleOf vs ==> jsTuple vs)
80 where vs = map VarT [1..n]
81 name = "castTupleToJSTuple" ++ show n
84 map castToTuple [2..5] ++ map castToJSTuple [2..5] ++
85 [ "castJSArrayToList" -:: jsArray a ==> listOf a
86 , "castListToJSArray" -:: listOf a ==> jsArray a
90 [ "JsonString" -: string ==> jsonValue
91 , "JsonBool" -: bool ==> jsonValue
92 , "JsonNull" -: jsonValue
93 , "JsonArray" -: listOf jsonValue ==> jsonValue
94 , "JsonObject" -: jsonObject ==> jsonValue
95 , numScheme (\n -> n ==> jsonValue) "JsonNumber"
96 , "toPrettyString" -: string ==> jsonObject ==> string
97 , "toPrettyJSString" -: string ==> jsonObject ==> jsString
98 , "toJSString" -: jsonObject ==> jsString
102-------- Signals --------
104sig n name = (,) name $ Forall [1..n] [] (fn ts ==> fn (map signalOf ts))
105 where fn = foldr1 (==>)
114 , "foldp" -:: (a ==> b ==> b) ==> b ==> signalOf a ==> signalOf b
115 , "randomize" -:: int ==> int ==> signalOf a ==> signalOf int
116 , "count" -:: signalOf a ==> signalOf int
117 , "keepIf" -:: (a==>bool) ==> a ==> signalOf a ==> signalOf a
118 , "dropIf" -:: (a==>bool) ==> a ==> signalOf a ==> signalOf a
119 , "keepWhen" -:: signalOf bool ==>a==> signalOf a ==> signalOf a
120 , "dropWhen" -:: signalOf bool ==>a==> signalOf a ==> signalOf a
121 , "dropRepeats" -:: signalOf a ==> signalOf a
122 , "sampleOn" -:: signalOf a ==> signalOf b ==> signalOf b
126 [ "keysDown" -: signalOf (listOf int)
127 , "charPressed" -: signalOf (maybeOf int)
128 , "inRange" -: int ==> int ==> signalOf int
129 , timeScheme "every" (\t -> t ==> signalOf t)
130 , timeScheme "before" (\t -> t ==> signalOf bool)
131 , timeScheme "after" (\t -> t ==> signalOf bool)
132 , "dimensions" -: signalOf point
133 , "position" -: signalOf point
134 , "x" -: signalOf int
135 , "y" -: signalOf int
136 , "isDown" -: signalOf bool
137 , "isClicked" -: signalOf bool
138 , "textField" -: string ==> tupleOf [element, signalOf string]
139 , "password" -: string ==> tupleOf [element, signalOf string]
140 , "textArea" -: int ==> int ==> tupleOf [element, signalOf string]
141 , "checkBox" -: bool ==> tupleOf [element, signalOf bool]
142 , "button" -: string ==> tupleOf [element, signalOf bool]
143 , "stringDropDown" -: listOf string ==> tupleOf [element, signalOf string]
146-------- Math and Binops --------
148binop t = t ==> t ==> t
149scheme1 super t name =
150 (name, Forall [0] [ Context ("`" ++ name ++ "'") $ VarT 0 :<: super
152scheme2 s1 s2 t name =
153 (name, Forall [0,1] [ Context ("`" ++ name ++ "'") $ VarT 0 :<: s1
154 , Context ("`" ++ name ++ "'") $ VarT 1 :<: s2
155 ] (t (VarT 0) (VarT 1)))
156numScheme t name = scheme1 number t name
157timeScheme name t = scheme1 time t name
158twoNums f name = scheme2 number number f name
161 map (numScheme (\t -> t ==> binop t)) ["clamp"] ++
162 map (numScheme (\t -> binop t)) ["+","-","*","max","min"] ++
163 [ numScheme (\t -> t ==> t) "abs" ] ++
164 hasType (binop float) [ "/", "logBase" ] ++
165 hasType (binop int) ["rem","div","mod"] ++
166 hasType (float ==> float) ["sin","cos","tan","asin","acos","atan","sqrt"] ++
167 hasType float ["pi","e"] ++
168 hasType (int ==> float) ["toFloat","castIntToFloat"] ++
169 hasType (float ==> int) ["round","floor","ceiling","truncate"]
172 [ "not" -: bool ==> bool ] ++
173 hasType (binop bool) ["&&","||"] ++
174 map (scheme1 comparable (\t -> t ==> t ==> bool)) ["<",">","<=",">="] ++
176 , Forall [0,1] [ Context "`compare'" $ VarT 0 :<: comparable ] (VarT 0 ==> VarT 0 ==> VarT 1) )
179-------- Polymorphic Functions --------
181[a,b,c] = map VarT [1,2,3]
184name -:: tipe = (name, Forall [1,2,3] [] tipe)
188 , "==" -:: a ==> a ==> bool
189 , "/=" -:: a ==> a ==> bool
190 , "flip" -:: (a ==> b ==> c) ==> (b ==> a ==> c)
191 , "." -:: (b ==> c) ==> (a ==> b) ==> (a ==> c)
192 , "$" -:: (a ==> b) ==> a ==> b
193 , ":" -:: a ==> listOf a ==> listOf a
194 , (,) "++" . Forall [0,1] [ Context "`++'" $ VarT 0 :<: appendable (VarT 1) ] $ VarT 0 ==> VarT 0 ==> VarT 0
195 , "Cons" -:: a ==> listOf a ==> listOf a
197 , "Just" -:: a ==> maybeOf a
198 , "Nothing" -:: maybeOf a
199 , "elmRange" -:: int ==> int ==> listOf int
203 [ "and" -:: listOf bool ==> bool
204 , "or" -:: listOf bool ==> bool
205 , numScheme (\n -> listOf n ==> listOf n) "sort"
206 , "head" -:: listOf a ==> a
207 , "tail" -:: listOf a ==> listOf a
208 , "length" -:: listOf a ==> int
209 , "filter" -:: (a ==> bool) ==> listOf a ==> listOf a
210 , "foldr1" -:: (a ==> a ==> a) ==> listOf a ==> a
211 , "foldl1" -:: (a ==> a ==> a) ==> listOf a ==> a
212 , "scanl1" -:: (a ==> a ==> a) ==> listOf a ==> a
213 , "forall" -:: (a ==> bool) ==> listOf a ==> bool
214 , "exists" -:: (a ==> bool) ==> listOf a ==> bool
215 , "reverse" -:: listOf a ==> listOf a
216 , "take" -:: int ==> listOf a ==> listOf a
217 , "drop" -:: int ==> listOf a ==> listOf a
218 , "partition" -:: (a ==> bool) ==> listOf a ==> tupleOf [listOf a,listOf a]
219 , "intersperse" -:: a ==> listOf a ==> listOf a
220 , "zip" -:: listOf a ==>listOf b ==>listOf(tupleOf [a,b])
221 , "map" -:: (a ==> b) ==> listOf a ==> listOf b
222 , "foldr" -:: (a ==> b ==> b) ==> b ==> listOf a ==> b
223 , "foldl" -:: (a ==> b ==> b) ==> b ==> listOf a ==> b
224 , "scanl" -:: (a ==> b ==> b) ==> b ==> listOf a ==> listOf b
225 , (,) "concat" . Forall [0,1] [ Context "`concat'" $ VarT 0 :<: appendable (VarT 1) ] $
226 listOf (VarT 0) ==> VarT 0
227 , (,) "concatMap" . Forall [0,1,2] [ Context "`concatMap'" $ VarT 0 :<: appendable (VarT 1) ] $
228 (VarT 2 ==> VarT 0) ==> listOf (VarT 2) ==> VarT 0
229 , (,) "intercalate" . Forall [0,1] [ Context "`intercalate'" $ VarT 0 :<: appendable (VarT 1) ] $
230 VarT 0 ==> listOf (VarT 0) ==> VarT 0
231 , "zipWith" -:: (a ==> b ==> c) ==> listOf a ==> listOf b ==> listOf c
232 ] ++ map (numScheme (\n -> listOf n ==> n)) [ "sum", "product"
233 , "maximum", "minimum" ]
236-------- Everything --------
238hints = mapM (\(n,s) -> (,) n `liftM` rescheme s) hs
239 where hs = concat [ funcs, lists, signals, math, bools, str2elem, textAttrs
240 , elements, directions, colors, lineTypes, shapes
241 , concreteSignals, casts, polyCasts, json
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