Skip to content

Commit

Permalink
Remove warning about exporting default constructor for TokenMap.
Browse files Browse the repository at this point in the history
It's no longer necessary to worry about exporting the default
constructor for `TokenMap`.

The original concern was that exporting the default constructor would
allow callers to break the invariant that there are no `mempty` values
in the map.

However, this is no longer possible, as the `MonoidMap` type handles
this invariant automatically.

Therefore, it's no longer necessary to have a warning.

Nevertheless, this commit doesn't export the default constructor, as
there currently isn't any need to do so.
  • Loading branch information
jonathanknowles committed Jun 2, 2023
1 parent c07e36d commit 5a84c1d
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenMap.hs
Expand Up @@ -21,22 +21,6 @@
module Cardano.Wallet.Primitive.Types.TokenMap
(
-- * Types

-- Important:
--
-- The default data constructor for 'TokenMap' is not exported, by design,
-- as the internal data structure has an invariant that must be preserved
-- across all operations.
--
-- Exporting the default constructor would make it possible for functions
-- outside the 'TokenMap' module to break the invariant, opening the door
-- to subtle regressions.
--
-- See the definition of 'TokenMap' for more details of the invariant.
--
-- To construct a 'TokenMap', use one of the provided constructors, all
-- of which are tested to check that they respect the invariant.
--
TokenMap
, AssetId (..)

Expand Down

0 comments on commit 5a84c1d

Please sign in to comment.