File: DetOperations.curry

package info (click to toggle)
curry-tools 1.0.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,492 kB
  • ctags: 121
  • sloc: makefile: 470; sh: 421
file content (19 lines) | stat: -rw-r--r-- 554 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{-# OPTIONS_CYMAKE -F --pgmF=currypp --optF=defaultrules #-}

--- Examples for specifying deterministic operations via
--- the DET annotation in the type.
--- CurryCheck generates and check properties which states
--- that the original operations are indeed deterministic.

-- Computes the last element of a list.
last :: [a] ->DET a
last (_ ++ [x]) = x

last'pre = not . null

-- Definition of bubble sort with default rule as a deterministic operaion.
sort :: [Int] ->DET [Int]
sort (xs++[x,y]++ys) |  x>y = sort (xs++[y,x]++ys)
sort'default xs = xs