Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d99fca1
Edited gitignore to account for differing nix setups
jhodgdev Mar 29, 2022
cdda9e7
Added stub files
jhodgdev Mar 29, 2022
135161c
Stubbed out the entirety of contexts
jhodgdev Mar 29, 2022
72b269b
continued speccing out components
jhodgdev Mar 29, 2022
6783cf4
Added numerous functions to Apropos gen extra
jhodgdev Mar 30, 2022
11b2aa8
Merge branch 'main' of github.com:mlabs-haskell/apropos-tx into jhodg…
jhodgdev Apr 4, 2022
4e3ef85
Fixed CI build issue
jhodgdev Apr 4, 2022
7c7a1bf
Formatting
jhodgdev Apr 4, 2022
afff43e
linting suggestions
jhodgdev Apr 4, 2022
81cc01f
Merge branch 'jhodgdev/ci-improvments' of github.com:mlabs-haskell/ap…
jhodgdev Apr 5, 2022
0378c18
Merge branch 'main' of github.com:mlabs-haskell/apropos-tx into jhodg…
jhodgdev Apr 5, 2022
258d1e9
switch to hercules, add fmt checks to flake
brainrake Apr 6, 2022
81ddfba
Added first round of docstrings
jhodgdev Apr 6, 2022
86e32ed
use inputs from devShell for check
brainrake Apr 6, 2022
eca0e88
clear unused top binds warning for gen extra
jhodgdev Apr 6, 2022
b1d9c9d
Merge branch 'marton/hercules-ci' of github.com:brainrape/apropos-tx …
jhodgdev Apr 6, 2022
589b1f0
finished documenting gen extra
jhodgdev Apr 6, 2022
567af28
Set up local hoogle
jhodgdev Apr 6, 2022
ecd2662
Merge branch 'jhodgdev/local-hoogle' of github.com:mlabs-haskell/apro…
jhodgdev Apr 6, 2022
8d515ad
Added interval to apropos-tx.cabal
jhodgdev Apr 7, 2022
fd7f0e4
Added docstrings to script
jhodgdev Apr 7, 2022
16e0274
finished adding docstrings
jhodgdev Apr 7, 2022
d435de5
Exported more from modules
jhodgdev Apr 7, 2022
5257325
Updated txid ref for compatibility
jhodgdev Apr 8, 2022
dd292b4
Removed data' function as was v. slow
jhodgdev Apr 11, 2022
58148d5
Replaced inefficient calls to element with choice
jhodgdev Apr 28, 2022
23fb121
Formatting
jhodgdev Apr 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/format.sh

This file was deleted.

78 changes: 0 additions & 78 deletions .github/workflows/integrate.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ cabal.project.local*
# ctags
tags
TAGS

# Local hoogle
.hoogle
.haddock
27 changes: 16 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# are made availible by the nix shell defined in shell.nix.
# In most cases you should execute Make after entering nix-shell.

SHELL := /usr/bin/env bash

.PHONY: hoogle build test watch ghci readme_contents \
format lint refactor requires_nix_shell

Expand All @@ -25,16 +23,20 @@ usage:
@echo " format_check -- Check source code formatting without making changes"
@echo " cabalfmt -- Apply cabal formatting with cabal-fmt"
@echo " cabalfmt_check -- Check cabal files for formatting errors without making changes"
@echo " nixfmt -- Apply nix formatting with nixfmt"
@echo " nixfmt_check -- Check nix files for format errors"
@echo " nixpkgsfmt -- Apply nix formatting with nixpkgs-fmt"
@echo " nixpkgsfmt_check -- Check nix files for format errors"
@echo " lint -- Check the sources with hlint"
@echo " refactor_cautious -- Automatically apply hlint refactors, with prompt"
@echo " refactor -- Automatically apply hlint refactors, without prompt"
@echo " readme_contents -- Add table of contents to README"
@echo " update_plutus -- Update plutus version with niv"
@echo " haddock -- Generate haddock docs.

