File tree Expand file tree Collapse file tree 1 file changed +20
-28
lines changed Expand file tree Collapse file tree 1 file changed +20
-28
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ evaluateExpression mpath evaluator handler expr =
126126
127127 eval' = normalForm <=< nixEvalExpr mpath
128128
129- argmap args = nvSet mempty ( M. fromList args)
129+ argmap args = nvSet mempty $ M. fromList args
130130
131131processResult
132132 :: forall e t f m a
@@ -135,34 +135,26 @@ processResult
135135 -> NValue t f m
136136 -> m a
137137processResult h val = do
138- opts :: Options <- asks ( view hasLens)
138+ opts :: Options <- asks $ view hasLens
139139 maybe
140140 (h val)
141- (\ (Text. splitOn " ." -> keys) -> go keys val)
141+ (\ (Text. splitOn " ." -> keys) -> processKeys keys val)
142142 (attr opts)
143143 where
144- go :: [Text ] -> NValue t f m -> m a
145- go [] v = h v
146- go ((Text. decimal -> Right (n," " )) : ks) v =
147- (\ case
148- NVList xs ->
149- list
150- h
151- go
152- ks
153- (xs !! n)
154- _ -> errorWithoutStackTrace $ " Expected a list for selector '" <> show n <> " ', but got: " <> show v
155- ) =<< demand v
156- go (k : ks) v =
157- (\ case
158- NVSet xs _ ->
159- maybe
160- (errorWithoutStackTrace $ toString $ " Set does not contain key '" <> k <> " '" )
161- (list
162- h
163- go
164- ks
165- )
166- (M. lookup k xs)
167- _ -> errorWithoutStackTrace $ toString $ " Expected a set for selector '" <> k <> " ', but got: " <> show v
168- ) =<< demand v
144+ processKeys :: [Text ] -> NValue t f m -> m a
145+ processKeys kys v =
146+ list
147+ (h v)
148+ (\ (k : ks) ->
149+ do
150+ v' <- demand v
151+ case (k, v') of
152+ (Text. decimal -> Right (n," " ), NVList xs) -> processKeys ks $ xs !! n
153+ (_, NVSet xs _) ->
154+ maybe
155+ (errorWithoutStackTrace $ toString $ " Set does not contain key '" <> k <> " '" )
156+ (processKeys ks)
157+ (M. lookup k xs)
158+ (_, _) -> errorWithoutStackTrace $ toString $ " Expected a set or list for selector '" <> k <> " ', but got: " <> show v
159+ )
160+ kys
You can’t perform that action at this time.
0 commit comments