on master help sign in
Merge branch 'type-decls'
e531046Evan Czaplicki
compiler/Docs.hs+2−2
@@ -25,7 +25,7 @@ import qualified AST.Expression.Source as Src
25import qualified AST.Variable as Var
25import qualified AST.Variable as Var
26
26
27import Text.Parsec hiding (newline,spaces)
27import Text.Parsec hiding (newline,spaces)
28−import Parse.Declaration (alias,datatype,infixDecl)
28+import Parse.Declaration (typeDecl,infixDecl)
29import Parse.Expression (typeAnnotation)
29import Parse.Expression (typeAnnotation)
30import Parse.Helpers
30import Parse.Helpers
31import Parse.Module (moduleDef)
31import Parse.Module (moduleDef)
@@ -102,7 +102,7 @@ docThing = uncommentable <|> commented <|> uncommented ""
102 uncommented comment
102 uncommented comment
103
103
104 uncommented comment = do
104 uncommented comment = do
105− (src,def) <- withSource $ choice [ alias, datatype, D.Definition <$> typeAnnotation ]
105+ (src,def) <- withSource $ choice [ typeDecl, D.Definition <$> typeAnnotation ]
106 return (comment, def, src)
106 return (comment, def, src)
107
107
108
108
compiler/Parse/Declaration.hs+23−20
@@ -9,31 +9,34 @@ import qualified Parse.Expression as Expr
9import qualified Parse.Type as Type
9import qualified Parse.Type as Type
10import qualified AST.Declaration as D
10import qualified AST.Declaration as D
11
11
12+
12declaration :: IParser D.SourceDecl
13declaration :: IParser D.SourceDecl
13−declaration = alias <|> datatype <|> infixDecl <|> port <|> definition
14+declaration = typeDecl <|> infixDecl <|> port <|> definition
15+
14
16
15definition :: IParser D.SourceDecl
17definition :: IParser D.SourceDecl
16definition = D.Definition <$> Expr.def
18definition = D.Definition <$> Expr.def
17
19
20+
18−alias :: IParser D.SourceDecl
21+typeDecl :: IParser D.SourceDecl
19−alias = do
22+typeDecl =
20− reserved "type" <?> "type alias (type Point = {x:Int, y:Int})"
23+ do reserved "type" <?> "type declaration"
21− forcedWS
24+ forcedWS
25+ isAlias <- optionMaybe (string "alias" >> forcedWS)
26+ case isAlias of
27+ Just _ ->
22− name <- capVar
28+ do name <- capVar
23− args <- spacePrefix lowVar
29+ args <- spacePrefix lowVar
24− padded equals
30+ padded equals
25− tipe <- Type.expr
31+ tipe <- Type.expr
26− return (D.TypeAlias name args tipe)
32+ return (D.TypeAlias name args tipe)
27−
33+
28−datatype :: IParser D.SourceDecl
34+ Nothing ->
29−datatype = do
30− reserved "data" <?> "datatype definition (data T = A | B | ...)"
31− forcedWS
32− name <- capVar <?> "name of data-type"
35+ do name <- capVar <?> "name of data-type"
33− args <- spacePrefix lowVar
36+ args <- spacePrefix lowVar
34− padded equals
37+ padded equals
35− tcs <- pipeSep1 Type.constructor
38+ tcs <- pipeSep1 Type.constructor
36− return $ D.Datatype name args tcs
39+ return $ D.Datatype name args tcs
37
40
38
41
39infixDecl :: IParser D.SourceDecl
42infixDecl :: IParser D.SourceDecl
compiler/Parse/Helpers.hs+11−9
@@ -22,15 +22,17 @@ import AST.Literal as Literal
22import AST.PrettyPrint
22import AST.PrettyPrint
23import qualified AST.Variable as Variable
23import qualified AST.Variable as Variable
24
24
25+reserveds :: [String]
26+reserveds =
25−reserveds = [ "if", "then", "else"
27+ [ "if", "then", "else"
26− , "case", "of"
28+ , "case", "of"
27− , "let", "in"
29+ , "let", "in"
28− , "data", "type"
30+ , "data", "type"
29− , "module", "where"
31+ , "module", "where"
30− , "import", "as", "hiding", "open"
32+ , "import", "as", "hiding", "open"
31− , "export", "foreign"
33+ , "export", "foreign"
32− , "deriving", "port"
34+ , "deriving", "port"
33− ]
35+ ]
34
36
35expecting = flip (<?>)
37expecting = flip (<?>)
36
38
libraries/Array.elm+1−1
@@ -25,7 +25,7 @@ import Basics (..)
25import Maybe (..)
25import Maybe (..)
26import List
26import List
27
27
28−data Array a = Array
28+type Array a = Array
29
29
30{-| Initialize an array. `initialize n f` creates an array of length `n` with
30{-| Initialize an array. `initialize n f` creates an array of length `n` with
31the element at index `i` initialized to the result of `(f i)`.
31the element at index `i` initialized to the result of `(f i)`.
libraries/Basics.elm+1−1
@@ -234,7 +234,7 @@ compare = Native.Basics.compare
234{-| Represents the relative ordering of two things.
234{-| Represents the relative ordering of two things.
235The relations are less than, equal to, and greater than.
235The relations are less than, equal to, and greater than.
236-}
236-}
237−data Order = LT | EQ | GT
237+type Order = LT | EQ | GT
238
238
239{-| Find the smaller of two comparables. -}
239{-| Find the smaller of two comparables. -}
240min : comparable -> comparable -> comparable
240min : comparable -> comparable -> comparable
libraries/Char.elm+1−1
@@ -50,7 +50,7 @@ toLocaleUpper = Native.Char.toLocaleUpper
50toLocaleLower : Char -> Char
50toLocaleLower : Char -> Char
51toLocaleLower = Native.Char.toLocaleLower
51toLocaleLower = Native.Char.toLocaleLower
52
52
53−type KeyCode = Int
53+type alias KeyCode = Int
54
54
55{-| Convert to unicode. Used with the `Keyboard` library, which expects the
55{-| Convert to unicode. Used with the `Keyboard` library, which expects the
56input to be uppercase. -}
56input to be uppercase. -}
libraries/Color.elm+2−2
@@ -42,7 +42,7 @@ that has never helped me remember which one I should be writing.
42
42
43import Basics (..)
43import Basics (..)
44
44
45−data Color
45+type Color
46 = RGBA Int Int Int Float
46 = RGBA Int Int Int Float
47 | HSLA Float Float Float Float
47 | HSLA Float Float Float Float
48
48
@@ -174,7 +174,7 @@ hslToRgb hue saturation lightness =
174
174
175--toV4 : Color -> V4
175--toV4 : Color -> V4
176
176
177−data Gradient
177+type Gradient
178 = Linear (Float,Float) (Float,Float) [(Float,Color)]
178 = Linear (Float,Float) (Float,Float) [(Float,Color)]
179 | Radial (Float,Float) Float (Float,Float) Float [(Float,Color)]
179 | Radial (Float,Float) Float (Float,Float) Float [(Float,Color)]
180
180
libraries/Date.elm+6−5
@@ -16,15 +16,16 @@ import Native.Date
16import Time (Time)
16import Time (Time)
17import Maybe (Maybe)
17import Maybe (Maybe)
18
18
19−data Date = Date
19+type Date = Date
20
20
21{-| Represents the days of the week. -}
21{-| Represents the days of the week. -}
22−data Day = Mon | Tue | Wed | Thu | Fri | Sat | Sun
22+type Day = Mon | Tue | Wed | Thu | Fri | Sat | Sun
23
23
24{-| Represents the month of the year. -}
24{-| Represents the month of the year. -}
25+type Month
25−data Month = Jan | Feb | Mar | Apr
26+ = Jan | Feb | Mar | Apr
26− | May | Jun | Jul | Aug
27+ | May | Jun | Jul | Aug
27− | Sep | Oct | Nov | Dec
28+ | Sep | Oct | Nov | Dec
28
29
29{-| Attempt to read a date from a string. -}
30{-| Attempt to read a date from a string. -}
30read : String -> Maybe Date
31read : String -> Maybe Date
libraries/Dict.elm+5−8
@@ -42,13 +42,10 @@ import List
42import List ((::))
42import List ((::))
43import Native.Utils
43import Native.Utils
44
44
45−type Fakeout = (Int, Int)
46−
47−type Another = (Int, Int)
48
45
49-- BBlack and NBlack should only be used during the deletion
46-- BBlack and NBlack should only be used during the deletion
50-- algorithm. Any other occurrence is a bug and should fail an assert.
47-- algorithm. Any other occurrence is a bug and should fail an assert.
51−data NColor
48+type NColor
52 = Red
49 = Red
53 | Black
50 | Black
54 | BBlack -- Double Black, counts as 2 blacks for the invariant
51 | BBlack -- Double Black, counts as 2 blacks for the invariant
@@ -63,7 +60,7 @@ showNColor c =
63 BBlack -> "BBlack"
60 BBlack -> "BBlack"
64 NBlack -> "NBlack"
61 NBlack -> "NBlack"
65
62
66−data LeafColor
63+type LeafColor
67 = LBlack
64 = LBlack
68 | LBBlack -- Double Black, counts as 2
65 | LBBlack -- Double Black, counts as 2
69
66
@@ -72,7 +69,7 @@ showLColor c = case c of
72 LBlack -> "LBlack"
69 LBlack -> "LBlack"
73 LBBlack -> "LBBlack"
70 LBBlack -> "LBBlack"
74
71
75−data Dict k v
72+type Dict k v
76 = RBNode NColor k v (Dict k v) (Dict k v)
73 = RBNode NColor k v (Dict k v) (Dict k v)
77 | RBEmpty LeafColor
74 | RBEmpty LeafColor
78
75
@@ -160,7 +157,6 @@ getOrFail k t =
160
157
161{-| Determine if a key is in a dictionary. -}
158{-| Determine if a key is in a dictionary. -}
162member : comparable -> Dict comparable v -> Bool
159member : comparable -> Dict comparable v -> Bool
163−-- Does t contain k?
164member k t = isJust <| get k t
160member k t = isJust <| get k t
165
161
166ensureBlackRoot : Dict k v -> Dict k v
162ensureBlackRoot : Dict k v -> Dict k v
@@ -182,7 +178,8 @@ remove : comparable -> Dict comparable v -> Dict comparable v
182remove k t = let u _ = Nothing in
178remove k t = let u _ = Nothing in
183 update k u t
179 update k u t
184
180
185−data Flag = Insert | Remove | Same
181+type Flag = Insert | Remove | Same
182+
186showFlag : Flag -> String
183showFlag : Flag -> String
187showFlag f = case f of
184showFlag f = case f of
188 Insert -> "Insert"
185 Insert -> "Insert"
libraries/Either.elm+3−1
@@ -23,7 +23,9 @@ This can also be used for error handling `(Either String a)` where
23error messages are stored on the left, and the correct values
23error messages are stored on the left, and the correct values
24(&ldquo;right&rdquo; values) are stored on the right.
24(&ldquo;right&rdquo; values) are stored on the right.
25-}
25-}
26−data Either a b = Left a | Right b
26+type Either a b
27+ = Left a
28+ | Right b
27
29
28{-| Apply the first function to a `Left` and the second function to a `Right`.
30{-| Apply the first function to a `Left` and the second function to a `Right`.
29This allows the extraction of a value from an `Either`.
31This allows the extraction of a value from an `Either`.
libraries/Graphics/Collage.elm+39−39
@@ -40,40 +40,40 @@ import Graphics.Element (Element)
40import Color (Color, black, Gradient)
40import Color (Color, black, Gradient)
41import Maybe (Maybe)
41import Maybe (Maybe)
42
42
43−type Form = {
43+type alias Form =
44− theta : Float,
44+ { theta : Float
45− scale : Float,
45+ , scale : Float
46− x : Float,
46+ , x : Float
47− y : Float,
47+ , y : Float
48− alpha : Float,
48+ , alpha : Float
49− form : BasicForm
49+ , form : BasicForm
50− }
50+ }
51−
51+
52−data FillStyle
52+type FillStyle
53− = Solid Color
53+ = Solid Color
54− | Texture String
54+ | Texture String
55− | Grad Gradient
55+ | Grad Gradient
56
56
57{-| The shape of the ends of a line. -}
57{-| The shape of the ends of a line. -}
58−data LineCap = Flat | Round | Padded
58+type LineCap = Flat | Round | Padded
59
59
60{-| The shape of the &ldquo;joints&rdquo; of a line, where each line segment
60{-| The shape of the &ldquo;joints&rdquo; of a line, where each line segment
61meets. `Sharp` takes an argument to limit the length of the joint. This
61meets. `Sharp` takes an argument to limit the length of the joint. This
62defaults to 10.
62defaults to 10.
63-}
63-}
64−data LineJoin = Smooth | Sharp Float | Clipped
64+type LineJoin = Smooth | Sharp Float | Clipped
65
65
66{-| All of the attributes of a line style. This lets you build up a line style
66{-| All of the attributes of a line style. This lets you build up a line style
67however you want. You can also update existing line styles with record updates.
67however you want. You can also update existing line styles with record updates.
68-}
68-}
69−type LineStyle = {
69+type alias LineStyle =
70− color : Color,
70+ { color : Color
71− width : Float,
71+ , width : Float
72− cap : LineCap,
72+ , cap : LineCap
73− join : LineJoin,
73+ , join : LineJoin
74− dashing : [Int],
74+ , dashing : [Int]
75− dashOffset : Int
75+ , dashOffset : Int
76− }
76+ }
77
77
78{-| The default line style, which is solid black with flat caps and sharp joints.
78{-| The default line style, which is solid black with flat caps and sharp joints.
79You can use record updates to build the line style you
79You can use record updates to build the line style you
@@ -82,14 +82,14 @@ want. For example, to make a thicker line, you could say:
82 { defaultLine | width <- 10 }
82 { defaultLine | width <- 10 }
83-}
83-}
84defaultLine : LineStyle
84defaultLine : LineStyle
85−defaultLine = {
85+defaultLine =
86− color = black,
86+ { color = black
87− width = 1,
87+ , width = 1
88− cap = Flat,
88+ , cap = Flat
89− join = Sharp 10,
89+ , join = Sharp 10
90− dashing = [],
90+ , dashing = []
91− dashOffset = 0
91+ , dashOffset = 0
92− }
92+ }
93
93
94{-| Create a solid line style with a given color. -}
94{-| Create a solid line style with a given color. -}
95solid : Color -> LineStyle
95solid : Color -> LineStyle
@@ -103,12 +103,12 @@ dashed clr = { defaultLine | color <- clr, dashing <- [8,4] }
103dotted : Color -> LineStyle
103dotted : Color -> LineStyle
104dotted clr = { defaultLine | color <- clr, dashing <- [3,3] }
104dotted clr = { defaultLine | color <- clr, dashing <- [3,3] }
105
105
106−data BasicForm
106+type BasicForm
107− = FPath LineStyle Path
107+ = FPath LineStyle Path
108− | FShape (Either LineStyle FillStyle) Shape
108+ | FShape (Either LineStyle FillStyle) Shape
109− | FImage Int Int (Int,Int) String
109+ | FImage Int Int (Int,Int) String
110− | FElement Element
110+ | FElement Element
111− | FGroup Transform2D [Form]
111+ | FGroup Transform2D [Form]
112
112
113form : BasicForm -> Form
113form : BasicForm -> Form
114form f = { theta=0, scale=1, x=0, y=0, alpha=1, form=f }
114form f = { theta=0, scale=1, x=0, y=0, alpha=1, form=f }
@@ -204,7 +204,7 @@ collage : Int -> Int -> [Form] -> Element
204collage = Native.Graphics.Collage.collage
204collage = Native.Graphics.Collage.collage
205
205
206
206
207−type Path = [(Float,Float)]
207+type alias Path = [(Float,Float)]
208
208
209{-| Create a path that follows a sequence of points. -}
209{-| Create a path that follows a sequence of points. -}
210path : [(Float,Float)] -> Path
210path : [(Float,Float)] -> Path
@@ -214,7 +214,7 @@ path ps = ps
214segment : (Float,Float) -> (Float,Float) -> Path
214segment : (Float,Float) -> (Float,Float) -> Path
215segment p1 p2 = [p1,p2]
215segment p1 p2 = [p1,p2]
216
216
217−type Shape = [(Float,Float)]
217+type alias Shape = [(Float,Float)]
218
218
219{-| Create an arbitrary polygon by specifying its corners in order.
219{-| Create an arbitrary polygon by specifying its corners in order.
220`polygon` will automatically close all shapes, so the given list
220`polygon` will automatically close all shapes, so the given list
libraries/Graphics/Element.elm+22−14
@@ -43,7 +43,7 @@ import List as List
43import Color (..)
43import Color (..)
44import Maybe ( Maybe(..) )
44import Maybe ( Maybe(..) )
45
45
46−type Properties = {
46+type alias Properties = {
47 id : Int,
47 id : Int,
48 width : Int,
48 width : Int,
49 height : Int,
49 height : Int,
@@ -55,7 +55,10 @@ type Properties = {
55 click : ()
55 click : ()
56 }
56 }
57
57
58+type alias Element =
59+ { props : Properties
58−type Element = { props : Properties, element : ElementPrim }
60+ , element : ElementPrim
61+ }
59
62
60{-| An Element that takes up no space. Good for things that appear conditionally:
63{-| An Element that takes up no space. Good for things that appear conditionally:
61
64
@@ -130,15 +133,15 @@ newElement w h e =
130 , element = e
133 , element = e
131 }
134 }
132
135
133−data ElementPrim
136+type ElementPrim
134− = Image ImageStyle Int Int String
137+ = Image ImageStyle Int Int String
135− | Container Position Element
138+ | Container Position Element
136− | Flow Direction [Element]
139+ | Flow Direction [Element]
137− | Spacer
140+ | Spacer
138− | RawHtml
141+ | RawHtml
139− | Custom -- for custom Elements implemented in JS, see collage for example
142+ | Custom -- for custom Elements implemented in JS, see collage for example
140
143
141−data ImageStyle = Plain | Fitted | Cropped (Int,Int) | Tiled
144+type ImageStyle = Plain | Fitted | Cropped (Int,Int) | Tiled
142
145
143{-| Create an image given a width, height, and image source. -}
146{-| Create an image given a width, height, and image source. -}
144image : Int -> Int -> String -> Element
147image : Int -> Int -> String -> Element
@@ -164,9 +167,14 @@ tiledImage : Int -> Int -> String -> Element
164tiledImage w h src =
167tiledImage w h src =
165 newElement w h (Image Tiled w h src)
168 newElement w h (Image Tiled w h src)
166
169
167−data Three = P | Z | N
170+type Three = P | Z | N
168−data Pos = Absolute Int | Relative Float
171+type Pos = Absolute Int | Relative Float
172+type alias Position =
169−type Position = { horizontal : Three, vertical : Three, x : Pos, y : Pos }
173+ { horizontal : Three
174+ , vertical : Three
175+ , x : Pos
176+ , y : Pos
177+ }
170
178
171{-| Put an element in a container. This lets you position the element really
179{-| Put an element in a container. This lets you position the element really
172easily, and there are tons of ways to set the `Position`.
180easily, and there are tons of ways to set the `Position`.
@@ -185,7 +193,7 @@ for making borders.
185spacer : Int -> Int -> Element
193spacer : Int -> Int -> Element
186spacer w h = newElement w h Spacer
194spacer w h = newElement w h Spacer
187
195
188−data Direction = DUp | DDown | DLeft | DRight | DIn | DOut
196+type Direction = DUp | DDown | DLeft | DRight | DIn | DOut
189
197
190{-| Have a list of elements flow in a particular direction.
198{-| Have a list of elements flow in a particular direction.
191The `Direction` starts from the first element in the list.
199The `Direction` starts from the first element in the list.
libraries/Graphics/Input.elm+2−2
@@ -42,9 +42,9 @@ of two fields:
42
42
43This will make more sense as you see more examples.
43This will make more sense as you see more examples.
44-}
44-}
45−type Input a = { signal : Signal a, handle : Handle a }
45+type alias Input a = { signal : Signal a, handle : Handle a }
46
46
47−data Handle a = Handle
47+type Handle a = Handle
48
48
49{-| This creates a new `Input`. You provide a single argument that will serve
49{-| This creates a new `Input`. You provide a single argument that will serve
50as the initial value of the input&rsquo;s `signal`. For example:
50as the initial value of the input&rsquo;s `signal`. For example:
libraries/Graphics/Input/Field.elm+36−17
@@ -40,7 +40,12 @@ dimensions such that the left and right are twice as wide as the top and bottom:
40 myDimensions : Int -> Dimensions
40 myDimensions : Int -> Dimensions
41 myDimensions n = { left = 2 * n, right = 2 * n, top = n, bottom = n }
41 myDimensions n = { left = 2 * n, right = 2 * n, top = n, bottom = n }
42-}
42-}
43−type Dimensions = { left:Int, right:Int, top:Int, bottom:Int }
43+type alias Dimensions =
44+ { left:Int
45+ , right:Int
46+ , top:Int
47+ , bottom:Int
48+ }
44
49
45{-| A field can have a outline around it. This lets you set its color, width,
50{-| A field can have a outline around it. This lets you set its color, width,
46and radius. The radius allows you to round the corners of your field. Set the
51and radius. The radius allows you to round the corners of your field. Set the
@@ -49,7 +54,11 @@ and thin with slightly rounded corners:
49
54
50 { color = grey, width = uniformly 1, radius = 4 }
55 { color = grey, width = uniformly 1, radius = 4 }
51-}
56-}
57+type alias Outline =
58+ { color:Color
52−type Outline = { color:Color, width:Dimensions, radius:Int }
59+ , width:Dimensions
60+ , radius:Int
61+ }
53
62
54{-| An outline with zero width, so you cannot see it. -}
63{-| An outline with zero width, so you cannot see it. -}
55noOutline : Outline
64noOutline : Outline
@@ -62,7 +71,10 @@ is blue and thin:
62
71
63 { color = blue, width = 1 }
72 { color = blue, width = 1 }
64-}
73-}
65−type Highlight = { color:Color, width:Int }
74+type alias Highlight =
75+ { color:Color
76+ , width:Int
77+ }
66
78
67{-| An highlight with zero width, so you cannot see it. -}
79{-| An highlight with zero width, so you cannot see it. -}
68noHighlight : Highlight
80noHighlight : Highlight
@@ -81,12 +93,12 @@ from the total height to determine how much room there is for text. The
81`padding` and `outline` appear on the top and bottom, so there will be 28
93`padding` and `outline` appear on the top and bottom, so there will be 28
82vertical pixels remaining for the text (40 - 1 - 5 - 5 - 1).
94vertical pixels remaining for the text (40 - 1 - 5 - 5 - 1).
83-}
95-}
84−type Style =
96+type alias Style =
85− { padding : Dimensions
97+ { padding : Dimensions
86− , outline : Outline
98+ , outline : Outline
87− , highlight : Highlight
99+ , highlight : Highlight
88− , style : Text.Style
100+ , style : Text.Style
89− }
101+ }
90
102
91{-| The default style for a text field. The outline is `Color.grey` with width
103{-| The default style for a text field. The outline is `Color.grey` with width
921 and radius 2. The highlight is `Color.blue` with width 1, and the default
1041 and radius 2. The highlight is `Color.blue` with width 1, and the default
@@ -94,11 +106,11 @@ text color is black.
94-}
106-}
95defaultStyle : Style
107defaultStyle : Style
96defaultStyle =
108defaultStyle =
97− { padding = uniformly 4
109+ { padding = uniformly 4
98− , outline = Outline Color.grey (uniformly 1) 2
110+ , outline = Outline Color.grey (uniformly 1) 2
99− , highlight = Highlight Color.blue 1
111+ , highlight = Highlight Color.blue 1
100− , style = Text.defaultStyle
112+ , style = Text.defaultStyle
101− }
113+ }
102
114
103{-| Represents the current content of a text field. For example:
115{-| Represents the current content of a text field. For example:
104
116
@@ -107,7 +119,10 @@ defaultStyle =
107This means the user highlighted the substring `"She"` backwards. The value of
119This means the user highlighted the substring `"She"` backwards. The value of
108`content.string` is `"She sells sea shells"`.
120`content.string` is `"She sells sea shells"`.
109-}
121-}
122+type alias Content =
123+ { string:String
110−type Content = { string:String, selection:Selection }
124+ , selection:Selection
125+ }
111
126
112{-| The selection within a text field. `start` is never greater than `end`:
127{-| The selection within a text field. `start` is never greater than `end`:
113
128
@@ -116,14 +131,18 @@ type Content = { string:String, selection:Selection }
116 Selection 5 9 Backward -- highlighting characters starting after
131 Selection 5 9 Backward -- highlighting characters starting after
117 -- the 5th and ending after the 9th
132 -- the 5th and ending after the 9th
118-}
133-}
134+type alias Selection =
135+ { start:Int
136+ , end:Int
119−type Selection = { start:Int, end:Int, direction:Direction }
137+ , direction:Direction
138+ }
120
139
121{-| The direction of selection. When the user highlights a selection in a text
140{-| The direction of selection. When the user highlights a selection in a text
122field, they must do it in a particular direction. This determines which end of
141field, they must do it in a particular direction. This determines which end of
123the selection moves when they change the selection by pressing Shift-Left or
142the selection moves when they change the selection by pressing Shift-Left or
124Shift-Right.
143Shift-Right.
125-}
144-}
126−data Direction = Forward | Backward
145+type Direction = Forward | Backward
127
146
128{-| A field with no content:
147{-| A field with no content:
129
148
libraries/Http.elm+5−2
@@ -18,9 +18,12 @@ import Native.Http
18{-| The datatype for responses. Success contains only the returned message.
18{-| The datatype for responses. Success contains only the returned message.
19Failures contain both an error code and an error message.
19Failures contain both an error code and an error message.
20-}
20-}
21+type Response a
22+ = Success a
23+ | Waiting
21−data Response a = Success a | Waiting | Failure Int String
24+ | Failure Int String
22
25
23−type Request a = {
26+type alias Request a = {
24 verb : String,
27 verb : String,
25 url : String,
28 url : String,
26 body : a,
29 body : a,
libraries/JavaScript/Experimental.elm+1−1
@@ -12,7 +12,7 @@ import Native.JavaScript
12import Native.Json
12import Native.Json
13import Json
13import Json
14
14
15−data RawObject = RawObject
15+type RawObject = RawObject
16
16
17{-| Turn arbitrary JavaScript objects into Elm records.
17{-| Turn arbitrary JavaScript objects into Elm records.
18Arrays are converted into lists, nested objects are allowed.
18Arrays are converted into lists, nested objects are allowed.
libraries/Json.elm+1−1
@@ -19,7 +19,7 @@ through ports, and the runtime will do a conversion like this:
19JSON is an intentional subset of JavaScript values which excludes functions.
19JSON is an intentional subset of JavaScript values which excludes functions.
20This ensures that impure functions cannot sneak into Elm through ports.
20This ensures that impure functions cannot sneak into Elm through ports.
21-}
21-}
22−data Value
22+type Value
23 = String String
23 = String String
24 | Number Float
24 | Number Float
25 | Boolean Bool
25 | Boolean Bool
libraries/Keyboard.elm+1−1
@@ -25,7 +25,7 @@ import Native.Keyboard
25in this library. Use `Char.toCode` and `Char.fromCode` to convert key codes
25in this library. Use `Char.toCode` and `Char.fromCode` to convert key codes
26to characters. Use the uppercase character with `toCode`.
26to characters. Use the uppercase character with `toCode`.
27-}
27-}
28−type KeyCode = Int
28+type alias KeyCode = Int
29
29
30{-| Custom key directions to support different locales. The order is up, down,
30{-| Custom key directions to support different locales. The order is up, down,
31left, right.
31left, right.
libraries/Maybe.elm+1−1
@@ -16,7 +16,7 @@ module Maybe (Maybe(..), maybe, isJust, isNothing, map) where
16result in a value (e.g. logarithm is defined only for positive
16result in a value (e.g. logarithm is defined only for positive
17numbers).
17numbers).
18-}
18-}
19−data Maybe a = Just a | Nothing
19+type Maybe a = Just a | Nothing
20
20
21{-| Provide a default value and a function to extract the contents of a `Maybe`.
21{-| Provide a default value and a function to extract the contents of a `Maybe`.
22When given `Nothing` you get the default, when given a `Just` you apply the
22When given `Nothing` you get the default, when given a `Just` you apply the
libraries/Regex.elm+8−3
@@ -20,7 +20,7 @@ and [`replace`](#replace).
20import Maybe (Maybe)
20import Maybe (Maybe)
21import Native.Regex
21import Native.Regex
22
22
23−data Regex = Regex
23+type Regex = Regex
24
24
25{-| Escape strings to be regular expressions, making all special characters
25{-| Escape strings to be regular expressions, making all special characters
26safe. So `regex (escape "^a+")` will match exactly `"^a+"` instead of a series
26safe. So `regex (escape "^a+")` will match exactly `"^a+"` instead of a series
@@ -73,13 +73,18 @@ Here are details on each field:
73 This is useful when paired with `replace All` if replacement is dependent on how
73 This is useful when paired with `replace All` if replacement is dependent on how
74 many times a pattern has appeared before.
74 many times a pattern has appeared before.
75-}
75-}
76+type alias Match =
77+ { match : String
76−type Match = { match : String, submatches : [Maybe String], index : Int, number : Int }
78+ , submatches : [Maybe String]
79+ , index : Int
80+ , number : Int
81+ }
77
82
78{-| `HowMany` is used to specify how many matches you want to make. So
83{-| `HowMany` is used to specify how many matches you want to make. So
79`replace All` would replace every match, but `replace (AtMost 2)` would
84`replace All` would replace every match, but `replace (AtMost 2)` would
80replace at most two matches (i.e. zero, one, two, but never three or more).
85replace at most two matches (i.e. zero, one, two, but never three or more).
81-}
86-}
82−data HowMany = All | AtMost Int
87+type HowMany = All | AtMost Int
83
88
84{-| Find matches in a string:
89{-| Find matches in a string:
85
90
libraries/Set.elm+1−1
@@ -36,7 +36,7 @@ import Maybe (Maybe)
36import Dict as Dict
36import Dict as Dict
37import List as List
37import List as List
38
38
39−type Set t = Dict.Dict t ()
39+type alias Set t = Dict.Dict t ()
40
40
41{-| Create an empty set. -}
41{-| Create an empty set. -}
42empty : Set comparable
42empty : Set comparable
libraries/Signal.elm+1−1
@@ -33,7 +33,7 @@ import Native.Signal
33import List (foldr, (::))
33import List (foldr, (::))
34import Basics (fst, snd, not)
34import Basics (fst, snd, not)
35
35
36−data Signal a = Signal
36+type Signal a = Signal
37
37
38{-| Create a constant signal that never changes. -}
38{-| Create a constant signal that never changes. -}
39constant : a -> Signal a
39constant : a -> Signal a
libraries/Text.elm+3−3
@@ -38,7 +38,7 @@ import Maybe (Maybe(Nothing))
38import Native.Show
38import Native.Show
39import Native.Text
39import Native.Text
40
40
41−data Text = Text
41+type Text = Text
42
42
43{-| Styles for lines on text. This allows you to add an underline, an overline,
43{-| Styles for lines on text. This allows you to add an underline, an overline,
44or a strike out text:
44or a strike out text:
@@ -47,7 +47,7 @@ or a strike out text:
47 line Over (toText "overline")
47 line Over (toText "overline")
48 line Through (toText "strike out")
48 line Through (toText "strike out")
49-}
49-}
50−data Line = Under | Over | Through
50+type Line = Under | Over | Through
51
51
52{-| Represents all the ways you can style `Text`. If the `typeface` list is
52{-| Represents all the ways you can style `Text`. If the `typeface` list is
53empty or the `height` is `Nothing`, the users will fall back on their browser's
53empty or the `height` is `Nothing`, the users will fall back on their browser's
@@ -62,7 +62,7 @@ Times New Roman (assuming that typeface is available on the user's computer):
62 , line = Just Under
62 , line = Just Under
63 }
63 }
64-}
64-}
65−type Style =
65+type alias Style =
66 { typeface : [String]
66 { typeface : [String]
67 , height : Maybe Float
67 , height : Maybe Float
68 , color : Color
68 , color : Color
libraries/Time.elm+1−1
@@ -21,7 +21,7 @@ import Signal (Signal)
21{-| Type alias to make it clearer when you are working with time values.
21{-| Type alias to make it clearer when you are working with time values.
22Using the `Time` constants instead of raw numbers is very highly recommended.
22Using the `Time` constants instead of raw numbers is very highly recommended.
23-}
23-}
24−type Time = Float
24+type alias Time = Float
25
25
26{-| Units of time, making it easier to specify things like a half-second
26{-| Units of time, making it easier to specify things like a half-second
27`(500 * milliseconds)` without remembering Elm&rsquo;s underlying units of time.
27`(500 * milliseconds)` without remembering Elm&rsquo;s underlying units of time.
libraries/Touch.elm+8−1
@@ -21,7 +21,14 @@ A touch also keeps info about the initial point and time of contact:
21`x0`, `y0`, and `t0`. This helps compute more complicated gestures
21`x0`, `y0`, and `t0`. This helps compute more complicated gestures
22like taps, drags, and swipes which need to know about timing or direction.
22like taps, drags, and swipes which need to know about timing or direction.
23-}
23-}
24−type Touch = { x:Int, y:Int, id:Int, x0:Int, y0:Int, t0:Time }
24+type alias Touch =
25+ { x:Int
26+ , y:Int
27+ , id:Int
28+ , x0:Int
29+ , y0:Int
30+ , t0:Time
31+ }
25
32
26{-| A list of ongoing touches. -}
33{-| A list of ongoing touches. -}
27touches : Signal [Touch]
34touches : Signal [Touch]
libraries/Trampoline.elm+3−1
@@ -42,7 +42,9 @@ stack overflow. We can rewrite it as follows:
42
42
43Now it uses a trampoline and can recurse without growing the stack!
43Now it uses a trampoline and can recurse without growing the stack!
44-}
44-}
45+type Trampoline a
46+ = Done a
45−data Trampoline a = Done a | Continue (() -> Trampoline a)
47+ | Continue (() -> Trampoline a)
46
48
47{-| Evaluate a trampolined value in constant space. -}
49{-| Evaluate a trampolined value in constant space. -}
48trampoline : Trampoline a -> a
50trampoline : Trampoline a -> a
libraries/Transform2D.elm+1−1
@@ -22,7 +22,7 @@ always `0 0 1` in these matrices, it is omitted in the diagrams below.
22
22
23import Native.Transform2D
23import Native.Transform2D
24
24
25−data Transform2D = Transform2D
25+type Transform2D = Transform2D
26
26
27{-| Create an identity transform. Transforming by the identity does
27{-| Create an identity transform. Transforming by the identity does
28not change anything, but it can come in handy as a default or
28not change anything, but it can come in handy as a default or