{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} module Cardano.Ledger.Compactible ( -- * Compactible Compactible (..), ) where import Data.Kind (Type) -------------------------------------------------------------------------------- -- * Compactible -- -- Certain types may have a "presentation" form and a more compact -- representation that allows for more efficient memory usage. In this case, -- one should make instances of the 'Compactible' class for them. -------------------------------------------------------------------------------- class Compactible a where data CompactForm a :: Type toCompact :: a -> Maybe (CompactForm a) fromCompact :: CompactForm a -> a