mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-09-21 22:17:19 +03:00
5ea6aa0520
The changes are as follows: + `print` is for putting showable things to STDOUT. + `printLn` is for putting showable things to STDOUT with a new line + `putCharLn` for putting a single character to STDOUT, with a new line. Effects has been updated accordingly.
25 lines
595 B
Idris
25 lines
595 B
Idris
-- This regtest tests for incorrect erasure from underapplied data constructors.
|
|
|
|
data T : Type where
|
|
C : Nat -> Nat -> Nat -> T
|
|
|
|
data Q : Type where
|
|
D : (Nat -> T) -> Q
|
|
|
|
-- The bug was here: (C 3 4) would compile to plain data,
|
|
-- not to a function that would expect another (albeit erased) argument.
|
|
f : Q
|
|
f = D (C 3 4)
|
|
|
|
proj : Nat -> Q -> Nat -> T
|
|
proj Z (D f) = f
|
|
proj (S n) q = proj n q
|
|
|
|
g : T -> Nat
|
|
g (C x y z) = x + y
|
|
|
|
-- Here, we'd apply the not-a-function to the erased argument 4,
|
|
-- which would make the program go wrong.
|
|
main : IO ()
|
|
main = printLn $ g (proj 3 f 4)
|