Commit 4343ba52 authored by Mike Ledger's avatar Mike Ledger

change syntax for docs again

parent 1a742e9d
......@@ -113,7 +113,7 @@ parseMapExpr =
mkLabel _ = const Error
term =
P.token (DocNum . fromInteger <$> P.decimal <|>
P.token (DocNum . fromInteger <$> (P.char '$' *> P.decimal) <|>
Label <$> P.stringLiteral)
<|> P.parens parseMapExpr
......@@ -214,9 +214,10 @@ interpret
=> MapExpr k a
-> V.Vector (Map.Map k a)
-> (Map.Map Text (Map.Map k a), Map.Map k a)
interpret me0 v = case runState (go me0) Map.empty of
(Result r, s) -> (getLabels s, r)
(_, s) -> (getLabels s, Map.empty)
interpret me0 v =
case runState (go me0) Map.empty of
(Result r, s) -> (getLabels s, r)
(_, s) -> (getLabels s, Map.empty)
where
takeLabel (Label l) = l
......@@ -244,9 +245,14 @@ interpret me0 v = case runState (go me0) Map.empty of
[] -> replicate i mempty
| otherwise = l
cols cs l = VU.foldr
(\i xs -> fromMaybe mempty (lv V.!? i) : xs) [] cs
where lv = V.fromList l
cols cs l =
VU.foldr
(\i xs -> fromMaybe mempty (lv V.!? i) : xs)
[]
cs
where
lv = V.fromList l
go :: MapExpr k a
-> State (Map.Map (MapExpr k a) (MapExpr k a)) (MapExpr k a)
......@@ -260,7 +266,7 @@ interpret me0 v = case runState (go me0) Map.empty of
modify' (Map.insert (Label k) a')
return a'
Label k -> return (Label k)
DocNum i -> ins (Result (v V.! (i - 1)))
DocNum i -> return (Result (v V.! (i - 1)))
Union a b -> ins =<< withResult2 Map.union <$> go a <*> go b
Difference a b -> ins =<< withResult2 Map.difference <$> go a <*> go b
Intersection a b -> ins =<< withResult2 Map.intersection <$> go a <*> go b
......@@ -273,7 +279,7 @@ interpret me0 v = case runState (go me0) Map.empty of
NonNullsOf a -> ins =<< withResult1 (Map.filter (not . null)) <$> go a
NullsOf a -> ins =<< withResult1 (Map.filter null) <$> go a
Keys a -> ins =<< withResult1 (Map.map (const [])) <$> go a
Pad i a -> ins =<< withResult1 (Map.map (pad i)) <$> go a
Pad i a -> ins =<< withResult1 (Map.map (pad (i - 1))) <$> go a
Columns cs a -> ins =<< withResult1 (Map.map (cols cs)) <$> go a
_ -> return me
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment