diff --git a/plutus-core/plutus-core/src/PlutusCore/Size.hs b/plutus-core/plutus-core/src/PlutusCore/Size.hs deleted file mode 100644 index 39493162341..00000000000 --- a/plutus-core/plutus-core/src/PlutusCore/Size.hs +++ /dev/null @@ -1,78 +0,0 @@ -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE OverloadedStrings #-} - -module PlutusCore.Size - ( Size (..) - , kindSize - , typeSize - , tyVarDeclSize - , termSize - , varDeclSize - , programSize - , serialisedSize - ) where - -import PlutusPrelude - -import PlutusCore.Core - -import Control.Lens -import Data.ByteString qualified as BS -import Data.Monoid -import PlutusCore.Flat hiding (to) - -newtype Size = Size - { unSize :: Integer - } deriving stock (Show) - deriving newtype (Pretty, Eq, Ord, Num) - deriving anyclass (PrettyBy config) - deriving (Semigroup, Monoid) via Sum Integer - --- | Count the number of AST nodes in a kind. --- --- >>> kindSize $ Type () --- Size {unSize = 1} --- >>> kindSize $ KindArrow () (KindArrow () (Type ()) (Type ())) (Type ()) --- Size {unSize = 5} -kindSize :: Kind a -> Size -kindSize kind = fold - [ Size 1 - , kind ^. kindSubkinds . to kindSize - ] - --- | Count the number of AST nodes in a type. -typeSize :: Type tyname uni ann -> Size -typeSize ty = fold - [ Size 1 - , ty ^. typeSubkinds . to kindSize - , ty ^. typeSubtypes . to typeSize - ] - -tyVarDeclSize :: TyVarDecl tyname ann -> Size -tyVarDeclSize tyVarDecl = fold - [ Size 1 - , tyVarDecl ^. tyVarDeclSubkinds . to kindSize - ] - --- | Count the number of AST nodes in a term. -termSize :: Term tyname name uni fun ann -> Size -termSize term = fold - [ Size 1 - , term ^. termSubkinds . to kindSize - , term ^. termSubtypes . to typeSize - , term ^. termSubterms . to termSize - ] - -varDeclSize :: VarDecl tyname name uni ann -> Size -varDeclSize varDecl = fold - [ Size 1 - , varDecl ^. varDeclSubtypes . to typeSize - ] - --- | Count the number of AST nodes in a program. -programSize :: Program tyname name uni fun ann -> Size -programSize (Program _ _ t) = termSize t - --- | Compute the size of the serializabled form of a value. -serialisedSize :: Flat a => a -> Integer -serialisedSize = fromIntegral . BS.length . flat diff --git a/plutus-core/plutus-ir/src/PlutusIR/Analysis/Size.hs b/plutus-core/plutus-ir/src/PlutusIR/Analysis/Size.hs deleted file mode 100644 index 468e1d021a2..00000000000 --- a/plutus-core/plutus-ir/src/PlutusIR/Analysis/Size.hs +++ /dev/null @@ -1,25 +0,0 @@ -module PlutusIR.Analysis.Size - ( Size (..) - , kindSize - , typeSize - , tyVarDeclSize - , termSize - , varDeclSize - ) where - -import PlutusPrelude - -import PlutusIR.Core - -import PlutusCore.Size (Size (..), kindSize, tyVarDeclSize, typeSize, varDeclSize) - -import Control.Lens - --- | Count the number of AST nodes in a term. -termSize :: Term tyname name uni fun ann -> Size -termSize term = fold - [ Size 1 - , term ^. termSubkinds . to kindSize - , term ^. termSubtypes . to typeSize - , term ^. termSubterms . to termSize - ] diff --git a/plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Size.hs b/plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Size.hs deleted file mode 100644 index 50b41d36099..00000000000 --- a/plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Size.hs +++ /dev/null @@ -1,29 +0,0 @@ -module UntypedPlutusCore.Size - ( Size (..) - , termSize - , programSize - , serialisedSize - ) where - -import PlutusCore.Size (Size (..)) -import UntypedPlutusCore.Core - -import Control.Lens -import Data.ByteString qualified as BS -import Data.Foldable -import PlutusCore.Flat hiding (to) - --- | Count the number of AST nodes in a term. -termSize :: Term name uni fun ann -> Size -termSize term = fold - [ Size 1 - , term ^. termSubterms . to termSize - ] - --- | Count the number of AST nodes in a program. -programSize :: Program name uni fun ann -> Size -programSize (Program _ _ t) = termSize t - --- | Compute the size of the serialized form of a value. -serialisedSize :: Flat a => a -> Integer -serialisedSize = fromIntegral . BS.length . flat