File: module-spec2.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 (37 lines) | stat: -rw-r--r-- 537 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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- Higher-order module spec.
-- ==
-- input { 3 } output { 12 }

module type MT1 = {
  val f: i32 -> i32 -> i32
}

module type MT2 = {
  val g: i32 -> i32
}

module type MT3 = {
  module T: MT1 -> MT2
}

module MT3_twice: MT3 = {
  module T(P: MT1): MT2 = {
    def g (x: i32) = P.f x x
  }
}

module  MT1_plus: MT1 = {
  def f (x: i32) (y: i32) = x + y
}

module M = {
  module T(P: MT3) = {
    module P_T_I = P.T MT1_plus

    def g(x: i32) = P_T_I.g x
  }
}

module MT_I = M.T MT3_twice

def main(x: i32) = MT1_plus.f x x + MT_I.g x