Skip to content

Commit

Permalink
Add and apply fourmolu code formatter. (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
koslambrou authored Dec 18, 2024
1 parent 8d49242 commit a1bb795
Show file tree
Hide file tree
Showing 94 changed files with 8,157 additions and 6,968 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ protocol-parameters-mainnet.json
.pre-commit-config.yaml
download-tx-test.sh
tx.json
graph.dot
graph.dot
.vim
3 changes: 0 additions & 3 deletions fix-stylish-haskell.sh

This file was deleted.

53 changes: 53 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Number of spaces per indentation step
indentation: 2

# Max line length for automatic line breaking
column-limit: none

# Styling of arrows in type signatures (choices: trailing, leading, or leading-args)
function-arrows: leading

# How to place commas in multi-line lists, records, etc. (choices: leading or trailing)
comma-style: leading

# Styling of import/export lists (choices: leading, trailing, or diff-friendly)
import-export-style: diff-friendly

# Whether to full-indent or half-indent 'where' bindings past the preceding body
indent-wheres: false

# Whether to leave a space before an opening record brace
record-brace-space: false

# Number of spaces between top-level declarations
newlines-between-decls: 1

# How to print Haddock comments (choices: single-line, multi-line, or multi-line-compact)
haddock-style: multi-line

# How to print module docstring
haddock-style-module: null

# Styling of let blocks (choices: auto, inline, newline, or mixed)
let-style: auto

# How to align the 'in' keyword with respect to the 'let' keyword (choices: left-align, right-align, or no-space)
in-style: right-align

# Whether to put parentheses around a single constraint (choices: auto, always, or never)
single-constraint-parens: always

# Whether to put parentheses around a single deriving class (choices: auto, always, or never)
single-deriving-parens: always

# Output Unicode syntax (choices: detect, always, or never)
unicode: never

# Give the programmer more choice on where to insert blank lines
respectful: true

# Fixity information for operators
fixities: []

# Module reexports Fourmolu should know about
reexports: []
2 changes: 1 addition & 1 deletion nix/outputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ in
project.flake
)
{
devShells.profiled = project.variants.profiled.devShells.default;
devShells.default = project.variants.profiled.devShells.default;
}
]
22 changes: 19 additions & 3 deletions nix/project.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@ let
sha256map = {
};

cardano-node = inputs.cardano-node.packages.cardano-node;
cardano-cli = inputs.cardano-cli.legacyPackages.cardano-cli;

modules = [
({ config, ... }: {
packages = {
# TODO
# convex-base.ghcOptions = [ "-Werror" ];
# convex-coin-selection.ghcOptions = [ "-Werror" ];
# TODO Fails because `cardano-cli`, and `cardano-node` is not on PATH
# when running tests with Nix. I don't know how to include packages as
# inputs when running tests (doesn't seem supported by Haskell.nix). The
# alternative would be to allow env variables in complement to absolute
# paths, and use preCheck to set the env variables.
convex-devnet.doCheck = false;

# Werror everything. This is a pain, see https://github.com/input-output-hk/haskell.nix/issues/519
convex-base.ghcOptions = [ "-Werror" ];
convex-coin-selection.ghcOptions = [ "-Werror" ];
convex-blockfrost.ghcOptions = [ "-Werror" ];
convex-devnet.ghcOptions = [ "-Werror" ];
convex-mockchain.ghcOptions = [ "-Werror" ];
convex-node-client.ghcOptions = [ "-Werror" ];
convex-optics.ghcOptions = [ "-Werror" ];
convex-wallet.ghcOptions = [ "-Werror" ];
};
})
];
Expand Down
5 changes: 2 additions & 3 deletions nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ in
# To maintain a the same hooks for both nix and non-nix environment you should update the `.pre-commit-config.yaml.nonix`
# (`cp .pre-commit-config.yaml .pre-commit-config.yaml.nonix`).
# This step is necessary because `.pre-commit-config.yaml` is ignored by git.
# TODO To enable in a future PR
# cabal-fmt.enable = true;
stylish-haskell.enable = true;
cabal-fmt.enable = true;
fourmolu.enable = true;
# nixpkgs-fmt.enable = true;
};
}
181 changes: 95 additions & 86 deletions src/base/convex-base.cabal
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cabal-version: 3.4
name: convex-base
version: 0.3.0.0
synopsis: Base classes and types for working with cardano-api transactions
license: Apache-2.0
license-files:
LICENSE
synopsis:
Base classes and types for working with cardano-api transactions

license: Apache-2.0
license-files: LICENSE
maintainer: [email protected]
author: Jann Müller
homepage: https://github.com/j-mueller/sc-tools
Expand All @@ -16,101 +16,110 @@ description:
build-type: Simple

