cons/nil for pair/unit in scheme backend
Some checks failed
Publish Playground / build (push) Has been cancelled
Publish Playground / deploy (push) Has been cancelled

This commit is contained in:
2026-03-18 17:28:58 -07:00
parent 5eb43f6252
commit cfdddbb002
4 changed files with 11 additions and 15 deletions

View File

@@ -146,12 +146,6 @@ compileTerm tm@(App _ _ _) = case funArgs tm of
if length' qs == length' args
then pure $ CConstr tag nm.baseName args' qs NilCon
else apply nm args' arity
-- REVIEW Slower for JS, faster for scheme. (2.88 vs 3.01)
-- but all of the "JS" diff is code gen?
-- Just (DCon tag info qs _) =>
-- if length' qs == length' args
-- then pure $ CConstr tag nm.baseName args' qs info
-- else apply nm args' arity
_ => apply nm args' arity
-- REVIEW maybe we want a different constructor for non-Ref applications?
(t, args) => do

View File

@@ -415,11 +415,14 @@ populateConInfo entries =
-- Boolean
| Just (a :: b :: Nil) => (setInfo a FalseCon :: setInfo b TrueCon :: Nil)
| Just entries => entries in
let (a :: b :: Nil) = entries | _ => entries in
fromMaybe entries $ checkNat entries <|> checkCons entries
-- let (Nothing) = checkNat entries | Just entries => entries in
-- let (Nothing) = checkNat entries | Just entries => entries in
-- entries
case entries of
a :: Nil => case countFields a of
0 => setInfo a NilCon :: Nil
2 => setInfo a ConsCon :: Nil
_ => entries
a :: b :: Nil =>
fromMaybe entries $ checkNat entries <|> checkCons entries
_ => entries
where
countFields : TopEntry Int
countFields (MkEntry fc name type def eflags) = go type