on master help sign in
Merge pull request #1372 from elm-lang/dev
3a43888Evan Czaplicki
hints/recursive-alias.md+3−3
@@ -89,7 +89,7 @@ No matter what, the type of `Node n xs` is going to be `List`. There is no expan
89So let's return to wanting to represent a `Comment` that may have responses. There are a couple ways to do this:
89So let's return to wanting to represent a `Comment` that may have responses. There are a couple ways to do this:
90
90
91
91
92−### Obvious, but kind of annoying
92+### Obvious, but kind of annoying
93
93
94```elm
94```elm
95type Comment =
95type Comment =
@@ -133,7 +133,7 @@ upvote comment =
133 { comment | upvotes = 1 + comment.upvotes }
133 { comment | upvotes = 1 + comment.upvotes }
134```
134```
135
135
136−So rather than having to unwrap a `Comment` to do *anything* to it, you only have to do some unwrapping in the cases where you are doing something recusive. In practice, this means you will do less unwrapping which is nice.
136+So rather than having to unwrap a `Comment` to do *anything* to it, you only have to do some unwrapping in the cases where you are doing something recursive. In practice, this means you will do less unwrapping which is nice.
137
137
138
138
139## Mutually recursive type aliases
139## Mutually recursive type aliases
@@ -158,4 +158,4 @@ type SortBy = Time | Score | MostResponses
158
158
159When you try to expand `Comment` you have to expand `Responses` which needs to expand `Comment` which needs to expand `Responses`, etc.
159When you try to expand `Comment` you have to expand `Responses` which needs to expand `Comment` which needs to expand `Responses`, etc.
160
160
161−So this is just a fancy case of a self-recusive type alias. The solution is the same. Somewhere in that cycle, you need to define an actual `type` to end the infinite expansion.
161+So this is just a fancy case of a self-recursive type alias. The solution is the same. Somewhere in that cycle, you need to define an actual `type` to end the infinite expansion.
src/Reporting/Error/Helpers.hs+4−9
@@ -114,23 +114,18 @@ drawCycle :: [String] -> Doc
114drawCycle strings =
114drawCycle strings =
115 let
115 let
116 topLine =
116 topLine =
117− [ text "┌─────┐"
117+ text "┌─────┐"
118− , text "│ V"
119− ]
120
118
121 line str =
119 line str =
122− [ text "│ " <> dullyellow (text str)
120+ text "│ " <> dullyellow (text str)
123− ]
124
121
125 midLine =
122 midLine =
126− [ text "│ │"
123+ text "│ ↓"
127− , text "│ V"
128− ]
129
124
130 bottomLine =
125 bottomLine =
131 text "└─────┘"
126 text "└─────┘"
132 in
127 in
133− vcat (topLine ++ List.intercalate midLine (map line strings) ++ [ bottomLine ])
128+ vcat (topLine : List.intersperse midLine (map line strings) ++ [ bottomLine ])
134
129
135
130
136
131