Coming from Haskell, I was reading about Idris' story regarding laziness (non-strictness). I trolled the recent release notes, and found code akin to the following
myIf : (b : Bool) -> (t : Lazy a) -> (e : Lazy a) -> a
myIf True t e = t
myIf False t e = e
I wrote a simple factorial function to test it
myFact : Int -> Int
myFact n = myIf (n == 1) 1 (n * myFact (n-1))
I ran it and it worked!
> myFact 5
120 : Int
I decided to break it by changing the type signature of myIf
to
myIf : (b : Bool) -> a -> a -> a
I reloaded the idris
repl, and ran myFact 5
again expecting an infinite recursion. To my surprise, it still worked the same way!
Can idris figure out when it should avoid strictness? Why didn't this recurse forever?
I'm using Idris 0.9.15 and none of the release notes between now and the linked notes, mention any changes.