hoogle: requires_nix_shell
hoogle server --local
pkill hoogle || true
hoogle generate --local=.haddock --database=.hoogle/local.hoo
hoogle server --local -p 8080 >> /dev/null &
hoogle server --local --database=.hoogle/local.hoo -p 8081 >> /dev/null &

STACK_EXE_PATH = $(shell stack $(STACK_FLAGS) path --local-install-root)/bin

Expand Down Expand Up @@ -71,7 +73,7 @@ format: requires_nix_shell
format_check: requires_nix_shell
fourmolu --mode check --check-idempotence $(FORMAT_EXTENSIONS) $(FORMAT_SOURCES)

CABAL_SOURCES := $(shell git ls-tree -r HEAD --full-tree --name-only | grep -E '.*\.cabal' )
CABAL_SOURCES := $(shell fd -ecabal)

cabalfmt: requires_nix_shell
cabal-fmt --inplace $(CABAL_SOURCES)
Expand All @@ -80,13 +82,13 @@ cabalfmt_check: requires_nix_shell
cabal-fmt --check $(CABAL_SOURCES)

# Nix files to format
NIX_SOURCES := $(shell git ls-tree -r HEAD --full-tree --name-only | grep -E '.*\.nix' )
NIX_SOURCES := $(shell fd -enix)

nixfmt: requires_nix_shell
nixfmt $(NIX_SOURCES)
nixpkgsfmt: requires_nix_shell
nixpkgs-fmt $(NIX_SOURCES)

nixfmt_check: requires_nix_shell
nixfmt --check $(NIX_SOURCES)
nixpkgsfmt_check: requires_nix_shell
nixpkgs-fmt --check $(NIX_SOURCES)

# Check with hlint, currently I couldn't get --refactor to work
lint: requires_nix_shell
Expand Down Expand Up @@ -123,3 +125,6 @@ update_plutus:
@echo "Make sure to update the plutus rev in cabal.project with:"
@echo " commit: $(PLUTUS_REV)"
@echo "This may require further resolution of dependency versions."

haddock: requires_nix_shell
cabal haddock --haddock-html --haddock-hoogle --builddir=.haddock
17 changes: 17 additions & 0 deletions apropos-tx.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ common lang
build-depends:
, apropos
, base >=4.14
, bytestring
, containers
, free
, hedgehog
Expand All @@ -49,6 +50,7 @@ common lang
, plutarch
, plutus-core
, plutus-ledger-api
, plutus-tx
, pretty
, pretty-show
, safe
Expand All @@ -64,6 +66,18 @@ common lang
library
import: lang
exposed-modules:
Apropos.Gen.Address
Apropos.Gen.Api
Apropos.Gen.Contexts
Apropos.Gen.Credential
Apropos.Gen.Crypto
Apropos.Gen.DCert
Apropos.Gen.Extra
Apropos.Gen.Interval
Apropos.Gen.Scripts
Apropos.Gen.Time
Apropos.Gen.TxId
Apropos.Gen.Value
Apropos.Script
Apropos.Tx

Expand All @@ -88,6 +102,9 @@ test-suite examples
, containers
, hedgehog
, mtl
, plutarch
, plutus-core
, plutus-ledger-api
, tasty
, tasty-hedgehog
, text
4 changes: 2 additions & 2 deletions examples/Spec/Int.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ instance HasParameterisedGenerator IntProp Int where
else
if IsMaxBound `elem` s
then pure maxBound
else int (linear 11 (maxBound -1))
else int (linear 11 (maxBound - 1))
if IsNegative `elem` s
then
if IsMinBound `elem` s
then pure minBound
else pure (- i)
else pure (-i)
else pure i

intGenTests :: TestTree
Expand Down
4 changes: 2 additions & 2 deletions examples/Spec/IntPermutationGen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ instance HasPermutationGenerator IntProp Int where
{ name = "MakeLarge"
, match = Not $ Var IsLarge
, contract = clear >> addAll [IsLarge, IsPositive]
, morphism = \_ -> int (linear 11 (maxBound -1))
, morphism = \_ -> int (linear 11 (maxBound - 1))
}
, Morphism
{ name = "MakeSmall"
Expand All @@ -83,7 +83,7 @@ instance HasPermutationGenerator IntProp Int where
[ has IsNegative >> remove IsNegative >> add IsPositive
, has IsPositive >> remove IsPositive >> add IsNegative
]
, morphism = \i -> pure (- i)
, morphism = \i -> pure (-i)
}
]

