File: sum.fut

package info (click to toggle)
haskell-futhark 0.25.32-2
  • 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: 277
file content (10 lines) | stat: -rw-r--r-- 421 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
-- Tests various complicated sum types and destructing/constructing
-- them.

type~ contrived = #foo ([]i32) bool | #bar bool ([]u32) | #baz ([]i32) ([]i32)

entry next (c: contrived) : contrived =
  match c
  case #foo arr b -> #bar (!b) (map u32.i32 (map (+1) arr))
  case #bar b arr -> #baz (map i32.u32 (map (*2) arr)) (map i32.u32 (map (+u32.bool b) arr))
  case #baz x y -> #foo (map2 (+) x y) (i32.sum x % 2 == 0)