mirror of https://github.com/voidlizard/hbs2
wip, kinda function composition?
This commit is contained in:
parent
b8db094714
commit
f12f4d1e12
|
@ -942,7 +942,7 @@ internalEntries = do
|
||||||
_ -> throwIO (TypeCheckError @C nil)
|
_ -> throwIO (TypeCheckError @C nil)
|
||||||
|
|
||||||
entry $ bindMatch "dec" $ \case
|
entry $ bindMatch "dec" $ \case
|
||||||
[ LitIntVal n ] -> pure (mkInt (succ n))
|
[ LitIntVal n ] -> pure (mkInt (pred n))
|
||||||
_ -> throwIO (TypeCheckError @C nil)
|
_ -> throwIO (TypeCheckError @C nil)
|
||||||
|
|
||||||
entry $ bindMatch "map" $ \case
|
entry $ bindMatch "map" $ \case
|
||||||
|
@ -974,6 +974,16 @@ internalEntries = do
|
||||||
[ e, ListVal es ] -> pure (mkList (e:es))
|
[ e, ListVal es ] -> pure (mkList (e:es))
|
||||||
_ -> throwIO (BadFormException @C nil)
|
_ -> throwIO (BadFormException @C nil)
|
||||||
|
|
||||||
|
entry $ bindMatch "@" $ \syn -> do
|
||||||
|
case List.uncons (reverse syn) of
|
||||||
|
Nothing -> pure nil
|
||||||
|
Just (a, []) -> pure a
|
||||||
|
Just (a, fs) -> flip fix (a, fs) $ \next -> \case
|
||||||
|
(acc, []) -> pure acc
|
||||||
|
(acc, x:xs) -> do
|
||||||
|
acc' <- apply_ x [acc]
|
||||||
|
next (acc', xs)
|
||||||
|
|
||||||
brief "get tail of list"
|
brief "get tail of list"
|
||||||
$ args [arg "list" "list"]
|
$ args [arg "list" "list"]
|
||||||
$ desc "nil if the list is empty; error if not list"
|
$ desc "nil if the list is empty; error if not list"
|
||||||
|
|
Loading…
Reference in New Issue