mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-22 11:13:36 +03:00
31 lines
636 B
Idris
31 lines
636 B
Idris
module Data.Linear.LList
|
|
|
|
import Data.Linear.Bifunctor
|
|
import Data.Linear.Interface
|
|
import Data.Linear.Notation
|
|
import Data.Linear.LNat
|
|
|
|
%default total
|
|
|
|
public export
|
|
data LList : Type -> Type where
|
|
Nil : LList a
|
|
(::) : a -@ LList a -@ LList a
|
|
|
|
%name LList xs, ys, zs, ws
|
|
|
|
export
|
|
length : Consumable a => LList a -@ LNat
|
|
length [] = Zero
|
|
length (x :: xs) = consume x `seq` length xs
|
|
|
|
export
|
|
Consumable a => Consumable (LList a) where
|
|
consume [] = ()
|
|
consume (x :: xs) = x `seq` consume xs
|
|
|
|
export
|
|
Duplicable a => Duplicable (LList a) where
|
|
duplicate [] = [[], []]
|
|
duplicate (x :: xs) = (::) <$> duplicate x <*> duplicate xs
|