Expand Down
2 changes: 1 addition & 1 deletion examples/Spec/Plutarch/CostModel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ numCostModels = 10

peano :: Integer -> Term s PInteger
peano 0 = 0
peano i = papp (plam (+ 1)) (peano (i -1))
peano i = papp (plam (+ 1)) (peano (i - 1))

addCost :: Integer -> Script
addCost i = compile $ peano i
Expand Down
2 changes: 1 addition & 1 deletion examples/Spec/Plutarch/MagicNumber.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ numMagicNumbers = 4

-- accepts a range of numbers determined by a Magic Number
magicNumber :: Integer -> Script
magicNumber i = compile $ plam $ \ii -> pif ((pfromData ii #<= (fromInteger i :: Term s PInteger)) #&& ((fromInteger (- i) :: Term s PInteger) #<= pfromData ii)) (pcon PUnit) perror
magicNumber i = compile $ plam $ \ii -> pif ((pfromData ii #<= (fromInteger i :: Term s PInteger)) #&& ((fromInteger (-i) :: Term s PInteger) #<= pfromData ii)) (pcon PUnit) perror

data MagicNumberProp = HalfWidth Integer
deriving stock (Eq, Ord, Show)
Expand Down
62 changes: 34 additions & 28 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@

nixpkgsFor = system: import nixpkgs { inherit system; overlays = [ haskell-nix.overlay ]; inherit (haskell-nix) config; };

fourmoluFor = system: (nixpkgsFor system).haskell-nix.tool "ghc8107" "fourmolu" { };

projectFor = system:
let
deferPluginErrors = true;
pkgs = nixpkgsFor system;

fakeSrc = pkgs.runCommand "real-source" {} ''
fakeSrc = pkgs.runCommand "real-source" { } ''
cp -rT ${self} $out
chmod u+w $out/cabal.project
cat $out/cabal-haskell.nix.project >> $out/cabal.project
Expand Down Expand Up @@ -55,51 +57,55 @@

# We use the ones from Nixpkgs, since they are cached reliably.
# Eventually we will probably want to build these with haskell.nix.
nativeBuildInputs = [ pkgs.cabal-install pkgs.hlint pkgs.haskellPackages.fourmolu ];
nativeBuildInputs = with pkgs; [ cabal-install hlint (fourmoluFor system) fd haskellPackages.cabal-fmt nixpkgs-fmt coreutils ];

additional = ps: [
ps.plutarch
ps.apropos
];
};
sha256map = {
"https://github.com/Plutonomicon/plutarch"."f8b7eb06184112ae2bebdec5a8156010141a05d5"
= "sha256-y9lalsaTFVEPCoE/P8d4bduJJLSBvVpo/791mI9kcO4=";
"https://github.com/mlabs-haskell/apropos"."3734bb3baa297ed990725a5ef14efcbb6a1c1c23"
= "sha256-C2gQrd5hFvQ+BsjAJs6V0iP9PRzd9dZMKtpk7kOjhwc=";
"https://github.com/input-output-hk/plutus.git"."6d8d25d1e84b2a4278da1036aab23da4161b8df8"
= "o8m86TkI1dTo74YbE9CPPNrBfSDSrf//DMq+v2+woEY=";
"https://github.com/Quid2/flat.git"."ee59880f47ab835dbd73bea0847dab7869fc20d8"
= "lRFND+ZnZvAph6ZYkr9wl9VAx41pb3uSFP8Wc7idP9M=";
"https://github.com/input-output-hk/cardano-crypto.git"."07397f0e50da97eaa0575d93bee7ac4b2b2576ec"
= "oxIOVlgm07FAEmgGRF1C2me9TXqVxQulEOcJ22zpTRs=";
"https://github.com/input-output-hk/cardano-base"."78b3928391b558fb1750228f63301ec371f13528"
= "pBUTTcenaSLMovHKGsaddJ7Jh3okRTrtu5W7Rdu6RM4=";
"https://github.com/input-output-hk/cardano-prelude"."fd773f7a58412131512b9f694ab95653ac430852"
= "BtbT5UxOAADvQD4qTPNrGfnjQNgbYNO4EAJwH2ZsTQo=";
"https://github.com/input-output-hk/Win32-network"."3825d3abf75f83f406c1f7161883c438dac7277d"
= "Hesb5GXSx0IwKSIi42ofisVELcQNX6lwHcoZcbaDiqc=";
"https://github.com/Plutonomicon/plutarch"."f8b7eb06184112ae2bebdec5a8156010141a05d5" = "sha256-y9lalsaTFVEPCoE/P8d4bduJJLSBvVpo/791mI9kcO4=";
"https://github.com/mlabs-haskell/apropos"."3734bb3baa297ed990725a5ef14efcbb6a1c1c23" = "sha256-C2gQrd5hFvQ+BsjAJs6V0iP9PRzd9dZMKtpk7kOjhwc=";
"https://github.com/input-output-hk/plutus.git"."6d8d25d1e84b2a4278da1036aab23da4161b8df8" = "o8m86TkI1dTo74YbE9CPPNrBfSDSrf//DMq+v2+woEY=";
"https://github.com/Quid2/flat.git"."ee59880f47ab835dbd73bea0847dab7869fc20d8" = "lRFND+ZnZvAph6ZYkr9wl9VAx41pb3uSFP8Wc7idP9M=";
"https://github.com/input-output-hk/cardano-crypto.git"."07397f0e50da97eaa0575d93bee7ac4b2b2576ec" = "oxIOVlgm07FAEmgGRF1C2me9TXqVxQulEOcJ22zpTRs=";
"https://github.com/input-output-hk/cardano-base"."78b3928391b558fb1750228f63301ec371f13528" = "pBUTTcenaSLMovHKGsaddJ7Jh3okRTrtu5W7Rdu6RM4=";
"https://github.com/input-output-hk/cardano-prelude"."fd773f7a58412131512b9f694ab95653ac430852" = "BtbT5UxOAADvQD4qTPNrGfnjQNgbYNO4EAJwH2ZsTQo=";
"https://github.com/input-output-hk/Win32-network"."3825d3abf75f83f406c1f7161883c438dac7277d" = "Hesb5GXSx0IwKSIi42ofisVELcQNX6lwHcoZcbaDiqc=";
};
};
formatCheckFor = system:
let
pkgs = nixpkgsFor system;
in
pkgs.runCommand "format-check"
{
nativeBuildInputs = [ self.devShell.${system}.nativeBuildInputs ];
} ''
cd ${self}
IN_NIX_SHELL=true make format_check cabalfmt_check nixpkgsfmt_check lint
mkdir $out
'';
in
{
ciNix = flake-compat-ci.lib.recurseIntoFlakeWith {
flake = self;
systems = [ "x86_64-linux" ];
};

project = perSystem projectFor;
flake = perSystem (system: (projectFor system).flake {});
flake = perSystem (system: (projectFor system).flake { });

# this could be done automatically, but would reduce readability
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"
(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);

herculesCI.ciSystems = [ "x86_64-linux" ];
};
}
22 changes: 22 additions & 0 deletions src/Apropos/Gen/Address.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{- |
Module: Apropos.Gen.Address
Description: Address generators.
Maintainer: jack@mlabs.city

`Gen`s for `Plutus.V1.Ledger.Address` types.
-}
module Apropos.Gen.Address (address) where

import Apropos.Gen (Gen)
import Apropos.Gen.Credential (credential, stakingCredential)
import Apropos.Gen.Extra qualified as Gen (maybe)
import Plutus.V1.Ledger.Address (
Address (Address),
)

-- | Generator for Plutus `Address` types.
address :: Gen Address
address = do
cred <- credential
scred <- Gen.maybe stakingCredential
return $ Address cred scred
Loading