basis-library/config/c/word-to-bool.sml
raw| 1 | (* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh |
| 2 | * Jagannathan, and Stephen Weeks. |
| 3 | * |
| 4 | * MLton is released under a HPND-style license. |
| 5 | * See the file MLton-LICENSE for details. |
| 6 | *) |
| 7 | |
| 8 | functor WordToBool (S : sig |
| 9 | eqtype t |
| 10 | val one: t |
| 11 | val zero: t |
| 12 | end) : sig |
| 13 | eqtype t |
| 14 | val fromBool: bool -> t |
| 15 | val toBool: t -> bool |
| 16 | end = |
| 17 | struct |
| 18 | open S |
| 19 | |
| 20 | val fromBool: bool -> t = fn b => if b then zero else one |
| 21 | val toBool: t -> bool = fn w => w <> zero |
| 22 | end |