File: value-type-function0.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 (13 lines) | stat: -rw-r--r-- 424 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
-- Since we distinguish between value types and lifted types, it
-- should not be possible to instantiate a polymorphic funtion, that
-- uses its (value type) polymorphic arguments in the branches of a
-- conditional, with a function type.
-- ==
-- error: functional

def cond 'a (b : bool) (x : a) (y : a) : a =
  if b then x else y

def main (b : bool) : i32 =
  let f = cond b (\(x:i32) -> x+x) (\(x:i32) -> x)
  in f 42