diff --git a/.github/format.sh b/.github/format.sh index 90be9ca..b655d8b 100755 --- a/.github/format.sh +++ b/.github/format.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Extensions necessary to tell fourmolu about -EXTENSIONS="-o -XTypeApplications -o -XTemplateHaskell -o -XImportQualifiedPost -o -XPatternSynonyms -o -fplugin=RecordDotPreprocessor" +# Extensions necessary to tell fourmolu about +EXTENSIONS="-o -XTypeApplications -o -XTemplateHaskell -o -XImportQualifiedPost -o -XPatternSynonyms -o -XOverloadedRecordDot" SOURCES=$(git ls-tree -r HEAD --full-tree --name-only | grep -E '.*\.hs') -nix run nixpkgs#haskellPackages.fourmolu -- --mode check --check-idempotence $EXTENSIONS $SOURCES +nix run nixpkgs#haskell.packages.ghc921.fourmolu -- --mode check --check-idempotence $EXTENSIONS $SOURCES diff --git a/Makefile b/Makefile index 84c1ed3..35cd401 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ HOOGLE_PORT=8081 hoogle: hoogle server --local --port $(HOOGLE_PORT) > /dev/null & -FORMAT_EXTENSIONS := -o -XQuasiQuotes -o -XTemplateHaskell -o -XTypeApplications -o -XImportQualifiedPost -o -XPatternSynonyms -o -fplugin=RecordDotPreprocessor +FORMAT_EXTENSIONS := -o -XQuasiQuotes -o -XTemplateHaskell -o -XTypeApplications -o -XImportQualifiedPost -o -XPatternSynonyms -o -XOverloadedRecordDot format: find -name '*.hs' -not -path './dist-*/*' | xargs fourmolu $(FORMAT_EXTENSIONS) -m inplace git ls-tree -r HEAD --full-tree --name-only | grep -E '.*\.nix' | xargs nixfmt diff --git a/agora.cabal b/agora.cabal index c6d3061..c874b3f 100644 --- a/agora.cabal +++ b/agora.cabal @@ -9,100 +9,129 @@ license: Apache-2.0 -- Common Stanza Declarations -- Language options, warnings, some options for plutus + common lang - default-language: Haskell2010 + ghc-options: + -Wall -Wcompat -Wincomplete-uni-patterns -Wno-unused-do-bind + -Wno-partial-type-signatures -Wmissing-export-lists + -Wincomplete-record-updates -Wmissing-deriving-strategies + -Wno-name-shadowing -Wunused-foralls -fprint-explicit-foralls + -fprint-explicit-kinds -Werror + + mixins: + base hiding (Prelude), + pprelude (PPrelude as Prelude) + default-extensions: - NoImplicitPrelude + NoStarIsType BangPatterns BinaryLiterals + ConstrainedClassMethods ConstraintKinds DataKinds DeriveAnyClass + DeriveDataTypeable + DeriveFoldable DeriveFunctor DeriveGeneric + DeriveLift DeriveTraversable DerivingStrategies DerivingVia - DuplicateRecordFields + DoAndIfThenElse EmptyCase + EmptyDataDecls + EmptyDataDeriving + ExistentialQuantification + ExplicitForAll FlexibleContexts FlexibleInstances - GADTs - GeneralizedNewtypeDeriving + ForeignFunctionInterface + GADTSyntax + GeneralisedNewtypeDeriving HexFloatLiterals + ImplicitPrelude ImportQualifiedPost InstanceSigs KindSignatures LambdaCase + MonomorphismRestriction MultiParamTypeClasses + NamedFieldPuns + NamedWildCards NumericUnderscores OverloadedStrings - QuasiQuotes + PartialTypeSignatures + PatternGuards + PolyKinds + PostfixOperators + RankNTypes + RelaxedPolyRec ScopedTypeVariables StandaloneDeriving + StandaloneKindSignatures TupleSections TypeApplications TypeFamilies TypeOperators TypeSynonymInstances - UndecidableInstances + ViewPatterns + OverloadedRecordDot + QualifiedDo - ghc-options: - -Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints - -Wmissing-export-lists -Werror -Wincomplete-record-updates - -fno-ignore-interface-pragmas -fno-omit-interface-pragmas - -fobject-code -fno-strictness -fplugin=RecordDotPreprocessor - -fplugin-opt PlutusTx.Plugin:dump-uplc + default-language: Haskell2010 common deps build-depends: , aeson , ansi-terminal - , base >=4.9 && <5 + , base >=4.14 && <5 , base-compat , bytestring - , cardano-api , cardano-prelude , containers , data-default , data-default-class + , generics-sop , plutarch , plutus-core - , plutus-extra - , plutus-ledger , plutus-ledger-api , plutus-tx + , pprelude , prettyprinter - , record-dot-preprocessor - , record-hasfield , recursion-schemes , serialise , template-haskell , text - , generics-sop common test-deps build-depends: , QuickCheck , quickcheck-instances - , tagged , tasty - , tasty-hunit - , utf8-string - --------------------------------------------------------------------------------- + , tasty-quickcheck library import: lang, deps exposed-modules: Agora.AuthorityToken - Agora.Stake - Agora.Voting Agora.SafeMoney Agora.SafeMoney.QQ + Agora.Stake + Agora.Voting + other-modules: hs-source-dirs: src +library pprelude + build-depends: + , base + , plutarch + + exposed-modules: PPrelude + hs-source-dirs: src + default-language: Haskell2010 + test-suite agora-test import: lang, deps, test-deps type: exitcode-stdio-1.0 diff --git a/cabal.project b/cabal.project index 74256d3..bd0d96f 100644 --- a/cabal.project +++ b/cabal.project @@ -1,42 +1,3 @@ -index-state: 2021-10-20T00:00:00Z - packages: ./. --- Always build tests and benchmarks. tests: true -benchmarks: true - --- The only sensible test display option -test-show-details: direct - -allow-newer: - -- Pins to an old version of Template Haskell, unclear if/when it will be updated - size-based:template-haskell - , ouroboros-consensus-byron:formatting - , beam-core:aeson - , beam-sqlite:aeson - , beam-sqlite:dlist - , beam-migrate:aeson - -constraints: - -- big breaking change here, inline-r doens't have an upper bound - singletons < 3.0 - -- bizarre issue: in earlier versions they define their own 'GEq', in newer - -- ones they reuse the one from 'some', but there isn't e.g. a proper version - -- constraint from dependent-sum-template (which is the library we actually use). - , dependent-sum > 0.6.2.0 - -- Newer Hashable have instances for Set, which breaks beam-migrate - -- which declares its own instances of Hashable Set - , hashable < 1.3.4.0 - -package cardano-ledger-alonzo - optimization: False -package ouroboros-consensus-shelley - optimization: False -package ouroboros-consensus-cardano - optimization: False -package cardano-api - optimization: False - -package plutarch - flags: +development \ No newline at end of file diff --git a/flake.lock b/flake.lock index b5acf55..e68b47a 100644 --- a/flake.lock +++ b/flake.lock @@ -16,22 +16,6 @@ "type": "github" } }, - "HTTP_2": { - "flake": false, - "locked": { - "lastModified": 1451647621, - "narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=", - "owner": "phadej", - "repo": "HTTP", - "rev": "9bc0996d412fef1787449d841277ef663ad9a915", - "type": "github" - }, - "original": { - "owner": "phadej", - "repo": "HTTP", - "type": "github" - } - }, "Shrinker": { "flake": false, "locked": { @@ -49,23 +33,6 @@ } }, "Win32-network": { - "flake": false, - "locked": { - "lastModified": 1627315969, - "narHash": "sha256-Hesb5GXSx0IwKSIi42ofisVELcQNX6lwHcoZcbaDiqc=", - "owner": "input-output-hk", - "repo": "Win32-network", - "rev": "3825d3abf75f83f406c1f7161883c438dac7277d", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "Win32-network", - "rev": "3825d3abf75f83f406c1f7161883c438dac7277d", - "type": "github" - } - }, - "Win32-network_2": { "flake": false, "locked": { "lastModified": 1636063162, @@ -82,24 +49,24 @@ "type": "github" } }, - "cabal-32": { + "autodocodec": { "flake": false, "locked": { - "lastModified": 1603716527, - "narHash": "sha256-sDbrmur9Zfp4mPKohCD8IDZfXJ0Tjxpmr2R+kg5PpSY=", - "owner": "haskell", - "repo": "cabal", - "rev": "94aaa8e4720081f9c75497e2735b90f6a819b08e", + "lastModified": 1644358110, + "narHash": "sha256-X1TNZlmO2qDFk3OL4Z1v/gzvd3ouoACAiMweutsYek4=", + "owner": "srid", + "repo": "autodocodec", + "rev": "42b42a7407f33c6c74fa4e8c84906aebfed28daf", "type": "github" }, "original": { - "owner": "haskell", - "ref": "3.2", - "repo": "cabal", + "owner": "srid", + "ref": "ghc921", + "repo": "autodocodec", "type": "github" } }, - "cabal-32_2": { + "cabal-32": { "flake": false, "locked": { "lastModified": 1603716527, @@ -133,23 +100,6 @@ "type": "github" } }, - "cabal-34_2": { - "flake": false, - "locked": { - "lastModified": 1622475795, - "narHash": "sha256-chwTL304Cav+7p38d9mcb+egABWmxo2Aq+xgVBgEb/U=", - "owner": "haskell", - "repo": "cabal", - "rev": "b086c1995cdd616fc8d91f46a21e905cc50a1049", - "type": "github" - }, - "original": { - "owner": "haskell", - "ref": "3.4", - "repo": "cabal", - "type": "github" - } - }, "cabal-36": { "flake": false, "locked": { @@ -167,41 +117,7 @@ "type": "github" } }, - "cardano-addresses": { - "flake": false, - "locked": { - "lastModified": 1631515399, - "narHash": "sha256-XgXQKJHRKAFwIjONh19D/gKE0ARlhMXXcV74eZpd0lw=", - "owner": "input-output-hk", - "repo": "cardano-addresses", - "rev": "d2f86caa085402a953920c6714a0de6a50b655ec", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "cardano-addresses", - "rev": "d2f86caa085402a953920c6714a0de6a50b655ec", - "type": "github" - } - }, "cardano-base": { - "flake": false, - "locked": { - "lastModified": 1633088283, - "narHash": "sha256-JKpOlruMX5sr9eaQ3AuOppCbBjQIRKwF4ny20tdPnUg=", - "owner": "input-output-hk", - "repo": "cardano-base", - "rev": "654f5b7c76f7cc57900b4ddc664a82fc3b925fb0", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "cardano-base", - "rev": "654f5b7c76f7cc57900b4ddc664a82fc3b925fb0", - "type": "github" - } - }, - "cardano-base_2": { "flake": false, "locked": { "lastModified": 1638456794, @@ -218,23 +134,6 @@ } }, "cardano-crypto": { - "flake": false, - "locked": { - "lastModified": 1604244485, - "narHash": "sha256-2Fipex/WjIRMrvx6F3hjJoAeMtFd2wGnZECT0kuIB9k=", - "owner": "input-output-hk", - "repo": "cardano-crypto", - "rev": "f73079303f663e028288f9f4a9e08bcca39a923e", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "cardano-crypto", - "rev": "f73079303f663e028288f9f4a9e08bcca39a923e", - "type": "github" - } - }, - "cardano-crypto_2": { "flake": false, "locked": { "lastModified": 1621376239, @@ -251,58 +150,7 @@ "type": "github" } }, - "cardano-ledger-specs": { - "flake": false, - "locked": { - "lastModified": 1634701482, - "narHash": "sha256-HTPOmVOXgBD/3uAxZip/HSttaKcJ+uImYDbuwANAw1c=", - "owner": "input-output-hk", - "repo": "cardano-ledger-specs", - "rev": "bf008ce028751cae9fb0b53c3bef20f07c06e333", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "cardano-ledger-specs", - "rev": "bf008ce028751cae9fb0b53c3bef20f07c06e333", - "type": "github" - } - }, - "cardano-node": { - "flake": false, - "locked": { - "lastModified": 1634904623, - "narHash": "sha256-tuEtSCJOk1MA9sguxL13XLa+qHaz//v7eNyhxHC9tHw=", - "owner": "input-output-hk", - "repo": "cardano-node", - "rev": "b6ca519f97a0e795611a63174687e6bb70c9f752", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "cardano-node", - "rev": "b6ca519f97a0e795611a63174687e6bb70c9f752", - "type": "github" - } - }, "cardano-prelude": { - "flake": false, - "locked": { - "lastModified": 1617239936, - "narHash": "sha256-BtbT5UxOAADvQD4qTPNrGfnjQNgbYNO4EAJwH2ZsTQo=", - "owner": "input-output-hk", - "repo": "cardano-prelude", - "rev": "fd773f7a58412131512b9f694ab95653ac430852", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "cardano-prelude", - "rev": "fd773f7a58412131512b9f694ab95653ac430852", - "type": "github" - } - }, - "cardano-prelude_2": { "flake": false, "locked": { "lastModified": 1641566029, @@ -335,22 +183,6 @@ "type": "github" } }, - "cardano-repo-tool_2": { - "flake": false, - "locked": { - "lastModified": 1624584417, - "narHash": "sha256-YSepT97PagR/1jTYV/Yer8a2GjFe9+tTwaTCHxuK50M=", - "owner": "input-output-hk", - "repo": "cardano-repo-tool", - "rev": "30e826ed8f00e3e154453b122a6f3d779b2f73ec", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "cardano-repo-tool", - "type": "github" - } - }, "cardano-shell": { "flake": false, "locked": { @@ -367,39 +199,6 @@ "type": "github" } }, - "cardano-shell_2": { - "flake": false, - "locked": { - "lastModified": 1608537748, - "narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=", - "owner": "input-output-hk", - "repo": "cardano-shell", - "rev": "9392c75087cb9a3d453998f4230930dea3a95725", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "cardano-shell", - "type": "github" - } - }, - "cardano-wallet": { - "flake": false, - "locked": { - "lastModified": 1639607349, - "narHash": "sha256-JuYH5pAF7gOsliES0Beo86PinoBmmKXWShXT3NqVlgQ=", - "owner": "j-mueller", - "repo": "cardano-wallet", - "rev": "760140e238a5fbca61d1b286d7a80ece058dc729", - "type": "github" - }, - "original": { - "owner": "j-mueller", - "repo": "cardano-wallet", - "rev": "760140e238a5fbca61d1b286d7a80ece058dc729", - "type": "github" - } - }, "cryptonite": { "flake": false, "locked": { @@ -496,39 +295,7 @@ "type": "github" } }, - "flake-utils_2": { - "locked": { - "lastModified": 1623875721, - "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "flat": { - "flake": false, - "locked": { - "lastModified": 1630339624, - "narHash": "sha256-5TokQ8IgZYUI6YsfUB4FovwD3xAv1ky/MpY8XmOnd4U=", - "owner": "Quid2", - "repo": "flat", - "rev": "d32c2c0c0c3c38c41177684ade9febe92d279b06", - "type": "github" - }, - "original": { - "owner": "Quid2", - "repo": "flat", - "rev": "d32c2c0c0c3c38c41177684ade9febe92d279b06", - "type": "github" - } - }, - "flat_2": { "flake": false, "locked": { "lastModified": 1641898475, @@ -579,23 +346,6 @@ "type": "github" } }, - "ghc-8.6.5-iohk_2": { - "flake": false, - "locked": { - "lastModified": 1600920045, - "narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=", - "owner": "input-output-hk", - "repo": "ghc", - "rev": "95713a6ecce4551240da7c96b6176f980af75cae", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "ref": "release/8.6.5-iohk", - "repo": "ghc", - "type": "github" - } - }, "gitignore-nix": { "flake": false, "locked": { @@ -612,47 +362,14 @@ "type": "github" } }, - "gitignore-nix_2": { - "flake": false, - "locked": { - "lastModified": 1611672876, - "narHash": "sha256-qHu3uZ/o9jBHiA3MEKHJ06k7w4heOhA+4HCSIvflRxo=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "211907489e9f198594c0eb0ca9256a1949c9d412", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "goblins": { - "flake": false, - "locked": { - "lastModified": 1598362523, - "narHash": "sha256-z9ut0y6umDIjJIRjz9KSvKgotuw06/S8QDwOtVdGiJ0=", - "owner": "input-output-hk", - "repo": "goblins", - "rev": "cde90a2b27f79187ca8310b6549331e59595e7ba", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "goblins", - "rev": "cde90a2b27f79187ca8310b6549331e59595e7ba", - "type": "github" - } - }, "hackage": { "flake": false, "locked": { - "lastModified": 1638407533, - "narHash": "sha256-ja9xIX8eMQz1zFaqHuoeGztxVnUPqIpebfFPXQCtCmU=", + "lastModified": 1642554756, + "narHash": "sha256-1+SN+z80HgKYshlCf8dRxwRojQzuwwsQ5uq14N/JP1Y=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "5786405063958e417fdbcf7e75686f35d63708ac", + "rev": "f9d5e67ca90926b244c0ad68815371d37582a149", "type": "github" }, "original": { @@ -677,38 +394,6 @@ "type": "github" } }, - "hackage-nix_2": { - "flake": false, - "locked": { - "lastModified": 1637291070, - "narHash": "sha256-hTX2Xo36i9MR6PNwA/89C8daKjxmx5ZS5lwR2Cbp8Yo=", - "owner": "input-output-hk", - "repo": "hackage.nix", - "rev": "6ea4ad5f4a5e2303cd64974329ba90ccc410a012", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "hackage.nix", - "type": "github" - } - }, - "hackage_2": { - "flake": false, - "locked": { - "lastModified": 1642554756, - "narHash": "sha256-1+SN+z80HgKYshlCf8dRxwRojQzuwwsQ5uq14N/JP1Y=", - "owner": "input-output-hk", - "repo": "hackage.nix", - "rev": "f9d5e67ca90926b244c0ad68815371d37582a149", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "hackage.nix", - "type": "github" - } - }, "haskell-language-server": { "flake": false, "locked": { @@ -742,83 +427,29 @@ "type": "github" } }, - "haskell-language-server_3": { - "flake": false, - "locked": { - "lastModified": 1638136578, - "narHash": "sha256-Reo9BQ12O+OX7tuRfaDPZPBpJW4jnxZetm63BxYncoM=", - "owner": "haskell", - "repo": "haskell-language-server", - "rev": "745ef26f406dbdd5e4a538585f8519af9f1ccb09", - "type": "github" - }, - "original": { - "owner": "haskell", - "ref": "1.5.1", - "repo": "haskell-language-server", - "type": "github" - } - }, "haskell-nix": { "inputs": { "HTTP": "HTTP", "cabal-32": "cabal-32", "cabal-34": "cabal-34", + "cabal-36": "cabal-36", "cardano-shell": "cardano-shell", "flake-utils": "flake-utils", "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", "hackage": "hackage", "hpc-coveralls": "hpc-coveralls", "nix-tools": "nix-tools", - "nixpkgs": [ - "haskell-nix", - "nixpkgs-unstable" - ], - "nixpkgs-2003": "nixpkgs-2003", - "nixpkgs-2009": "nixpkgs-2009", - "nixpkgs-2105": "nixpkgs-2105", - "nixpkgs-unstable": "nixpkgs-unstable", - "old-ghc-nix": "old-ghc-nix", - "stackage": "stackage" - }, - "locked": { - "lastModified": 1641511340, - "narHash": "sha256-cdw4HbqukogROTYG4i9LarwN6+xtRRikO0g35tvAtYk=", - "owner": "input-output-hk", - "repo": "haskell.nix", - "rev": "4aeeba8d713d0b98c92c8c717df24da17d463c1d", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "haskell.nix", - "rev": "4aeeba8d713d0b98c92c8c717df24da17d463c1d", - "type": "github" - } - }, - "haskell-nix_2": { - "inputs": { - "HTTP": "HTTP_2", - "cabal-32": "cabal-32_2", - "cabal-34": "cabal-34_2", - "cabal-36": "cabal-36", - "cardano-shell": "cardano-shell_2", - "flake-utils": "flake-utils_2", - "ghc-8.6.5-iohk": "ghc-8.6.5-iohk_2", - "hackage": "hackage_2", - "hpc-coveralls": "hpc-coveralls_2", - "nix-tools": "nix-tools_2", "nixpkgs": [ "plutarch", "haskell-nix", "nixpkgs-2111" ], - "nixpkgs-2003": "nixpkgs-2003_2", - "nixpkgs-2105": "nixpkgs-2105_2", + "nixpkgs-2003": "nixpkgs-2003", + "nixpkgs-2105": "nixpkgs-2105", "nixpkgs-2111": "nixpkgs-2111_2", - "nixpkgs-unstable": "nixpkgs-unstable_2", - "old-ghc-nix": "old-ghc-nix_2", - "stackage": "stackage_2" + "nixpkgs-unstable": "nixpkgs-unstable", + "old-ghc-nix": "old-ghc-nix", + "stackage": "stackage" }, "locked": { "lastModified": 1642811877, @@ -835,23 +466,7 @@ "type": "github" } }, - "haskell-nix_3": { - "flake": false, - "locked": { - "lastModified": 1629380841, - "narHash": "sha256-gWOWCfX7IgVSvMMYN6rBGK6EA0pk6pmYguXzMvGte+Q=", - "owner": "input-output-hk", - "repo": "haskell.nix", - "rev": "7215f083b37741446aa325b20c8ba9f9f76015eb", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "haskell.nix", - "type": "github" - } - }, - "haskell-nix_4": { + "haskell-nix_2": { "flake": false, "locked": { "lastModified": 1629380841, @@ -927,22 +542,6 @@ "type": "github" } }, - "hpc-coveralls_2": { - "flake": false, - "locked": { - "lastModified": 1607498076, - "narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=", - "owner": "sevanspowell", - "repo": "hpc-coveralls", - "rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430", - "type": "github" - }, - "original": { - "owner": "sevanspowell", - "repo": "hpc-coveralls", - "type": "github" - } - }, "hs-memory": { "flake": false, "locked": { @@ -960,23 +559,6 @@ "type": "github" } }, - "iohk-monitoring-framework": { - "flake": false, - "locked": { - "lastModified": 1624367860, - "narHash": "sha256-QE3QRpIHIABm+qCP/wP4epbUx0JmSJ9BMePqWEd3iMY=", - "owner": "input-output-hk", - "repo": "iohk-monitoring-framework", - "rev": "46f994e216a1f8b36fe4669b47b2a7011b0e153c", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "iohk-monitoring-framework", - "rev": "46f994e216a1f8b36fe4669b47b2a7011b0e153c", - "type": "github" - } - }, "iohk-nix": { "flake": false, "locked": { @@ -993,22 +575,6 @@ "type": "github" } }, - "iohk-nix_2": { - "flake": false, - "locked": { - "lastModified": 1626953580, - "narHash": "sha256-iEI9aTOaZMGsjWzcrctrC0usmiagwKT2v1LSDe9/tMU=", - "owner": "input-output-hk", - "repo": "iohk-nix", - "rev": "cbd497f5844249ef8fe617166337d59f2a6ebe90", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "iohk-nix", - "type": "github" - } - }, "nix-darwin": { "inputs": { "nixpkgs": "nixpkgs" @@ -1043,22 +609,6 @@ "type": "github" } }, - "nix-tools_2": { - "flake": false, - "locked": { - "lastModified": 1636018067, - "narHash": "sha256-ng306fkuwr6V/malWtt3979iAC4yMVDDH2ViwYB6sQE=", - "owner": "input-output-hk", - "repo": "nix-tools", - "rev": "ed5bd7215292deba55d6ab7a4e8c21f8b1564dda", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "nix-tools", - "type": "github" - } - }, "nixos-20_09": { "locked": { "lastModified": 1623585158, @@ -1121,55 +671,7 @@ "type": "github" } }, - "nixpkgs-2003_2": { - "locked": { - "lastModified": 1620055814, - "narHash": "sha256-8LEHoYSJiL901bTMVatq+rf8y7QtWuZhwwpKE2fyaRY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-20.03-darwin", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-2009": { - "locked": { - "lastModified": 1624271064, - "narHash": "sha256-qns/uRW7MR2EfVf6VEeLgCsCp7pIOjDeR44JzTF09MA=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "46d1c3f28ca991601a53e9a14fdd53fcd3dd8416", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-20.09-darwin", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs-2105": { - "locked": { - "lastModified": 1630481079, - "narHash": "sha256-leWXLchbAbqOlLT6tju631G40SzQWPqaAXQG3zH1Imw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "110a2c9ebbf5d4a94486854f18a37a938cfacbbb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-21.05-darwin", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-2105_2": { "locked": { "lastModified": 1640283157, "narHash": "sha256-6Ddfop+rKE+Gl9Tjp9YIrkfoYPzb8F80ergdjcq3/MY=", @@ -1187,11 +689,11 @@ }, "nixpkgs-2111": { "locked": { - "lastModified": 1644510859, - "narHash": "sha256-xjpVvL5ecbyi0vxtVl/Fh9bwGlMbw3S06zE5nUzFB8A=", + "lastModified": 1644793108, + "narHash": "sha256-MN/ElRTuE7pWuf99Hr1pbAxA3ApDLYuK6hIsA5sagjc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0d1d5d7e3679fec9d07f2eb804d9f9fdb98378d3", + "rev": "b61bf7a96aa6ddd3c425fa1db8c45acfdd82e36b", "type": "github" }, "original": { @@ -1234,22 +736,6 @@ } }, "nixpkgs-unstable": { - "locked": { - "lastModified": 1635295995, - "narHash": "sha256-sGYiXjFlxTTMNb4NSkgvX+knOOTipE6gqwPUQpxNF+c=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "22a500a3f87bbce73bd8d777ef920b43a636f018", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-unstable_2": { "locked": { "lastModified": 1641285291, "narHash": "sha256-KYaOBNGar3XWTxTsYPr9P6u74KAqNq0wobEC236U+0c=", @@ -1298,23 +784,6 @@ "type": "github" } }, - "nixpkgs_4": { - "flake": false, - "locked": { - "lastModified": 1628785280, - "narHash": "sha256-2B5eMrEr6O8ff2aQNeVxTB+9WrGE80OB4+oM6T7fOcc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6525bbc06a39f26750ad8ee0d40000ddfdc24acb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "old-ghc-nix": { "flake": false, "locked": { @@ -1332,94 +801,47 @@ "type": "github" } }, - "old-ghc-nix_2": { - "flake": false, - "locked": { - "lastModified": 1631092763, - "narHash": "sha256-sIKgO+z7tj4lw3u6oBZxqIhDrzSkvpHtv0Kki+lh9Fg=", - "owner": "angerman", - "repo": "old-ghc-nix", - "rev": "af48a7a7353e418119b6dfe3cd1463a657f342b8", - "type": "github" - }, - "original": { - "owner": "angerman", - "ref": "master", - "repo": "old-ghc-nix", - "type": "github" - } - }, - "optparse-applicative": { - "flake": false, - "locked": { - "lastModified": 1628901899, - "narHash": "sha256-uQx+SEYsCH7JcG3xAT0eJck9yq3y0cvx49bvItLLer8=", - "owner": "input-output-hk", - "repo": "optparse-applicative", - "rev": "7497a29cb998721a9068d5725d49461f2bba0e7a", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "optparse-applicative", - "rev": "7497a29cb998721a9068d5725d49461f2bba0e7a", - "type": "github" - } - }, - "ouroboros-network": { - "flake": false, - "locked": { - "lastModified": 1637082154, - "narHash": "sha256-FNYcUjoy0ZpletEXUIAMbag2Hwb9K3bDRl793NyNy1E=", - "owner": "input-output-hk", - "repo": "ouroboros-network", - "rev": "d613de3d872ec8b4a5da0c98afb443f322dc4dab", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "ouroboros-network", - "rev": "d613de3d872ec8b4a5da0c98afb443f322dc4dab", - "type": "github" - } - }, "plutarch": { "inputs": { "Shrinker": "Shrinker", - "Win32-network": "Win32-network_2", - "cardano-base": "cardano-base_2", - "cardano-crypto": "cardano-crypto_2", - "cardano-prelude": "cardano-prelude_2", + "Win32-network": "Win32-network", + "autodocodec": "autodocodec", + "cardano-base": "cardano-base", + "cardano-crypto": "cardano-crypto", + "cardano-prelude": "cardano-prelude", "cryptonite": "cryptonite", "flake-compat": "flake-compat", "flake-compat-ci": "flake-compat-ci", - "flat": "flat_2", + "flat": "flat", "foundation": "foundation", "haskell-language-server": "haskell-language-server", - "haskell-nix": "haskell-nix_2", + "haskell-nix": "haskell-nix", "hercules-ci-effects": "hercules-ci-effects", "hs-memory": "hs-memory", "nixpkgs": [ + "plutarch", "haskell-nix", "nixpkgs-unstable" ], "plutus": "plutus", "protolude": "protolude", + "safe-coloured-text": "safe-coloured-text", "sized-functors": "sized-functors", - "th-extras": "th-extras" + "sydtest": "sydtest", + "th-extras": "th-extras", + "validity": "validity" }, "locked": { - "lastModified": 1644875667, - "narHash": "sha256-eNKEubOfkVGmDX1HbbCTbtIjEyXfxlYedrWuwhOLVrQ=", + "lastModified": 1645006916, + "narHash": "sha256-j8o0D48LfDYqf07bi34474lkFnMZ5TNvcZmACVMw3yA=", "owner": "Plutonomicon", "repo": "plutarch", - "rev": "a0cbe99921aad7c5df9239cb0240933e4d9b2eaa", + "rev": "c77fcd605269bd8183d5496e297eb38503ea0e29", "type": "github" }, "original": { "owner": "Plutonomicon", "repo": "plutarch", - "rev": "a0cbe99921aad7c5df9239cb0240933e4d9b2eaa", "type": "github" } }, @@ -1429,7 +851,7 @@ "gitignore-nix": "gitignore-nix", "hackage-nix": "hackage-nix", "haskell-language-server": "haskell-language-server_2", - "haskell-nix": "haskell-nix_3", + "haskell-nix": "haskell-nix_2", "iohk-nix": "iohk-nix", "nixpkgs": "nixpkgs_3", "pre-commit-hooks-nix": "pre-commit-hooks-nix_2", @@ -1451,68 +873,6 @@ "type": "github" } }, - "plutus-apps": { - "flake": false, - "locked": { - "lastModified": 1642502716, - "narHash": "sha256-UULYQppoNjj+EOcV75UT3DOwJF+d609FOYsZZFeAQcM=", - "owner": "input-output-hk", - "repo": "plutus-apps", - "rev": "34fe6eeff441166fee0cd0ceba68c1439f0e93d2", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "plutus-apps", - "rev": "34fe6eeff441166fee0cd0ceba68c1439f0e93d2", - "type": "github" - } - }, - "plutus-extra": { - "flake": false, - "locked": { - "lastModified": 1643739251, - "narHash": "sha256-L7WSXvGWxfuqSP4ZNdbuT2AdW89mAJsE6+3mxO+1dx8=", - "owner": "Liqwid-Labs", - "repo": "plutus-extra", - "rev": "bfeb0d2bb1bc18f147e58c200db2022f5c75eb60", - "type": "github" - }, - "original": { - "owner": "Liqwid-Labs", - "repo": "plutus-extra", - "rev": "bfeb0d2bb1bc18f147e58c200db2022f5c75eb60", - "type": "github" - } - }, - "plutus_2": { - "inputs": { - "cardano-repo-tool": "cardano-repo-tool_2", - "gitignore-nix": "gitignore-nix_2", - "hackage-nix": "hackage-nix_2", - "haskell-language-server": "haskell-language-server_3", - "haskell-nix": "haskell-nix_4", - "iohk-nix": "iohk-nix_2", - "nixpkgs": "nixpkgs_4", - "pre-commit-hooks-nix": "pre-commit-hooks-nix_3", - "sphinxcontrib-haddock": "sphinxcontrib-haddock_2", - "stackage-nix": "stackage-nix_2" - }, - "locked": { - "lastModified": 1642090150, - "narHash": "sha256-0l8kWR9R0XkkJInbKP/1l8e5jCVhZQ7fVo7IRaXepQ8=", - "owner": "input-output-hk", - "repo": "plutus", - "rev": "65bad0fd53e432974c3c203b1b1999161b6c2dce", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "plutus", - "rev": "65bad0fd53e432974c3c203b1b1999161b6c2dce", - "type": "github" - } - }, "pre-commit-hooks-nix": { "flake": false, "locked": { @@ -1545,22 +905,6 @@ "type": "github" } }, - "pre-commit-hooks-nix_3": { - "flake": false, - "locked": { - "lastModified": 1624971177, - "narHash": "sha256-Amf/nBj1E77RmbSSmV+hg6YOpR+rddCbbVgo5C7BS0I=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "397f0713d007250a2c7a745e555fa16c5dc8cadb", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "type": "github" - } - }, "protolude": { "flake": false, "locked": { @@ -1578,66 +922,34 @@ "type": "github" } }, - "purescript-bridge": { - "flake": false, - "locked": { - "lastModified": 1635433489, - "narHash": "sha256-paaId4GJ9/Z5LstYfakiCJZ2p9Q5NMHXdXUx5rTPQKI=", - "owner": "input-output-hk", - "repo": "purescript-bridge", - "rev": "366fc70b341e2633f3ad0158a577d52e1cd2b138", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "purescript-bridge", - "rev": "366fc70b341e2633f3ad0158a577d52e1cd2b138", - "type": "github" - } - }, "root": { "inputs": { - "Win32-network": "Win32-network", - "cardano-addresses": "cardano-addresses", - "cardano-base": "cardano-base", - "cardano-crypto": "cardano-crypto", - "cardano-ledger-specs": "cardano-ledger-specs", - "cardano-node": "cardano-node", - "cardano-prelude": "cardano-prelude", - "cardano-wallet": "cardano-wallet", - "flat": "flat", - "goblins": "goblins", - "haskell-nix": "haskell-nix", - "iohk-monitoring-framework": "iohk-monitoring-framework", + "haskell-nix": [ + "plutarch", + "haskell-nix" + ], "nixpkgs": [ - "haskell-nix", - "nixpkgs-unstable" + "plutarch", + "nixpkgs" ], "nixpkgs-2111": "nixpkgs-2111", - "optparse-applicative": "optparse-applicative", - "ouroboros-network": "ouroboros-network", - "plutarch": "plutarch", - "plutus": "plutus_2", - "plutus-apps": "plutus-apps", - "plutus-extra": "plutus-extra", - "purescript-bridge": "purescript-bridge", - "servant-purescript": "servant-purescript" + "plutarch": "plutarch" } }, - "servant-purescript": { + "safe-coloured-text": { "flake": false, "locked": { - "lastModified": 1635969498, - "narHash": "sha256-VkM9Q2XkDEnQh6khptoIjQ9xW7Fc2wsOJ4vPYDzBTD4=", - "owner": "input-output-hk", - "repo": "servant-purescript", - "rev": "ebea59c7bdfc0338d83fca772b9a57e28560bcde", + "lastModified": 1644357337, + "narHash": "sha256-sXSKw8m6O9K/H2BBiYqO5e4sJIo+9UP+UvEukRn28d8=", + "owner": "srid", + "repo": "safe-coloured-text", + "rev": "034f3612525568b422e0c62b52417d77b7cf31c2", "type": "github" }, "original": { - "owner": "input-output-hk", - "repo": "servant-purescript", - "rev": "ebea59c7bdfc0338d83fca772b9a57e28560bcde", + "owner": "srid", + "ref": "ghc921", + "repo": "safe-coloured-text", "type": "github" } }, @@ -1674,30 +986,14 @@ "type": "github" } }, - "sphinxcontrib-haddock_2": { - "flake": false, - "locked": { - "lastModified": 1594136664, - "narHash": "sha256-O9YT3iCUBHP3CEF88VDLLCO2HSP3HqkNA2q2939RnVY=", - "owner": "michaelpj", - "repo": "sphinxcontrib-haddock", - "rev": "f3956b3256962b2d27d5a4e96edb7951acf5de34", - "type": "github" - }, - "original": { - "owner": "michaelpj", - "repo": "sphinxcontrib-haddock", - "type": "github" - } - }, "stackage": { "flake": false, "locked": { - "lastModified": 1638062215, - "narHash": "sha256-1kOXkElNdsUOQ0RKVHWpfxh8Tl4I0rwwusESEDkrasI=", + "lastModified": 1642468901, + "narHash": "sha256-+Hu4m9i8v8Moey/C8fy8juyxB729JdsXz02cK8nJXLk=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "17d51e4b25d266beee4f5038258269b5f87a1551", + "rev": "7544f8fd16bb92b7cf90cb51cb4ddc43173526de", "type": "github" }, "original": { @@ -1722,35 +1018,20 @@ "type": "github" } }, - "stackage-nix_2": { + "sydtest": { "flake": false, "locked": { - "lastModified": 1597712578, - "narHash": "sha256-c/pcfZ6w5Yp//7oC0hErOGVVphBLc5vc4IZlWKZ/t6E=", - "owner": "input-output-hk", - "repo": "stackage.nix", - "rev": "e32c8b06d56954865725514ce0d98d5d1867e43a", + "lastModified": 1644358460, + "narHash": "sha256-1ZxTLL5YVxktyHqfMywwsNGx5nxNMPXnq33QI6BcvUI=", + "owner": "srid", + "repo": "sydtest", + "rev": "5b572105c30f79c5e20637c6af4eedf39e0ac85a", "type": "github" }, "original": { - "owner": "input-output-hk", - "repo": "stackage.nix", - "type": "github" - } - }, - "stackage_2": { - "flake": false, - "locked": { - "lastModified": 1642468901, - "narHash": "sha256-+Hu4m9i8v8Moey/C8fy8juyxB729JdsXz02cK8nJXLk=", - "owner": "input-output-hk", - "repo": "stackage.nix", - "rev": "7544f8fd16bb92b7cf90cb51cb4ddc43173526de", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "stackage.nix", + "owner": "srid", + "ref": "ghc921", + "repo": "sydtest", "type": "github" } }, @@ -1770,6 +1051,23 @@ "rev": "787ed752c1e5d41b5903b74e171ed087de38bffa", "type": "github" } + }, + "validity": { + "flake": false, + "locked": { + "lastModified": 1644358698, + "narHash": "sha256-dpMIu08qXMzy8Kilk/2VWpuwIsfqFtpg/3mkwt5pdjA=", + "owner": "srid", + "repo": "validity", + "rev": "f7982549b95d0ab727950dc876ca06b1862135ba", + "type": "github" + }, + "original": { + "owner": "srid", + "ref": "ghc921", + "repo": "validity", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 17c8997..0c51115 100644 --- a/flake.nix +++ b/flake.nix @@ -1,89 +1,18 @@ { description = "agora"; - inputs.haskell-nix.url = - "github:input-output-hk/haskell.nix?rev=4aeeba8d713d0b98c92c8c717df24da17d463c1d"; - inputs.nixpkgs.follows = "haskell-nix/nixpkgs-unstable"; - inputs.haskell-nix.inputs.nixpkgs.follows = "haskell-nix/nixpkgs-unstable"; + inputs.nixpkgs.follows = "plutarch/nixpkgs"; + inputs.haskell-nix.follows = "plutarch/haskell-nix"; - # Temp workaround for Nix issue. - inputs.nixpkgs-2111.url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; + # temporary fix for nix versions that have the transitive follows bug + # see https://github.com/NixOS/nix/issues/6013 + inputs.nixpkgs-2111 = { url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; }; - inputs.plutus.url = - "github:input-output-hk/plutus?rev=65bad0fd53e432974c3c203b1b1999161b6c2dce"; + inputs.plutarch.url = "github:Plutonomicon/plutarch"; + inputs.plutarch.inputs.nixpkgs.follows = + "plutarch/haskell-nix/nixpkgs-unstable"; - inputs.plutarch.url = - "github:Plutonomicon/plutarch?rev=a0cbe99921aad7c5df9239cb0240933e4d9b2eaa"; - - inputs.goblins.url = - "github:input-output-hk/goblins?rev=cde90a2b27f79187ca8310b6549331e59595e7ba"; - inputs.goblins.flake = false; - - inputs.plutus-extra.url = - "github:Liqwid-Labs/plutus-extra?rev=bfeb0d2bb1bc18f147e58c200db2022f5c75eb60"; - inputs.plutus-extra.flake = false; # Could we set this to true? - - inputs.cardano-node.url = - "github:input-output-hk/cardano-node?rev=b6ca519f97a0e795611a63174687e6bb70c9f752"; - inputs.cardano-node.flake = false; - - inputs.cardano-wallet.url = - "github:j-mueller/cardano-wallet?rev=760140e238a5fbca61d1b286d7a80ece058dc729"; - inputs.cardano-wallet.flake = false; - - inputs.purescript-bridge.url = - "github:input-output-hk/purescript-bridge?rev=366fc70b341e2633f3ad0158a577d52e1cd2b138"; - inputs.purescript-bridge.flake = false; - - inputs.servant-purescript.url = - "github:input-output-hk/servant-purescript?rev=ebea59c7bdfc0338d83fca772b9a57e28560bcde"; - inputs.servant-purescript.flake = false; - - inputs.plutus-apps.url = - "github:input-output-hk/plutus-apps?rev=34fe6eeff441166fee0cd0ceba68c1439f0e93d2"; - inputs.plutus-apps.flake = false; - - inputs.cardano-addresses.url = - "github:input-output-hk/cardano-addresses?rev=d2f86caa085402a953920c6714a0de6a50b655ec"; - inputs.cardano-addresses.flake = false; - - inputs.optparse-applicative.url = - "github:input-output-hk/optparse-applicative?rev=7497a29cb998721a9068d5725d49461f2bba0e7a"; - inputs.optparse-applicative.flake = false; - - inputs.ouroboros-network.url = - "github:input-output-hk/ouroboros-network?rev=d613de3d872ec8b4a5da0c98afb443f322dc4dab"; - inputs.ouroboros-network.flake = false; - - inputs.cardano-ledger-specs.url = - "github:input-output-hk/cardano-ledger-specs?rev=bf008ce028751cae9fb0b53c3bef20f07c06e333"; - inputs.cardano-ledger-specs.flake = false; - - inputs.iohk-monitoring-framework.url = - "github:input-output-hk/iohk-monitoring-framework?rev=46f994e216a1f8b36fe4669b47b2a7011b0e153c"; - inputs.iohk-monitoring-framework.flake = false; - - inputs.cardano-prelude.url = - "github:input-output-hk/cardano-prelude?rev=fd773f7a58412131512b9f694ab95653ac430852"; - inputs.cardano-prelude.flake = false; - - inputs.cardano-base.url = - "github:input-output-hk/cardano-base?rev=654f5b7c76f7cc57900b4ddc664a82fc3b925fb0"; - inputs.cardano-base.flake = false; - - inputs.cardano-crypto.url = - "github:input-output-hk/cardano-crypto?rev=f73079303f663e028288f9f4a9e08bcca39a923e"; - inputs.cardano-crypto.flake = false; - - inputs.flat.url = - "github:Quid2/flat?rev=d32c2c0c0c3c38c41177684ade9febe92d279b06"; - inputs.flat.flake = false; - - inputs.Win32-network.url = - "github:input-output-hk/Win32-network?rev=3825d3abf75f83f406c1f7161883c438dac7277d"; - inputs.Win32-network.flake = false; - - outputs = inputs@{ self, nixpkgs, haskell-nix, plutus, ... }: + outputs = inputs@{ self, nixpkgs, haskell-nix, plutarch, ... }: let supportedSystems = with nixpkgs.lib.systems.supported; tier1 ++ tier2 ++ tier3; @@ -96,254 +25,88 @@ overlays = [ haskell-nix.overlay ]; inherit (haskell-nix) config; }; + nixpkgsFor' = system: + import nixpkgs { + inherit system; + inherit (haskell-nix) config; + }; - deferPluginErrors = true; - plutarch-development = true; + ghcVersion = "ghc921"; projectFor = system: let pkgs = nixpkgsFor system; + in let pkgs' = nixpkgsFor' system; in (nixpkgsFor system).haskell-nix.cabalProject' { src = ./.; - compiler-nix-name = "ghc8107"; - cabalProjectFileName = "cabal.project"; - - # This essentially replaces 'cabal-haskell.nix.project' - extraSources = [ - { - src = inputs.cardano-prelude; - subdirs = [ "cardano-prelude" "cardano-prelude-test" ]; - } - { - src = inputs.cardano-base; - subdirs = [ - "base-deriving-via" - "binary" - "binary/test" - "cardano-crypto-class" - "cardano-crypto-praos" - "cardano-crypto-tests" - "measures" - "orphans-deriving-via" - "slotting" - "strict-containers" - ]; - } - - { - src = inputs.iohk-monitoring-framework; - subdirs = [ - "iohk-monitoring" - "tracer-transformers" - "contra-tracer" - "plugins/backend-aggregation" - "plugins/backend-ekg" - "plugins/backend-monitoring" - "plugins/backend-trace-forwarder" - "plugins/scribe-systemd" - ]; - } - { - src = inputs.cardano-ledger-specs; - subdirs = [ - "byron/ledger/impl" - "cardano-ledger-core" - "cardano-protocol-tpraos" - "eras/alonzo/impl" - "eras/byron/chain/executable-spec" - "eras/byron/crypto" - "eras/byron/crypto/test" - "eras/byron/ledger/executable-spec" - "eras/byron/ledger/impl/test" - "eras/shelley/impl" - "eras/shelley-ma/impl" - "eras/shelley/chain-and-ledger/executable-spec" - "eras/shelley/test-suite" - "shelley/chain-and-ledger/shelley-spec-ledger-test" - "libs/non-integral" - "libs/small-steps" - "libs/cardano-ledger-pretty" - "semantics/small-steps-test" - ]; - } - { - src = inputs.ouroboros-network; - subdirs = [ - "monoidal-synchronisation" - "typed-protocols" - "typed-protocols-cborg" - "typed-protocols-examples" - "ouroboros-network" - "ouroboros-network-testing" - "ouroboros-network-framework" - "ouroboros-consensus" - "ouroboros-consensus-byron" - "ouroboros-consensus-cardano" - "ouroboros-consensus-shelley" - "io-sim" - "io-classes" - "network-mux" - "ntp-client" - ]; - } - { - src = inputs.servant-purescript; - subdirs = [ "." ]; - } - { - src = inputs.purescript-bridge; - subdirs = [ "." ]; - } - { - src = inputs.plutarch; - subdirs = [ "." ]; - } - { - src = inputs.cardano-addresses; - subdirs = [ "core" "command-line" ]; - } - { - src = inputs.goblins; - subdirs = [ "." ]; - } - { - src = inputs.optparse-applicative; - subdirs = [ "." ]; - } - { - src = inputs.cardano-crypto; - subdirs = [ "." ]; - } - { - src = inputs.Win32-network; - subdirs = [ "." ]; - } - { - src = inputs.flat; - subdirs = [ "." ]; - } - { - src = inputs.cardano-wallet; - subdirs = [ - "lib/text-class" - "lib/strict-non-empty-containers" - "lib/core" - "lib/test-utils" - "lib/numeric" - "lib/launcher" - "lib/core-integration" - "lib/cli" - "lib/dbvar" - "lib/shelley" - ]; - } - - { - src = inputs.plutus-apps; - subdirs = [ - "doc" - "freer-extras" - "playground-common" - "plutus-chain-index" - "plutus-chain-index-core" - "plutus-contract" - "plutus-ledger" - "plutus-ledger-constraints" - "plutus-pab" - "plutus-playground-server" - "plutus-use-cases" - "quickcheck-dynamic" - "web-ghc" - ]; - } - { - src = inputs.cardano-node; - subdirs = - [ "cardano-api" "cardano-node" "cardano-cli" "cardano-config" ]; - } - { - src = inputs.plutus-extra; - subdirs = [ - "tasty-plutus" - "plutus-pretty" - "plutus-numeric" - "plutus-extra" - "plutus-golden" - "plutus-laws" - "quickcheck-plutus-instances" - - ]; - } - { - src = inputs.plutus; - subdirs = [ - "plutus-benchmark" - "plutus-core" - "plutus-errors" - "plutus-ledger-api" - "plutus-metatheory" - "plutus-tx" - "plutus-tx-plugin" - "prettyprinter-configurable" - "word-array" - "stubs/plutus-ghc-stub" - ]; - } - ]; - modules = [{ - packages = { - - plutarch.flags.development = plutarch-development; - marlowe.flags.defer-plugin-errors = deferPluginErrors; - plutus-use-cases.flags.defer-plugin-errors = deferPluginErrors; - plutus-ledger.flags.defer-plugin-errors = deferPluginErrors; - plutus-contract.flags.defer-plugin-errors = deferPluginErrors; - cardano-crypto-praos.components.library.pkgconfig = - nixpkgs.lib.mkForce - [ [ (import plutus { inherit system; }).pkgs.libsodium-vrf ] ]; - cardano-crypto-class.components.library.pkgconfig = - nixpkgs.lib.mkForce - [ [ (import plutus { inherit system; }).pkgs.libsodium-vrf ] ]; - }; + compiler-nix-name = ghcVersion; + inherit (plutarch) cabalProjectLocal; + extraSources = plutarch.extraSources ++ [{ + src = inputs.plutarch; + subdirs = [ "." ]; }]; + modules = [ (plutarch.haskellModule system) ]; shell = { withHoogle = true; exactDeps = true; - nativeBuildInputs = with pkgs; [ - cabal-install - hlint - haskellPackages.fourmolu - nixfmt - haskellPackages.cabal-fmt - haskellPackages.apply-refact - haskellPackages.record-dot-preprocessor - entr - gnumake - - graphviz + # We use the ones from Nixpkgs, since they are cached reliably. + # Eventually we will probably want to build these with haskell.nix. + nativeBuildInputs = [ + pkgs'.git + pkgs'.haskellPackages.apply-refact + pkgs'.fd + pkgs'.cabal-install + pkgs'.hlint + pkgs'.haskellPackages.cabal-fmt + pkgs'.nixpkgs-fmt ]; - additional = ps: [ ps.plutarch ps.plutus-ledger ps.plutus-extra ]; + inherit (plutarch) tools; - tools.haskell-language-server = { }; + additional = ps: [ ps.plutarch ps.tasty-quickcheck ]; }; }; + + formatCheckFor = system: + let + pkgs = nixpkgsFor system; + pkgs' = nixpkgsFor' system; + in pkgs.runCommand "format-check" { + nativeBuildInputs = [ + pkgs'.git + pkgs'.fd + pkgs'.haskellPackages.cabal-fmt + pkgs'.nixpkgs-fmt + (pkgs.haskell-nix.tools ghcVersion { + inherit (plutarch.tools) fourmolu; + }).fourmolu + ]; + } '' + export LC_CTYPE=C.UTF-8 + export LC_ALL=C.UTF-8 + export LANG=C.UTF-8 + cd ${self} + make format_check + mkdir $out + ''; in { project = perSystem projectFor; flake = perSystem (system: (projectFor system).flake { }); packages = perSystem (system: self.flake.${system}.packages); - checks = perSystem (system: self.flake.${system}.checks); + checks = perSystem (system: + self.flake.${system}.checks // { + formatCheck = formatCheckFor system; + }); check = perSystem (system: (nixpkgsFor system).runCommand "combined-test" { - nativeBuildInputs = builtins.attrValues self.checks.${system}; - } "touch $out"); - apps = perSystem (system: self.flake.${system}.apps); - devShell = perSystem (system: - self.flake.${system}.devShell.overrideAttrs (oldAttrs: { - buildInputs = (nixpkgsFor system).lib.unique oldAttrs.buildInputs; - })); + checksss = builtins.attrValues self.checks.${system}; + } '' + echo $checksss + touch $out + ''); + devShell = perSystem (system: self.flake.${system}.devShell); defaultPackage = perSystem (system: self.flake.${system}.packages."agora:lib:agora"); }; diff --git a/src/Agora/AuthorityToken.hs b/src/Agora/AuthorityToken.hs index 913ff0b..0734987 100644 --- a/src/Agora/AuthorityToken.hs +++ b/src/Agora/AuthorityToken.hs @@ -5,18 +5,20 @@ module Agora.AuthorityToken ( AuthorityToken (..), ) where --------------------------------------------------------------------------------- +import Plutarch.Api.V1 ( + PScriptContext (..), + PScriptPurpose (..), + PTxInInfo (..), + PTxInfo (..), + PTxOut (..), + ) +import Plutarch.List (pfoldr') +import Plutarch.Monadic qualified as P +import Plutus.V1.Ledger.Value (AssetClass) import Prelude -------------------------------------------------------------------------------- -import Plutus.V1.Ledger.Value (AssetClass (..)) - --------------------------------------------------------------------------------- - -import Plutarch.Api.V1 -import Plutarch.List (pfoldr') -import Plutarch.Prelude import Agora.SafeMoney @@ -29,8 +31,8 @@ import Agora.SafeMoney _this_ token's existence in order to prevent incorrect minting. -} newtype AuthorityToken = AuthorityToken - { -- | Token that must move in order for minting this to be valid. - authority :: AssetClass + { authority :: AssetClass + -- ^ Token that must move in order for minting this to be valid. } -------------------------------------------------------------------------------- @@ -40,49 +42,35 @@ authorityTokenPolicy :: Term s (PData :--> PScriptContext :--> PUnit) authorityTokenPolicy params = plam $ \_redeemer ctx' -> - pmatch ctx' $ \(PScriptContext ctx) -> - let txInfo' = pfromData $ pfield @"txInfo" # ctx - purpose' = pfromData $ pfield @"purpose" # ctx - - inputs = - pmatch txInfo' $ \(PTxInfo txInfo) -> - pfromData $ pfield @"inputs" # txInfo - - authorityTokenInputs = + pmatch ctx' $ \(PScriptContext ctx') -> P.do + ctx <- pletFields @'["txInfo", "purpose"] ctx' + PTxInfo txInfo' <- pmatch $ pfromData ctx.txInfo + txInfo <- pletFields @'["inputs", "mint"] txInfo' + let inputs = txInfo.inputs :: Term _ (PBuiltinList (PAsData PTxInInfo)) + let authorityTokenInputs = pfoldr' - ( \txInInfo' acc -> - pmatch (pfromData txInInfo') $ \(PTxInInfo txInInfo) -> - let txOut' = - pfromData $ pfield @"resolved" # txInInfo - txOutValue = - pmatch txOut' $ - \(PTxOut txOut) -> - pfromData $ pfield @"value" # txOut - in passetClassValueOf' params.authority # txOutValue + acc + ( \txInInfo' acc -> P.do + PTxInInfo txInInfo <- pmatch (pfromData txInInfo') + PTxOut txOut' <- pmatch $ pfromData $ pfield @"resolved" # txInInfo + txOut <- pletFields @'["value"] txOut' + let txOutValue = pfromData txOut.value + passetClassValueOf' params.authority # txOutValue + acc ) - # (0 :: Term s PInteger) + # 0 # inputs - - -- We incur the cost twice here. This will be fixed upstream in Plutarch. - mintedValue = - pmatch txInfo' $ \(PTxInfo txInfo) -> - pfromData $ pfield @"mint" # txInfo - - tokenMoved = 0 #< authorityTokenInputs - in pmatch purpose' $ \case - PMinting sym' -> - let sym = pfromData $ pfield @"_0" # sym' - mintedATs = passetClassValueOf # sym # pconstant "" # mintedValue - in pif - (0 #< mintedATs) - ( pif - tokenMoved - -- The authority token moved, we are good to go for minting. - (pconstant ()) - (ptraceError "Authority token did not move in minting GATs") - ) - -- We minted 0 or less Authority Tokens, we are good to go. - -- Burning is always allowed. - (pconstant ()) - _ -> - ptraceError "Wrong script type" + let mintedValue = pfromData txInfo.mint + let tokenMoved = 0 #< authorityTokenInputs + PMinting sym' <- pmatch $ pfromData ctx.purpose + let sym = pfromData $ pfield @"_0" # sym' + let mintedATs = passetClassValueOf # sym # pconstant "" # mintedValue + pif + (0 #< mintedATs) + ( pif + tokenMoved + -- The authority token moved, we are good to go for minting. + (pconstant ()) + (ptraceError "Authority token did not move in minting GATs") + ) + -- We minted 0 or less Authority Tokens, we are good to go. + -- Burning is always allowed. + (pconstant ()) diff --git a/src/Agora/SafeMoney.hs b/src/Agora/SafeMoney.hs index f4107fb..daa9553 100644 --- a/src/Agora/SafeMoney.hs +++ b/src/Agora/SafeMoney.hs @@ -1,5 +1,6 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wwarn=missing-methods #-} {-# OPTIONS_GHC -Wwarn=unused-imports #-} diff --git a/src/Agora/SafeMoney/QQ.hs b/src/Agora/SafeMoney/QQ.hs index 29a5213..8219fa4 100644 --- a/src/Agora/SafeMoney/QQ.hs +++ b/src/Agora/SafeMoney/QQ.hs @@ -4,10 +4,8 @@ module Agora.SafeMoney.QQ (discrete) where -import Control.Arrow ((&&&)) -import Data.Ratio (denominator, numerator) -import Debug.Trace import GHC.Real (Ratio ((:%))) +import Language.Haskell.TH qualified as TH (Type) import Language.Haskell.TH.Quote (QuasiQuoter (QuasiQuoter)) import Language.Haskell.TH.Syntax ( Dec (TySynD), @@ -20,18 +18,15 @@ import Language.Haskell.TH.Syntax ( Type (AppT, ConT, LitT, PromotedTupleT), lookupTypeName, reify, - reifyType, ) -import PlutusTx.Ratio (unsafeRatio) import Text.ParserCombinators.ReadP (readP_to_S, skipSpaces) -import Text.Read (lexP, readMaybe, readPrec_to_P) +import Text.Read (lexP, readPrec_to_P) import Text.Read.Lex (Lexeme (Ident, Number), Number, numberToFixed, numberToRational) import Prelude -------------------------------------------------------------------------------- import Plutarch.Internal (punsafeCoerce) -import Plutarch.Prelude hiding (Type) import Agora.SafeMoney @@ -81,7 +76,7 @@ parseDiscreteRatioExp s = errorDiscretePat :: String -> Q Pat errorDiscretePat _ = fail "Cannot use 'discrete' in a pattern context." -errorDiscreteType :: String -> Q Type +errorDiscreteType :: String -> Q TH.Type errorDiscreteType _ = fail "Cannot use 'discrete' in a type context." errorDiscreteDiscretelaration :: String -> Q [Dec] diff --git a/src/Agora/Stake.hs b/src/Agora/Stake.hs index 34dddc9..21ab7af 100644 --- a/src/Agora/Stake.hs +++ b/src/Agora/Stake.hs @@ -1,4 +1,5 @@ {-# LANGUAGE PolyKinds #-} +{-# LANGUAGE UndecidableInstances #-} -- | Vote-lockable stake UTXOs holding GT module Agora.Stake ( @@ -22,7 +23,6 @@ import Plutarch.DataRepr ( PIsDataReprInstances (PIsDataReprInstances), ) import Plutarch.Internal -import Plutarch.Prelude -------------------------------------------------------------------------------- @@ -46,14 +46,14 @@ data StakeAction (gt :: MoneyClass) (s :: S) newtype StakeDatum (gt :: MoneyClass) (s :: S) = StakeDatum { getStakeDatum :: - ( Term - s - ( PDataRecord - '[ "stakedAmount" ':= Discrete gt - , "owner" ':= PPubKeyHash - ] - ) - ) + ( Term + s + ( PDataRecord + '[ "stakedAmount" ':= Discrete gt + , "owner" ':= PPubKeyHash + ] + ) + ) } deriving stock (GHC.Generic) deriving anyclass (Generic) @@ -65,10 +65,10 @@ newtype StakeDatum (gt :: MoneyClass) (s :: S) = StakeDatum assert :: Term s PString -> Term s PBool -> TermCont @r s () assert errorMessage check = TermCont $ \k -> pif check (k ()) (ptraceError errorMessage) -pfindDatum :: Term s (PDatumHash :--> PTxInfo :--> PMaybe PDatum) -pfindDatum = phoistAcyclic $ - plam $ \_datumHash _txInfo -> unTermCont $ do - pure (pcon PNothing) +-- pfindDatum :: Term s (PDatumHash :--> PTxInfo :--> PMaybe PDatum) +-- pfindDatum = phoistAcyclic $ +-- plam $ \_datumHash _txInfo -> unTermCont $ do +-- pure (pcon PNothing) stakePolicy :: forall (gt :: MoneyClass) s. diff --git a/src/PPrelude.hs b/src/PPrelude.hs new file mode 100644 index 0000000..3a8025b --- /dev/null +++ b/src/PPrelude.hs @@ -0,0 +1,7 @@ +module PPrelude ( + module Prelude, + module Plutarch.Prelude, +) where + +import Plutarch.Prelude +import Prelude