Idris2-boot/tests/idris2/basic009/LetCase.idr
Edwin Brady 00514887c4 More base libraries
This has shown up a problem with 'case' which is hard to fix - since it
works by generating a function with the appropriate type, it's hard to
ensure that let bindings computational behaviour is propagated while
maintaining appropriate dependencies between arguments and keeping the
let so that it only evaluates once. So, I've disabled the computational
behaviour of 'let' inside case blocks. I hope this isn't a big
inconvenience (there are workarounds if it's ever needed, anyway).
2019-06-30 23:54:50 +01:00

29 lines
619 B
Idris

import Stuff
data IsSuc : Nat -> Type where
Yes : IsSuc (S x)
pred : (x : Nat) -> IsSuc x -> Nat
pred (S x) Yes = x
test1 : Nat -> Nat
test1 x = let y = S (S x) in
case x of
res => pred y ?foo
-- Propagating let binding's computational behaviour through case is
-- not supported, sorry!
{-
data Vect : Nat -> Type -> Type where
Nil : Vect Z a
(::) : a -> Vect k a -> Vect (S k) a
test2 : Nat -> Nat -> Nat
test2 x@(S Z) y
= case y of
res =>
let fn : Vect (S Z) Nat -> Nat
fn ys = ?bar
in pred x Yes
-}