mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
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:
parent
a589f4af0b
commit
7124479647
@ -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:
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user