@@ -14,8 +14,6 @@ module Dhall.Lint
14
14
, fixAssert
15
15
, fixParentPath
16
16
, removeLetInLet
17
- , replaceOptionalBuildFold
18
- , replaceSaturatedOptionalFold
19
17
, useToMap
20
18
) where
21
19
@@ -24,7 +22,6 @@ import Control.Applicative ((<|>))
24
22
import Dhall.Syntax
25
23
( Binding (.. )
26
24
, Chunks (.. )
27
- , Const (.. )
28
25
, Directory (.. )
29
26
, Expr (.. )
30
27
, File (.. )
@@ -51,20 +48,15 @@ import qualified Lens.Family
51
48
* fixes @let a = x ≡ y@ to be @let a = assert : x ≡ y@
52
49
* consolidates nested @let@ bindings to use a multiple-@let@ binding with 'removeLetInLet'
53
50
* fixes paths of the form @.\/..\/foo@ to @..\/foo@
54
- * Replaces deprecated @Optional\/fold@ and @Optional\/build@ built-ins
55
51
-}
56
52
lint :: Expr s Import -> Expr s Import
57
- lint = Dhall.Optics. rewriteOf subExpressions lowerPriorityRewrite
58
- . Dhall.Optics. rewriteOf subExpressions higherPriorityRewrite
53
+ lint = Dhall.Optics. rewriteOf subExpressions rewrite
59
54
where
60
- lowerPriorityRewrite e =
55
+ rewrite e =
61
56
fixAssert e
62
57
<|> removeUnusedBindings e
63
58
<|> fixParentPath e
64
59
<|> removeLetInLet e
65
- <|> replaceOptionalBuildFold e
66
-
67
- higherPriorityRewrite = replaceSaturatedOptionalFold
68
60
69
61
-- | Remove unused `Let` bindings.
70
62
removeUnusedBindings :: Eq a => Expr s a -> Maybe (Expr s a )
@@ -132,68 +124,6 @@ removeLetInLet :: Expr s a -> Maybe (Expr s a)
132
124
removeLetInLet (Let binding (Note _ l@ Let {})) = Just (Let binding l)
133
125
removeLetInLet _ = Nothing
134
126
135
- -- | This replaces @Optional/fold@ and @Optional/build@, both of which can be
136
- -- implemented within the language
137
- replaceOptionalBuildFold :: Expr s a -> Maybe (Expr s a )
138
- replaceOptionalBuildFold OptionalBuild =
139
- Just
140
- (Lam " a" (Const Type )
141
- (Lam " build"
142
- (Pi " optional" (Const Type )
143
- (Pi " some" (Pi " _" " a" " optional" )
144
- (Pi " none" " optional" " optional" )
145
- )
146
- )
147
- (App (App (App " build" (App Optional " a" )) (Lam " x" " a" (Some " x" ))) (App None " a" ))
148
- )
149
- )
150
- replaceOptionalBuildFold OptionalFold =
151
- Just
152
- (Lam " a" (Const Type )
153
- (Lam " o" (App Optional " a" )
154
- (Lam " optional" (Const Type )
155
- (Lam " some" (Pi " _" " a" " optional" )
156
- (Lam " none" " optional"
157
- (Merge
158
- (RecordLit
159
- [ (" Some" , " some" )
160
- , (" None" , " none" )
161
- ]
162
- )
163
- " o"
164
- Nothing
165
- )
166
- )
167
- )
168
- )
169
- )
170
- )
171
- replaceOptionalBuildFold _ =
172
- Nothing
173
-
174
- -- | This replaces a saturated @Optional/fold@ with the equivalent @merge@
175
- -- expression
176
- replaceSaturatedOptionalFold :: Expr s a -> Maybe (Expr s a )
177
- replaceSaturatedOptionalFold
178
- (App
179
- (Core. shallowDenote -> App
180
- (Core. shallowDenote -> App
181
- (Core. shallowDenote -> App
182
- (Core. shallowDenote -> App
183
- (Core. shallowDenote -> OptionalFold )
184
- _
185
- )
186
- o
187
- )
188
- _
189
- )
190
- some
191
- )
192
- none
193
- ) = Just (Merge (RecordLit [ (" Some" , some), (" None" , none) ]) o Nothing )
194
- replaceSaturatedOptionalFold _ =
195
- Nothing
196
-
197
127
-- | This replaces a record of key-value pairs with the equivalent use of
198
128
-- @toMap@
199
129
--
0 commit comments