@@ -69,7 +69,7 @@ import Dhall.Parser (Src (..))
69
69
import Dhall.Syntax (Expr (.. ), Import )
70
70
import Dhall.TypeCheck (DetailedTypeError (.. ), TypeError )
71
71
import GHC.Generics
72
- import Lens.Micro (LensLike' )
72
+ import Lens.Micro (Lens' , lens )
73
73
import Lens.Micro.Extras (view )
74
74
import Prelude hiding (maybe , sequence )
75
75
import System.FilePath (takeDirectory )
@@ -112,22 +112,16 @@ defaultInputSettings = InputSettings
112
112
-- | Access the directory to resolve imports relative to.
113
113
--
114
114
-- @since 1.16
115
- rootDirectory
116
- :: (Functor f )
117
- => LensLike' f InputSettings FilePath
118
- rootDirectory k s =
119
- fmap (\ x -> s { _rootDirectory = x }) (k (_rootDirectory s))
115
+ rootDirectory :: Lens' InputSettings FilePath
116
+ rootDirectory = lens _rootDirectory (\ s x -> s { _rootDirectory = x })
120
117
121
118
-- | Access the name of the source to report locations from; this is
122
119
-- only used in error messages, so it's okay if this is a best guess
123
120
-- or something symbolic.
124
121
--
125
122
-- @since 1.16
126
- sourceName
127
- :: (Functor f )
128
- => LensLike' f InputSettings FilePath
129
- sourceName k s =
130
- fmap (\ x -> s { _sourceName = x}) (k (_sourceName s))
123
+ sourceName :: Lens' InputSettings FilePath
124
+ sourceName = lens _sourceName (\ s x -> s { _sourceName = x})
131
125
132
126
-- | @since 1.16
133
127
data EvaluateSettings = EvaluateSettings
@@ -153,59 +147,49 @@ defaultEvaluateSettings = EvaluateSettings
153
147
--
154
148
-- @since 1.16
155
149
startingContext
156
- :: (Functor f , HasEvaluateSettings s )
157
- => LensLike' f s (Dhall.Context. Context (Expr Src Void ))
158
- startingContext = evaluateSettings . l
159
- where
160
- l :: (Functor f )
161
- => LensLike' f EvaluateSettings (Dhall.Context. Context (Expr Src Void ))
162
- l k s = fmap (\ x -> s { _startingContext = x}) (k (_startingContext s))
150
+ :: (HasEvaluateSettings s )
151
+ => Lens' s (Dhall.Context. Context (Expr Src Void ))
152
+ startingContext =
153
+ evaluateSettings
154
+ . lens _startingContext (\ s x -> s { _startingContext = x})
163
155
164
156
-- | Access the custom substitutions.
165
157
--
166
158
-- @since 1.30
167
159
substitutions
168
- :: (Functor f , HasEvaluateSettings s )
169
- => LensLike' f s (Dhall.Substitution. Substitutions Src Void )
170
- substitutions = evaluateSettings . l
171
- where
172
- l :: (Functor f )
173
- => LensLike' f EvaluateSettings (Dhall.Substitution. Substitutions Src Void )
174
- l k s = fmap (\ x -> s { _substitutions = x }) (k (_substitutions s))
160
+ :: (HasEvaluateSettings s )
161
+ => Lens' s (Dhall.Substitution. Substitutions Src Void )
162
+ substitutions =
163
+ evaluateSettings
164
+ . lens _substitutions (\ s x -> s { _substitutions = x })
175
165
176
166
-- | Access the custom normalizer.
177
167
--
178
168
-- @since 1.16
179
169
normalizer
180
- :: (Functor f , HasEvaluateSettings s )
181
- => LensLike' f s (Maybe (Core. ReifiedNormalizer Void ))
182
- normalizer = evaluateSettings . l
183
- where
184
- l :: (Functor f )
185
- => LensLike' f EvaluateSettings (Maybe (Core. ReifiedNormalizer Void ))
186
- l k s = fmap (\ x -> s { _normalizer = x }) (k (_normalizer s))
170
+ :: (HasEvaluateSettings s )
171
+ => Lens' s (Maybe (Core. ReifiedNormalizer Void ))
172
+ normalizer =
173
+ evaluateSettings
174
+ . lens _normalizer (\ s x -> s { _normalizer = x })
187
175
188
176
-- | Access the HTTP manager initializer.
189
177
--
190
178
-- @since 1.36
191
179
newManager
192
- :: (Functor f , HasEvaluateSettings s )
193
- => LensLike' f s (IO Dhall.Import. Manager )
194
- newManager = evaluateSettings . l
195
- where
196
- l :: (Functor f )
197
- => LensLike' f EvaluateSettings (IO Dhall.Import. Manager )
198
- l k s = fmap (\ x -> s { _newManager = x }) (k (_newManager s))
180
+ :: (HasEvaluateSettings s )
181
+ => Lens' s (IO Dhall.Import. Manager )
182
+ newManager =
183
+ evaluateSettings
184
+ . lens _newManager (\ s x -> s { _newManager = x })
199
185
200
186
-- | @since 1.16
201
187
class HasEvaluateSettings s where
202
- evaluateSettings
203
- :: (Functor f )
204
- => LensLike' f s EvaluateSettings
188
+ evaluateSettings :: Lens' s EvaluateSettings
205
189
206
190
instance HasEvaluateSettings InputSettings where
207
- evaluateSettings k s =
208
- fmap ( \ x -> s { _evaluateSettings = x }) (k (_evaluateSettings s) )
191
+ evaluateSettings =
192
+ lens _evaluateSettings ( \ s x -> s { _evaluateSettings = x })
209
193
210
194
instance HasEvaluateSettings EvaluateSettings where
211
195
evaluateSettings = id
0 commit comments