Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix closure representation in the Nock backend #3105

Merged
merged 10 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Juvix/Compiler/Nockma/Language.hs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ makeLenses ''WithStack
makeLenses ''AtomInfo
makeLenses ''CellInfo

isCell :: Term a -> Bool
isCell = \case
TermCell {} -> True
_ -> False

isAtom :: Term a -> Bool
isAtom = not . isCell

atomHint :: Lens' (Atom a) (Maybe AtomHint)
atomHint = atomInfo . atomInfoHint

Expand Down Expand Up @@ -460,6 +468,12 @@ opAddress txt p = TermCell (txt @ OpAddress #. p)
opQuote :: (IsNock x) => Text -> x -> Term Natural
opQuote txt p = TermCell (txt @ OpQuote #. p)

opTrace :: Term Natural -> Term Natural
opTrace val = OpHint # (nockHintAtom NockHintPuts # val) # val

opTrace' :: Term Natural -> Term Natural -> Term Natural
paulcadman marked this conversation as resolved.
Show resolved Hide resolved
opTrace' msg val = OpHint # (nockNilTagged "opTrace'" # msg) # val

{-# COMPLETE Cell #-}

pattern Cell :: Term a -> Term a -> Cell a
Expand Down
Loading
Loading