mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-24 20:23:11 +03:00
30 lines
663 B
Idris
30 lines
663 B
Idris
|
data View : List a -> Type where
|
||
|
Nil : View []
|
||
|
(::) : (x : a) -> (xs : List a) -> View (x :: xs)
|
||
|
|
||
|
view : (xs : List a) -> View xs
|
||
|
view [] = []
|
||
|
view (x :: xs) = x :: xs
|
||
|
|
||
|
idL : (xs : List a) -> View xs -> List a
|
||
|
idL .([]) [] = []
|
||
|
idL .(x :: xs) (x :: xs) = x :: idL xs (view xs)
|
||
|
|
||
|
{- Current compile time tree:
|
||
|
|
||
|
Compile time tree: case {arg:1} of
|
||
|
Nil {e:0} => case {arg:2} of
|
||
|
Nil {e:4} => []
|
||
|
(::) {e:1} {e:2} {e:3} => case {arg:2} of
|
||
|
(::) {e:5} {e:6} {e:7} => {e:2} :: idL {e:3} (view {e:3})
|
||
|
|
||
|
-}
|
||
|
|
||
|
{- With dotted expressions change:
|
||
|
|
||
|
Compile time tree: case {arg:2} of
|
||
|
Nil {e:0} => []
|
||
|
(::) {e:1} {e:2} {e:3} => {e:2} :: idL {e:3} (view {e:3})
|
||
|
|
||
|
-}
|