-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed to ASTSize, changed to Maybe CoverageIndex
- Loading branch information
Showing
31 changed files
with
240 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### Changed | ||
|
||
- Renamed all `*Size` related datatypes and constructors to `*ASTSize`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
module PlutusCore.ASTSize | ||
( ASTSize (..) | ||
, kindASTSize | ||
, typeASTSize | ||
, tyVarDeclASTSize | ||
, termASTSize | ||
, varDeclASTSize | ||
, programASTSize | ||
) where | ||
|
||
import PlutusPrelude | ||
import PlutusCore.Core | ||
|
||
import Control.Lens | ||
import Data.Monoid | ||
|
||
newtype ASTSize = ASTSize | ||
{ unASTSize :: Integer | ||
} deriving stock (Show) | ||
deriving newtype (Pretty, Eq, Ord, Num) | ||
deriving (Semigroup, Monoid) via Sum Integer | ||
|
||
-- | Count the number of AST nodes in a kind. | ||
-- | ||
-- >>> kindASTSize $ Type () | ||
-- ASTSize {unASTSize = 1} | ||
-- >>> kindASTSize $ KindArrow () (KindArrow () (Type ()) (Type ())) (Type ()) | ||
-- ASTSize {unASTSize = 5} | ||
kindASTSize :: Kind a -> ASTSize | ||
kindASTSize kind = fold | ||
[ ASTSize 1 | ||
, kind ^. kindSubkinds . to kindASTSize | ||
] | ||
|
||
-- | Count the number of AST nodes in a type. | ||
typeASTSize :: Type tyname uni ann -> ASTSize | ||
typeASTSize ty = fold | ||
[ ASTSize 1 | ||
, ty ^. typeSubkinds . to kindASTSize | ||
, ty ^. typeSubtypes . to typeASTSize | ||
] | ||
|
||
tyVarDeclASTSize :: TyVarDecl tyname ann -> ASTSize | ||
tyVarDeclASTSize tyVarDecl = fold | ||
[ ASTSize 1 | ||
, tyVarDecl ^. tyVarDeclSubkinds . to kindASTSize | ||
] | ||
|
||
-- | Count the number of AST nodes in a term. | ||
termASTSize :: Term tyname name uni fun ann -> ASTSize | ||
termASTSize term = fold | ||
[ ASTSize 1 | ||
, term ^. termSubkinds . to kindASTSize | ||
, term ^. termSubtypes . to typeASTSize | ||
, term ^. termSubterms . to termASTSize | ||
] | ||
|
||
varDeclASTSize :: VarDecl tyname name uni ann -> ASTSize | ||
varDeclASTSize varDecl = fold | ||
[ ASTSize 1 | ||
, varDecl ^. varDeclSubtypes . to typeASTSize | ||
] | ||
|
||
-- | Count the number of AST nodes in a program. | ||
programASTSize :: Program tyname name uni fun ann -> ASTSize | ||
programASTSize (Program _ _ t) = termASTSize t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module PlutusIR.ASTSize | ||
( ASTSize (..) | ||
, kindASTSize | ||
, typeASTSize | ||
, tyVarDeclASTSize | ||
, termASTSize | ||
, varDeclASTSize | ||
) where | ||
|
||
import PlutusPrelude | ||
|
||
import PlutusIR.Core | ||
|
||
import PlutusCore.ASTSize (ASTSize (..), kindASTSize, tyVarDeclASTSize, typeASTSize, varDeclASTSize) | ||
|
||
import Control.Lens | ||
|
||
-- | Count the number of AST nodes in a term. | ||
termASTSize :: Term tyname name uni fun ann -> ASTSize | ||
termASTSize term = fold | ||
[ ASTSize 1 | ||
, term ^. termSubkinds . to kindASTSize | ||
, term ^. termSubtypes . to typeASTSize | ||
, term ^. termSubterms . to termASTSize | ||
] |
Oops, something went wrong.