on master help sign in
Correct some type hints that specified ints when numbers are okay.
d4b2760evancz
elm/src/Types/Hints.hs+18−14
@@ -16,14 +16,14 @@ textToText = [ "header", "italic", "bold", "underline"
16
16
17textAttrs = [ "toText" -: string ==> text
17textAttrs = [ "toText" -: string ==> text
18 , "link" -: string ==> text ==> text
18 , "link" -: string ==> text ==> text
19− , "Text.height" -: int ==> text ==> text
19+ , numScheme (\t -> t ==> text ==> text) "Text.height"
20 ] ++ hasType (text ==> text) textToText
20 ] ++ hasType (text ==> text) textToText
21
21
22elements = let iee = int ==> element ==> element in
22elements = let iee = int ==> element ==> element in
23 [ "flow" -: direction ==> listOf element ==> element
23 [ "flow" -: direction ==> listOf element ==> element
24 , "layers" -: listOf element ==> element
24 , "layers" -: listOf element ==> element
25 , "text" -: text ==> element
25 , "text" -: text ==> element
26− , "opacity" -: iee
26+ , "opacity" -: float ==> element ==> element
27 , "width" -: iee
27 , "width" -: iee
28 , "height" -: iee
28 , "height" -: iee
29 , "size" -: int ==> iee
29 , "size" -: int ==> iee
@@ -34,19 +34,22 @@ elements = let iee = int ==> element ==> element in
34 ]
34 ]
35
35
36directions = hasType direction ["up","down","left","right","inward","outward"]
36directions = hasType direction ["up","down","left","right","inward","outward"]
37−colors = [ "rgb" -: int ==> int ==> int ==> color
37+colors = [ numScheme (\n -> n ==> n ==> n ==> color) "rgb"
38− , "rgba" -: int ==> int ==> int ==> int ==> color
38+ , numScheme (\n -> n ==> n ==> n ==> n ==> color) "rgba"
39− ] ++ hasType color ["red","green","blue","black","white"]
39+ ] ++ hasType color ["red","green","blue","black","white"
40+ ,"yellow","cyan","magenta","grey","gray"]
40
41
41−lineTypes = [ "line" -: listOf point ==> line
42+lineTypes = [ numScheme (\n -> listOf (pairOf n) ==> line) "line"
42 , "customLine" -: listOf int ==> color ==> line ==> form
43 , "customLine" -: listOf int ==> color ==> line ==> form
43 ] ++ hasType (color ==> line ==> form) ["solid","dashed","dotted"]
44 ] ++ hasType (color ==> line ==> form) ["solid","dashed","dotted"]
44
45
45−shapes = [ "polygon" -: listOf point ==> point ==> shape
46+shapes = [ numScheme (\n -> listOf (pairOf n) ==> pairOf n ==> shape) "polygon"
46 , "filled" -: color ==> shape ==> form
47 , "filled" -: color ==> shape ==> form
47 , "outlined" -: color ==> shape ==> form
48 , "outlined" -: color ==> shape ==> form
48 , "customOutline" -: listOf int ==> color ==> shape ==> form
49 , "customOutline" -: listOf int ==> color ==> shape ==> form
49− ] ++ hasType (int ==> int ==> point ==> shape) ["ngon","rect","oval"]
50+ ] ++ map (numScheme (\n -> n ==> n ==> pairOf n ==> shape) [ "ngon"
51+ , "rect"
52+ , "oval" ]
50
53
51
54
52-------- Foreign --------
55-------- Foreign --------
@@ -132,14 +135,14 @@ math =
132 map (numScheme (\t -> t ==> binop t)) ["clamp"] ++
135 map (numScheme (\t -> t ==> binop t)) ["clamp"] ++
133 map (numScheme (\t -> binop t)) ["+","-","*","max","min"] ++
136 map (numScheme (\t -> binop t)) ["+","-","*","max","min"] ++
134 [ numScheme (\t -> t ==> t) "abs" ] ++
137 [ numScheme (\t -> t ==> t) "abs" ] ++
135− [ "/" -: binop float ] ++
138+ hasType (binop float) [ "/", "logBase" ] ++
136− hasType (binop int) ["rem","div","mod","logBase"] ++
139+ hasType (binop int) ["rem","div","mod"] ++
137− hasType (float ==> float) ["sin","cos","tan","asin","acos","atan","sqrt"]
140+ hasType (float ==> float) ["sin","cos","tan","asin","acos","atan","sqrt"] ++
138
141
139bools =
142bools =
140 [ "not" -: bool ==> bool ] ++
143 [ "not" -: bool ==> bool ] ++
141 hasType (binop bool) ["&&","||"] ++
144 hasType (binop bool) ["&&","||"] ++
142− hasType (int ==> int ==> bool) ["<",">","<=",">="]
145+ map (numScheme (\n -> n ==> n ==> bool)) ["<",">","<=",">="]
143
146
144
147
145-------- Polymorphic Functions --------
148-------- Polymorphic Functions --------
@@ -171,7 +174,7 @@ funcs =
171lists =
174lists =
172 [ "and" -:: listOf bool ==> bool
175 [ "and" -:: listOf bool ==> bool
173 , "or" -:: listOf bool ==> bool
176 , "or" -:: listOf bool ==> bool
174− , "sort" -:: listOf int ==> listOf int
177+ , numScheme (\n -> listOf n ==> listOf n) "sort"
175 , "head" -:: listOf a ==> a
178 , "head" -:: listOf a ==> a
176 , "tail" -:: listOf a ==> listOf a
179 , "tail" -:: listOf a ==> listOf a
177 , "length" -:: listOf a ==> int
180 , "length" -:: listOf a ==> int
@@ -195,7 +198,8 @@ lists =
195 , "scanl" -:: (a ==> b ==> b) ==> b ==> listOf a ==> listOf b
198 , "scanl" -:: (a ==> b ==> b) ==> b ==> listOf a ==> listOf b
196 , "concatMap" -:: (a ==> listOf b) ==> listOf a ==> listOf b
199 , "concatMap" -:: (a ==> listOf b) ==> listOf a ==> listOf b
197 , "zipWith" -:: (a ==> b ==> c) ==> listOf a ==> listOf b ==> listOf c
200 , "zipWith" -:: (a ==> b ==> c) ==> listOf a ==> listOf b ==> listOf c
198− ] ++ map (-: (listOf int ==> int)) [ "sum","product","maximum","minimum" ]
201+ ] ++ map (numScheme (\n -> listOf n ==> n)) [ "sum", "product"
202+ , "maximum", "minimum" ]
199
203
200
204
201-------- Everything --------
205-------- Everything --------
elm/src/Types/Types.hs+2−1
@@ -42,12 +42,13 @@ form = tipe "Form"
42line = tipe "Line"
42line = tipe "Line"
43shape = tipe "Shape"
43shape = tipe "Shape"
44color = tipe "Color"
44color = tipe "Color"
45−point = tupleOf [int,int]
46
45
47listOf t = ADT "List" [t]
46listOf t = ADT "List" [t]
48signalOf t = ADT "Signal" [t]
47signalOf t = ADT "Signal" [t]
49tupleOf ts = ADT ("Tuple" ++ show (length ts)) ts
48tupleOf ts = ADT ("Tuple" ++ show (length ts)) ts
50maybeOf t = ADT "Maybe" [t]
49maybeOf t = ADT "Maybe" [t]
50+pairOf t = tupleOf [t,t]
51+point = pairOf int
51
52
52jsBool = tipe "JSBool"
53jsBool = tipe "JSBool"
53jsNumber = tipe "JSNumber"
54jsNumber = tipe "JSNumber"