File: value-type-function5.fut

package info (click to toggle)
haskell-futhark 0.25.27-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 17,836 kB
  • sloc: haskell: 99,384; ansic: 12,821; python: 3,394; yacc: 783; javascript: 558; sh: 550; lisp: 395; makefile: 263
file content (14 lines) | stat: -rw-r--r-- 413 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- Lifted type parameters allows for the definition of general polymorphic
-- function composition. Without them, we are limited in which functions can be
-- composed.
-- ==
-- error: functional

def compose 'a 'b 'c (f : b -> c) (g : a -> b) : a -> c =
  \(x : a) -> f (g x)

def add (x : i32) (y : i32) : i32 = x+y
def double (x : i32) : i32 = x+x

def main (x : i32) (y : i32) : i32 =
  compose add double 3 5