-
Notifications
You must be signed in to change notification settings - Fork 259
Open
Description
I ran across an issue with termination checking a recursive function on a data-type using functional vectors, and have simplified to this mwe:
data Stuff (A : Set a) : Set a where
stuff : (i : ℕ) → Vector (Stuff A) i → Stuff A
mapStuff : (A → B) → Stuff A → Stuff B
mapStuff f (stuff i xs) = stuff i (Vector.map (mapStuff f) xs)The termination checker gets upset with the call to mapStuff f.
This simplifies to λ x → mapStuff f (xs x), which means the recursive call is smaller, so ideally it should pass the termination check.
Forcing this simplification by adding an inline pragma (without any change to the definition) resolves this:
map2 : (A → B) → ∀ {n} → Vector A n → Vector B n
map2 f xs = f ∘ xs
{-# INLINE map2 #-}
map2Stuff : (A → B) → Foo A → Foo B
map2Stuff f (stuff i xs) = stuff i (map2 (map2Stuff f) xs)This does rely on _∘_ being inlined also.
Metadata
Metadata
Assignees
Labels
No labels