Skip to content

Commit

Permalink
Redid simply typed lambda-calculus using DLists, which are lists with…
Browse files Browse the repository at this point in the history
… associativity on the nose.
  • Loading branch information
Alan Jeffrey committed Nov 2, 2011
1 parent e30ffa9 commit 1f5be9b
Show file tree
Hide file tree
Showing 10 changed files with 932 additions and 187 deletions.
11 changes: 8 additions & 3 deletions src/agda/FRP/JS/List.agda
@@ -1,5 +1,6 @@
open import FRP.JS.Nat using ( ℕ ; zero ; suc )
open import FRP.JS.Bool using ( Bool ; true ; false ; _∧_ )
open import FRP.JS.Maybe using ( Maybe ; just ; nothing )

module FRP.JS.List where

Expand Down Expand Up @@ -40,12 +41,16 @@ buildAppend as f (suc n) = buildAppend (f n ∷ as) f n
build : {α} {A : Set α} (ℕ A) List A
build = buildAppend []

length : {α} {A : Set α} List A
length = foldl (λ n a suc n) zero
len : {α} {A : Set α} List A
len = foldr (λ a n suc n) zero

lookup : {α} {A : Set α} List A Maybe A
lookup [] x = nothing
lookup (a ∷ as) zero = just a
lookup (a ∷ as) (suc n) = lookup as n

_≟[_]_ : {α β} {A : Set α} {B : Set β} List A (A B Bool) List B Bool
[] ≟[ p ] [] = true
(a ∷ as) ≟[ p ] (b ∷ bs) = (p a b) ∧ (as ≟[ p ] bs)
_ ≟[ p ] _ = false


0 comments on commit 1f5be9b

Please sign in to comment.