-
Notifications
You must be signed in to change notification settings - Fork 375
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
[ prelude ] Add some lacking %tcinline
s
#3047
Conversation
a6194f1
to
1c91e7c
Compare
It's interesting. This one is rejected: %default total
data X : Type -> Type -> Type where
B : b -> X a b
R : X a b -> X b c -> X a c
Functor (X a) where
map f (B x) = B (f x)
map f (R x y) = R x (f <$> y) It's not following the arguments:
But changing it to The diff of the logs (just looking at totality:99) is:
I added an extra log message, printing out
In one case it doesn't look like it's matching up the variables. I'm curious what's up, but might not have time to get to it today. This is interesting though. I logged the sizeChange (it's hard to get at these nameless things from the REPL), and it looks like args are partitioned between the <$> call and the map call (in the case where we're going through <$>:
|
In case anyone is wondering why it is happening without the
It finds is a call to |
Look like the current behaviour is strange. I thought it just doesn't look inside unless it's |
You probably know most of this already, but my understanding of the situation: When it's checking totality, it goes through each of the functions on the graph and calculates the size changes. For example, if it is looking at When it looks at Below I'm using a simplified test case (to remove some extra variables): %default total
data X : Type -> Type where
R : X b -> X c -> X c
Functor X where
map f (R x y) = R x (f <$> y) When processing Main.map b' a f (R a {b} x y) =
R b' {b} x ((<$>) b' a X "Main.Functor implementation at..." f y) After normaization with tcinline turned on ( Main.map b' a f (R a {b} x y) =
R b' {b} x ((<$>) b' a X (MkFunctor X \{0 b'' : Type} -> \{0 a' : Type} => \(func : _) => \(arg : X a') => Main.map b'' a' func arg) f y) So the definition of the Now it goes into the mechanism at If you tcline the I considered tweaking %default total
data Foo = MkFoo Nat (Nat -> Nat)
bar : Foo -> Nat
bar (MkFoo k f) = f (k + 2)
foo, baz : Nat -> Nat
baz k = bar (MkFoo k (\x => foo x))
foo (S k) = baz k
foo Z = Z |
One further note: I think the implementation is marked |
Without this you may get weird wrong totality checker errors when using simple functions like
<$>
, you can see an example in the added test.