cardano-foundation / cardano-wallet

HTTP server & command-line for managing UTxOs and HD wallets in Cardano.
Apache License 2.0
758 stars 211 forks source link

[ADP-3319] Replace implementation of `EraFun` #4491

Closed HeinrichApfelmus closed 5 months ago

HeinrichApfelmus commented 6 months ago

This pull requests starts the simplification of the Cardano.Wallet.Read.* hierarchy where the EraFun f g is removed in favor of a plain function type

foo :: forall era. IsEra era => f era → g era

In order to start the simplification, we redefine the EraFun type as a newtype

-- | Function that maps an era-indexed type.
newtype EraFun f g = EraFunCon
    {runEraFun :: forall era. IsEra era => f era -> g era}

and export both the eliminator runEraFun and the constructor mkEraFun = EraFunCon.

By using the eliminator and constructor directly, we can remove most categorical constructions such as

(*.**)
(*&&&*)
(*****)
EraFunK
liftK
mapOnEraFun
CollectTuple

Issue Number

ADP-3319