From fe39eea72647759b6b5df293d466109592a2ea1b Mon Sep 17 00:00:00 2001 From: Emily Martins Date: Wed, 24 Aug 2022 17:08:19 +0200 Subject: [PATCH 1/3] add kind signatures to all agora decls --- agora/Agora/AuthorityToken.hs | 12 ++++++------ agora/Agora/Credential.hs | 2 +- agora/Agora/Governor.hs | 4 ++-- agora/Agora/Governor/Scripts.hs | 6 ++++-- agora/Agora/Proposal.hs | 6 +++++- agora/Agora/Proposal/Time.hs | 3 ++- agora/Agora/Stake.hs | 18 ++++++++++-------- 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/agora/Agora/AuthorityToken.hs b/agora/Agora/AuthorityToken.hs index 8771027..caa0428 100644 --- a/agora/Agora/AuthorityToken.hs +++ b/agora/Agora/AuthorityToken.hs @@ -21,13 +21,13 @@ import Plutarch.Api.V1.Value (PValue (PValue)) import Plutarch.Api.V2 ( AmountGuarantees, KeyGuarantees, - PAddress (..), + PAddress (PAddress), PMintingPolicy, - PScriptContext (..), - PScriptPurpose (..), + PScriptContext (PScriptContext), + PScriptPurpose (PMinting), PTxInInfo (PTxInInfo), - PTxInfo (..), - PTxOut (..), + PTxInfo (PTxInfo), + PTxOut (PTxOut), ) import Plutarch.Extra.AssetClass (passetClass, passetClassValueOf) import Plutarch.Extra.List (plookup) @@ -74,7 +74,7 @@ newtype AuthorityToken = AuthorityToken @since 0.1.0 -} -authorityTokensValidIn :: Term s (PCurrencySymbol :--> PTxOut :--> PBool) +authorityTokensValidIn :: forall (s :: S). Term s (PCurrencySymbol :--> PTxOut :--> PBool) authorityTokensValidIn = phoistAcyclic $ plam $ \authorityTokenSym txOut'' -> unTermCont $ do PTxOut txOut' <- pmatchC txOut'' diff --git a/agora/Agora/Credential.hs b/agora/Agora/Credential.hs index b42d91b..d4743df 100644 --- a/agora/Agora/Credential.hs +++ b/agora/Agora/Credential.hs @@ -46,7 +46,7 @@ instance DerivePlutusType PAuthorizationContext where @since 1.0.0 -} authorizationContext :: - forall (s :: S) r. + forall (s :: S) (r :: Type). ( HasField "inputs" r (Term s (PBuiltinList PTxInInfo)) , HasField "signatories" r (Term s (PBuiltinList (PAsData PPubKeyHash))) ) => diff --git a/agora/Agora/Governor.hs b/agora/Agora/Governor.hs index f687054..81540af 100644 --- a/agora/Agora/Governor.hs +++ b/agora/Agora/Governor.hs @@ -232,7 +232,7 @@ deriving via (DerivePConstantViaEnum GovernorRedeemer PGovernorRedeemer) instanc @since 0.1.0 -} -pgetNextProposalId :: Term s (PProposalId :--> PProposalId) +pgetNextProposalId :: forall (s :: S). Term s (PProposalId :--> PProposalId) pgetNextProposalId = phoistAcyclic $ plam $ \(pto -> pid) -> pcon $ PProposalId $ pid + 1 {- | Get next proposal id. @@ -248,7 +248,7 @@ getNextProposalId (ProposalId pid) = ProposalId $ pid + 1 @since 0.1.0 -} -pisGovernorDatumValid :: Term s (PGovernorDatum :--> PBool) +pisGovernorDatumValid :: forall (s :: S). Term s (PGovernorDatum :--> PBool) pisGovernorDatumValid = phoistAcyclic $ plam $ \datum -> unTermCont $ do datumF <- diff --git a/agora/Agora/Governor/Scripts.hs b/agora/Agora/Governor/Scripts.hs index 07c212a..98991c2 100644 --- a/agora/Agora/Governor/Scripts.hs +++ b/agora/Agora/Governor/Scripts.hs @@ -503,7 +503,9 @@ governorValidator as = -- For a given output, check if it contains a single valid GAT -- and whether it correctly belongs to the group. - let validateGATOutput' :: Term s (PProposalEffectGroup :--> PTxOut :--> PBool) + let validateGATOutput' :: + forall (s :: S). + Term s (PProposalEffectGroup :--> PTxOut :--> PBool) validateGATOutput' = phoistAcyclic $ plam @@ -569,7 +571,7 @@ governorValidator as = Nothing -> ptraceError "Unknown redeemer" where -- The currency symbol of authority token. - atSymbol :: Term s PCurrencySymbol + atSymbol :: forall (s :: S). Term s PCurrencySymbol atSymbol = pconstant $ authorityTokenSymbol as -- The currency symbol of the proposal state token. diff --git a/agora/Agora/Proposal.hs b/agora/Agora/Proposal.hs index 97d0db9..db96b27 100644 --- a/agora/Agora/Proposal.hs +++ b/agora/Agora/Proposal.hs @@ -746,6 +746,7 @@ pisVotesEmpty = phoistAcyclic $ @since 0.1.0 -} pwinner :: + forall (s :: S). Term s ( PProposalVotes @@ -766,6 +767,7 @@ pwinner = phoistAcyclic $ @since 0.1.0 -} pwinner' :: + forall (s :: S). Term s ( PProposalVotes @@ -813,6 +815,7 @@ pwinner' = phoistAcyclic $ @since 0.1.0 -} phighestVotes :: + forall (s :: S). Term s ( PProposalVotes @@ -835,6 +838,7 @@ phighestVotes = phoistAcyclic $ @since 0.1.0 -} pneutralOption :: + forall (s :: S). Term s ( PMap 'Unsorted PResultTag PProposalEffectGroup @@ -883,7 +887,7 @@ pisProposalThresholdsValid = phoistAcyclic $ @since 0.1.0 -} -pretractVotes :: Term s (PResultTag :--> PInteger :--> PProposalVotes :--> PProposalVotes) +pretractVotes :: forall (s :: S). Term s (PResultTag :--> PInteger :--> PProposalVotes :--> PProposalVotes) pretractVotes = phoistAcyclic $ plam $ \rt count votes -> let voteMap :: Term _ (PMap 'Unsorted PResultTag PInteger) diff --git a/agora/Agora/Proposal/Time.hs b/agora/Agora/Proposal/Time.hs index 8177931..eda80ed 100644 --- a/agora/Agora/Proposal/Time.hs +++ b/agora/Agora/Proposal/Time.hs @@ -294,7 +294,7 @@ deriving via @since 0.2.0 -} -pisProposalTimingConfigValid :: Term s (PProposalTimingConfig :--> PBool) +pisProposalTimingConfigValid :: forall (s :: S). Term s (PProposalTimingConfig :--> PBool) pisProposalTimingConfigValid = phoistAcyclic $ plam $ \conf -> unTermCont $ do confF <- pletAllC conf @@ -397,6 +397,7 @@ currentProposalTime = phoistAcyclic $ @since 0.1.0 -} proposalTimeWithin :: + forall (s :: S). Term s ( PPOSIXTime diff --git a/agora/Agora/Stake.hs b/agora/Agora/Stake.hs index 07bfe2a..cb600ff 100644 --- a/agora/Agora/Stake.hs +++ b/agora/Agora/Stake.hs @@ -366,7 +366,9 @@ pstakeLocked = phoistAcyclic $ @since 0.2.0 -} -pnumCreatedProposals :: Term s (PBuiltinList (PAsData PProposalLock) :--> PInteger) +pnumCreatedProposals :: + forall (s :: S). + Term s (PBuiltinList (PAsData PProposalLock) :--> PInteger) pnumCreatedProposals = phoistAcyclic $ plam $ \l -> @@ -414,7 +416,7 @@ instance DerivePlutusType PStakeRole where @since 0.2.0 -} -pisVoter :: Term s (PStakeRole :--> PBool) +pisVoter :: forall (s :: S). Term s (PStakeRole :--> PBool) pisVoter = phoistAcyclic $ plam $ \sr -> pmatch sr $ \case PVoter _ -> pconstant True @@ -425,7 +427,7 @@ pisVoter = phoistAcyclic $ @since 0.2.0 -} -pisCreator :: Term s (PStakeRole :--> PBool) +pisCreator :: forall (s :: S). Term s (PStakeRole :--> PBool) pisCreator = phoistAcyclic $ plam $ \sr -> pmatch sr $ \case PCreator -> pconstant True @@ -437,7 +439,7 @@ pisCreator = phoistAcyclic $ @since 0.2.0 -} -pisPureCreator :: Term s (PStakeRole :--> PBool) +pisPureCreator :: forall (s :: S). Term s (PStakeRole :--> PBool) pisPureCreator = phoistAcyclic $ plam $ \sr -> pmatch sr $ \case PCreator -> pconstant True @@ -447,7 +449,7 @@ pisPureCreator = phoistAcyclic $ @since 0.2.0 -} -pisIrrelevant :: Term s (PStakeRole :--> PBool) +pisIrrelevant :: forall (s :: S). Term s (PStakeRole :--> PBool) pisIrrelevant = phoistAcyclic $ plam $ \sr -> pmatch sr $ \case PIrrelevant -> pconstant True @@ -461,7 +463,7 @@ pisIrrelevant = phoistAcyclic $ @since 0.2.0 -} -pgetStakeRole :: Term s (PProposalId :--> PBuiltinList (PAsData PProposalLock) :--> PStakeRole) +pgetStakeRole :: forall (s :: S). Term s (PProposalId :--> PBuiltinList (PAsData PProposalLock) :--> PStakeRole) pgetStakeRole = phoistAcyclic $ plam $ \pid locks -> pfoldl @@ -483,7 +485,7 @@ pgetStakeRole = phoistAcyclic $ # pcon PIrrelevant # locks where - pcombineStakeRole :: Term s (PStakeRole :--> PStakeRole :--> PStakeRole) + pcombineStakeRole :: forall (s :: S). Term s (PStakeRole :--> PStakeRole :--> PStakeRole) pcombineStakeRole = phoistAcyclic $ plam $ \x y -> let cannotCombine = ptraceError "duplicate roles" @@ -503,7 +505,7 @@ pgetStakeRole = phoistAcyclic $ @since 0.2.0 -} -pextractVoteOption :: Term s (PStakeRole :--> PResultTag) +pextractVoteOption :: forall (s :: S). Term s (PStakeRole :--> PResultTag) pextractVoteOption = phoistAcyclic $ plam $ \sr -> pmatch sr $ \case PVoter r -> r From e615dc6f9b3b8a2f7b7fc4d01b581d2c1ae2745e Mon Sep 17 00:00:00 2001 From: Emily Martins Date: Wed, 24 Aug 2022 17:21:25 +0200 Subject: [PATCH 2/3] ensure `make ci` is consistent with system Sadly I can't see of a way to pass your current system to `nix build`. So, let's just support x86 64-bit Linux and tell the user how to use `nix build` directly. --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bab143b..f3f0318 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # This really ought to be `/usr/bin/env bash`, but nix flakes don't like that. SHELL := /bin/sh -.PHONY: hoogle format haddock usage tag format_nix format_haskell format_check \ +.PHONY: hoogle format haddock usage tag format_nix format_haskell format_check \ lint refactor ps_bridge bench bench_check scripts test build ci SOURCE_FILES := $(shell git ls-tree -r HEAD --full-tree --name-only) @@ -98,4 +98,7 @@ test: requires_nix_shell build: requires_nix_shell cabal build -j$(THREADS) -ci: format_check lint build bench_check test haddock +ci: + @ [[ "$$(uname -sm)" == "Linux x86_64" ]] \ + && (nix build .#check.x86_64-linux) \ + || (echo "CI only builds on Linux x86_64. Your system is $$(uname -sm). If you want to build it for your system, use 'nix build .#check.' instead." && false) From a8973c9b921e192ce90fc5de94bbdca7e3f4cf16 Mon Sep 17 00:00:00 2001 From: Emily Martins Date: Wed, 24 Aug 2022 18:29:32 +0200 Subject: [PATCH 3/3] infer system for `make ci` --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f3f0318..37c916a 100644 --- a/Makefile +++ b/Makefile @@ -99,6 +99,5 @@ build: requires_nix_shell cabal build -j$(THREADS) ci: - @ [[ "$$(uname -sm)" == "Linux x86_64" ]] \ - && (nix build .#check.x86_64-linux) \ - || (echo "CI only builds on Linux x86_64. Your system is $$(uname -sm). If you want to build it for your system, use 'nix build .#check.' instead." && false) + @ [[ "$$(uname -sm)" == "Linux x86_64" ]] || (echo "NOTE: CI only builds on Linux x86_64. Your system is $$(uname -sm), continuing...") + nix build .#check.$(shell nix eval -f '' system)