let Methods : Type -> Type = \(s : Type) -> { get : s -> Natural, next : s -> s, init : s } let Stream : Type = forall (r : Type) -> (forall (s : Type) -> Methods s -> r) -> r let FibState : Type = { prev : Natural, now : Natural } let fibGet : FibState -> Natural = \(s : FibState) -> s.now let fibNext : FibState -> FibState = \(s : FibState) -> { prev = s.now, now = s.prev + s.now } let fibInit : FibState = { prev = 0, now = 1 } let fibs : Stream = \(r : Type) -> \(k : forall (s : Type) -> Methods s -> r) -> k FibState { get = fibGet, next = fibNext, init = fibInit } let fourth : Natural = fibs Natural ( \(s : Type) -> \(m : Methods s) -> m.get (m.next (m.next (m.next m.init))) ) let nthFib : Natural -> Natural = \(n : Natural) -> fibs Natural ( \(s : Type) -> \(m : Methods s) -> m.get (Natural/fold n s m.next m.init) ) let map = https://prelude.dhall-lang.org/List/map in map Natural Natural nthFib [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]