File: lambda0.fut

package info (click to toggle)
haskell-futhark 0.25.32-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,236 kB
  • sloc: haskell: 100,484; ansic: 12,100; python: 3,440; yacc: 785; sh: 561; javascript: 558; lisp: 399; makefile: 272
file content (20 lines) | stat: -rw-r--r-- 549 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- Module-level lambdas, i.e., anonymous functors.
-- ==
-- input { 2 } output { 32 }

module type operation = { type t val f: t -> t }

module type repeater = (P:operation) -> operation with t = P.t

module twice: repeater = \(P: operation) -> {
  type t = P.t
  def f (x: P.t) = P.f (P.f x)
}

module type i32_operation = operation with t = i32

module times_2: i32_operation = { type t = i32 def f (x: i32) = x * 2 }
module times_4: i32_operation = twice(times_2)
module times_16: i32_operation = twice(times_4)

def main (x: i32) = times_16.f x