common lang
default-language: Haskell2010
default-extensions: ExplicitForAll ScopedTypeVariables MultiParamTypeClasses
DeriveGeneric StandaloneDeriving DeriveLift FlexibleContexts
GeneralizedNewtypeDeriving DeriveFunctor DeriveFoldable
DeriveTraversable ImportQualifiedPost NumericUnderscores
ghc-options: -Wall -Wnoncanonical-monad-instances -Wunused-packages
-Wincomplete-uni-patterns -Wincomplete-record-updates
-Wredundant-constraints -Widentities
default-language: Haskell2010
default-extensions:
DeriveFoldable
DeriveFunctor
DeriveGeneric
DeriveLift
DeriveTraversable
ExplicitForAll
FlexibleContexts
GeneralizedNewtypeDeriving
ImportQualifiedPost
MultiParamTypeClasses
NumericUnderscores
ScopedTypeVariables
StandaloneDeriving

library
import: lang
exposed-modules:
Convex.BuildTx
Convex.Class
Convex.Constants
Convex.Eon
Convex.MonadLog
Convex.NodeQueries
Convex.NodeQueries.Debug
Convex.NodeParams
Convex.PlutusLedger.V1
Convex.PlutusLedger.V3
Convex.PlutusTx
Convex.ResolvedTx
Convex.Utils
Convex.Utxos
Convex.UtxoMod
hs-source-dirs: lib
build-depends:
base >= 4.14 && < 4.20,
lens,
containers,
aeson,
mtl,
katip,
prettyprinter,
transformers,
text,
exceptions,
time,
either-result,
primitive,
QuickCheck

build-depends:
convex-optics,
ghc-options:
-Wall -Wnoncanonical-monad-instances -Wunused-packages
-Wincomplete-uni-patterns -Wincomplete-record-updates
-Wredundant-constraints -Widentities

cardano-api == 10.1.0.0,
cardano-ledger-core,
cardano-crypto-wrapper,
cardano-binary,
library
import: lang
exposed-modules:
Convex.BuildTx
Convex.Class
Convex.Constants
Convex.Eon
Convex.MonadLog
Convex.NodeParams
Convex.NodeQueries
Convex.NodeQueries.Debug
Convex.PlutusLedger.V1
Convex.PlutusLedger.V3
Convex.PlutusTx
Convex.ResolvedTx
Convex.Utils
Convex.UtxoMod
Convex.Utxos

cardano-ledger-byron,
cardano-ledger-mary,
cardano-ledger-shelley,
cardano-ledger-babbage,
cardano-ledger-alonzo,
cardano-ledger-conway,
cardano-crypto-class,
hs-source-dirs: lib
build-depends:
, aeson
, base >=4.14 && <4.20
, containers
, either-result
, exceptions
, katip
, lens
, mtl
, prettyprinter
, primitive
, QuickCheck
, text
, time
, transformers

ouroboros-consensus,
ouroboros-consensus-cardano,
ouroboros-network-protocols,
cardano-slotting,
plutus-tx,
plutus-ledger-api,
serialise,
bytestring,
dlist,
either-result,
strict-sop-core,
graphviz,
base16-bytestring
build-depends:
, base16-bytestring
, bytestring
, cardano-api ==10.1.0.0
, cardano-binary
, cardano-crypto-class
, cardano-crypto-wrapper
, cardano-ledger-alonzo
, cardano-ledger-babbage
, cardano-ledger-byron
, cardano-ledger-conway
, cardano-ledger-core
, cardano-ledger-mary
, cardano-ledger-shelley
, cardano-slotting
, convex-optics
, dlist
, either-result
, graphviz
, ouroboros-consensus
, ouroboros-consensus-cardano
, ouroboros-network-protocols
, plutus-ledger-api
, plutus-tx
, serialise
, strict-sop-core

test-suite convex-base-test
import: lang
type: exitcode-stdio-1.0
import: lang
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is:
Spec.hs
other-modules:
Convex.PlutusLedgerSpec
build-tool-depends:
tasty-discover:tasty-discover
main-is: Spec.hs
other-modules: Convex.PlutusLedgerSpec
build-tool-depends: tasty-discover:tasty-discover

-- Local dependencies
build-depends:
, convex-base
build-depends: convex-base

-- CHaP dependencies
build-depends:
, cardano-api
, cardano-api:gen

-- Hackage dependencies
build-depends:
, base >= 4.14.0
, base >=4.14.0
, hedgehog-quickcheck
, QuickCheck
, tasty
, tasty-quickcheck
, QuickCheck
, hedgehog-quickcheck
Loading

0 comments on commit a1bb795

Please sign in to comment.