Add subtract to the daml-stdlib (#4523)

changelog_begin

- [DAML Standard Library] Add a ``subtract`` function which is useful
  as a replacement for sections of ``(-)``, e.g., ``subtract 1`` is
  equivalent to ``\x -> x - 1``.

changelog_end
This commit is contained in:
Moritz Kiefer 2020-02-14 14:55:47 +01:00 committed by GitHub
parent a589f4af0b
commit 7124479647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,7 @@ module GHC.Num
, Signed (..)
, Number (..)
, (%)
, subtract
) where
import GHC.Base
@ -58,6 +59,14 @@ class Additive a where
negate : a -> a
negate x = aunit - x
-- | `subtract x y` is equivalent to `y - x`.
--
-- This is useful for partial application, e.g., in `subtract 1` since `(- 1)` is
-- interpreted as the number `-1` and not a function that subtracts `1` from
-- its argument.
subtract : Additive a => a -> a -> a
subtract x y = y - x
-- | Use the `Multiplicative` class for types that can be multiplied.
-- Instances have to respect the following laws:
--