Backport from sid to buster
[hcoop/debian/mlton.git] / lib / mlton / basic / ring.fun
1 (* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 *
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
6 *)
7
8 functor Ring(S: RING_STRUCTS):> RING where type t = S.t =
9 struct
10
11 open S
12
13 fun a - b = a + (~ b)
14
15 fun isZero a = equals(a, zero)
16
17 fun double n = n + n
18
19 fun square n = n * n
20
21 fun sum l = List.fold(l, zero, op +)
22
23 end