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

Broken Eq List example #1045

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -354,5 +354,8 @@ toDictionaryPassing ::
[Constraint ResolvedDep (Type ResolvedDep ann)] ->
Expr ResolvedDep (Type ResolvedDep ann) ->
m (Expr ResolvedDep (Type ResolvedDep ann))
toDictionaryPassing env subs constraints expr =
runReaderT (toDictionaryPassingInternal env subs constraints expr) emptyPassDictEnv
toDictionaryPassing env subs constraints expr = do
tracePrettyM "expr" expr
newExpr <- runReaderT (toDictionaryPassingInternal env subs constraints expr) emptyPassDictEnv
tracePrettyM "toDictionaryPassing" newExpr
pure newExpr
16 changes: 15 additions & 1 deletion smol-modules/test/Test/Modules/InterpreterSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,21 @@ spec = do
"def main = show (Suc Zero)"
],
"\"S Z\""
)
){-,
( ["class Eq a { equals : a -> a -> Bool }",
"instance Eq Bool { \\a -> \\b -> a == b }",
"type List a = Nil | Cons a (List a)",
"instance (Eq a) => Eq (List a) { ",
"\\listA -> \\listB -> case ((listA, listB)) { ",
"(Nil, Nil) -> True,",
"(Cons a as, Cons b bs) -> ",
"if (equals a b) then (equals as bs) else False,",
"_ -> False } }",
"def main : Bool",
"def main = equals (Cons (True : Bool) Nil) (Cons (True : Bool) Nil)"

],
"True") -}
]
traverse_
( \(parts, expect) ->
Expand Down
8 changes: 7 additions & 1 deletion smol-modules/test/Test/Typecheck/ToDictionaryPassingSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ spec = do
]

-- the whole transformation basically
describe "toDictionaryPassing" $ do
fdescribe "toDictionaryPassing" $ do
traverse_
( \(constraints, parts, expectedParts) -> do
let input = joinText parts
Expand Down Expand Up @@ -217,5 +217,11 @@ spec = do
", _ -> \"\" } : Natural -> String); ",
"shownatural Zero"
]
),
( mempty,
["equals (Nil : List Bool) (Nil : List Bool)"],
["equals (Nil : List Bool) (Nil : List Bool)"]
)


]
19 changes: 19 additions & 0 deletions smol-modules/test/static/Eq.smol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ instance (Eq a) => Eq Maybe a {
}
}

type List a = Cons a (List a) | Nil

instance (Eq a) => Eq (List a) {
\listA -> \listB -> case ((listA, listB)) {
(Nil, Nil) -> True,
(Cons a as, Cons b bs) ->
if (equals a b) then (equals as bs) else False,
_ -> False }
}

test "whoa" { equals (Nil : List Bool) (Nil : List Bool) }

/*test "whoa" { equals (Cons (True : Bool) Nil) (Cons (True : Bool) Nil) } */






def useEqualsInt :
Bool
def useEqualsInt =
Expand Down
Loading