Skip to content

Commit

Permalink
Merge pull request #5 from telostat/slim-down
Browse files Browse the repository at this point in the history
Slimming Down and Refactor
  • Loading branch information
vst authored Mar 3, 2022
2 parents edf932c + 7a6832c commit 32c51c3
Show file tree
Hide file tree
Showing 33 changed files with 1,459 additions and 1,629 deletions.
38 changes: 38 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
############################
# HLint Configuration File #
############################

# See https://github.com/ndmitchell/hlint

#######################
# MODULE RESTRICTIONS #
#######################

- modules:
- {name: Control.Monad.Error, within: []}
- {name: [Data.Aeson], as: Aeson}
- {name: Data.ByteString, as: B }
- {name: Data.ByteString.Char8, as: BC }
- {name: Data.ByteString.Lazy, as: BL }
- {name: Data.ByteString.Lazy.Char8, as: BLC }
- {name: Data.Text, as: T }
- {name: Data.Text.Lazy, as: TL }
- {name: Data.Text.Encoding, as: TE }

##########################
# EXTENSION RESTRICTIONS #
##########################

- extensions:
- default: false # All extension are banned by default
- name: [DataKinds, DerivingVia] # Only these listed extensions can be used

################
# CUSTOM RULES #
################

# Replace a $ b $ c with a . b $ c
- group: {name: dollar, enabled: true}

# Generalise map to fmap, ++ to <>
- group: {name: generalise, enabled: true}
114 changes: 112 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,118 @@
> reach the first minor version. Until then, we will keep bumping the patch
> version.
*haspara* is a Haskell library providing data definitions and functions to work
with monetary values.
*haspara* is a Haskell library that provides monetary definitions and a
rudimentary (and experimental) accounting functionality.

## Development

Before committing code to repository, reformat the code:

```sh
stylish-haskell -i -r src/
```

Compile the codebase, check warnings and errors:

```sh
stack test
stack build
stack haddock
```

Run [hlint](https://github.com/ndmitchell/hlint):

```sh
hlint src/
```

Run [weeder](https://hackage.haskell.org/package/weeder):

```sh
weeder --require-hs-files
```

## Making Releases

1. Switch to `develop` branch:

```sh
git checkout develop
```

1. Ensure that your development branch is up to date:

```sh
git pull
```

1. Checkout `main` branch:

```sh
git checkout main
```

1. Merge `develop` branch to `main`:

```sh
git merge --no-ff develop
```

1. Update the `version` information in [package.yaml](./package.yaml) if
required and recompile the project to reflect the change on the `.cabal`
file:

```sh
stack build
```

1. Update [CHANGELOG.md](./CHANGELOG.md) file:

```sh
git-chglog --next-tag <NEW-VERSION> -o CHANGELOG.md
```

1. Commit, tag and push:

```sh
git commit -am "chore(release): <NEW-VERSION>"
git tag -a -m "Release <NEW-VERSION>" <NEW-VERSION>
git push --follow-tags origin main
```

1. Release to Hackage as a candidate first and check the result:

```sh
stack upload --pvp-bounds both --candidate .
```

1. If the candidate package release works fine, release to Hackage:

```sh
stack upload --pvp-bounds both .
```

1. Checkout to `develop` and rebase onto `main`:

```sh
git checkout develop
git rebase main
```

1. Update the `version` information in [package.yaml](./package.yaml) with the
upcoming version and recompile the project to reflect the change on the
`.cabal` file:

```sh
stack build
```

1. Commit and push:

```sh
git commit -am "chore: bump development version to <UPCOMING-VERSION>"
git push
```

## License

Expand Down
60 changes: 43 additions & 17 deletions haspara.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,63 @@ library
Haspara
Haspara.Accounting
Haspara.Accounting.Account
Haspara.Accounting.AccountKind
Haspara.Accounting.Entry
Haspara.Accounting.Event
Haspara.Accounting.Ledger
Haspara.Accounting.Posting
Haspara.Accounting.Types
Haspara.Currency
Haspara.Date
Haspara.FXQuote
Haspara.Id
Haspara.Internal.Currency
Haspara.Internal.Date
Haspara.Internal.FXQuote
Haspara.Internal.FXQuoteDatabase
Haspara.Internal.Id
Haspara.Internal.Money
Haspara.Internal.Quantity
Haspara.Money
Haspara.FxQuote
Haspara.Internal.Aeson
Haspara.Monetary
Haspara.Quantity
Haspara.TH
other-modules:
Paths_haspara
hs-source-dirs:
src
default-extensions:
BangPatterns
BinaryLiterals
ConstrainedClassMethods
ConstraintKinds
DeriveDataTypeable
DeriveFoldable
DeriveFunctor
DeriveGeneric
DeriveLift
DeriveTraversable
EmptyCase
EmptyDataDeriving
ExistentialQuantification
ExplicitForAll
FlexibleContexts
FlexibleInstances
GADTSyntax
GeneralisedNewtypeDeriving
HexFloatLiterals
ImportQualifiedPost
InstanceSigs
KindSignatures
MultiParamTypeClasses
NamedFieldPuns
NamedWildCards
NumericUnderscores
PolyKinds
PostfixOperators
RankNTypes
ScopedTypeVariables
StandaloneDeriving
StandaloneKindSignatures
TupleSections
TypeApplications
TypeOperators
TypeSynonymInstances
OverloadedStrings
ghc-options: -Wall -Wunused-packages
build-depends:
aeson
, base >=4.11 && <5
, containers
, deriving-aeson
, exceptions
, hashable
, megaparsec
, mtl
Expand All @@ -70,7 +96,6 @@ library
, template-haskell
, text
, time
, unordered-containers
default-language: Haskell2010

test-suite haspara-doctest
Expand All @@ -84,8 +109,10 @@ test-suite haspara-doctest
build-depends:
aeson
, base >=4.11 && <5
, containers
, deriving-aeson
, doctest
, exceptions
, hashable
, haspara
, megaparsec
Expand All @@ -96,5 +123,4 @@ test-suite haspara-doctest
, template-haskell
, text
, time
, unordered-containers
default-language: Haskell2010
41 changes: 40 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ extra-source-files:
dependencies:
- base >= 4.11 && < 5
- aeson
- containers
- deriving-aeson
- exceptions
- hashable
- megaparsec
- mtl
Expand All @@ -27,14 +29,51 @@ dependencies:
- template-haskell
- text
- time
- unordered-containers

library:
source-dirs: src
ghc-options:
- -Wall
- -Wunused-packages
default-extensions:
## Begin: Haskell 2021 Extensions List
- BangPatterns
- BinaryLiterals
- ConstrainedClassMethods
- ConstraintKinds
- DeriveDataTypeable
- DeriveFoldable
- DeriveFunctor
- DeriveGeneric
- DeriveLift
- DeriveTraversable
- EmptyCase
- EmptyDataDeriving
- ExistentialQuantification
- ExplicitForAll
- FlexibleContexts
- FlexibleInstances
- GADTSyntax
- GeneralisedNewtypeDeriving
- HexFloatLiterals
- ImportQualifiedPost
- InstanceSigs
- KindSignatures
- MultiParamTypeClasses
- NamedFieldPuns
- NamedWildCards
- NumericUnderscores
- PolyKinds
- PostfixOperators
- RankNTypes
- ScopedTypeVariables
- StandaloneDeriving
- StandaloneKindSignatures
- TupleSections
- TypeApplications
- TypeOperators
- TypeSynonymInstances
## End: Haskell 2021 Extensions List
- OverloadedStrings

tests:
Expand Down
17 changes: 9 additions & 8 deletions src/Haspara.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
-- | This module provides high-level definitions of @haspara@ library.
--
-- @haspara@ provides rudimentary (and experimental) accounting functionality,
-- too. These definitions can be found under "Haspara.Accounting" module.

module Haspara
( module Haspara.Currency
, module Haspara.Date
, module Haspara.FXQuote
, module Haspara.Id
, module Haspara.Money
, module Haspara.FxQuote
, module Haspara.Monetary
, module Haspara.Quantity
) where

import Haspara.Currency
import Haspara.Date
import Haspara.FXQuote
import Haspara.Id
import Haspara.Money
import Haspara.FxQuote
import Haspara.Monetary
import Haspara.Quantity
21 changes: 13 additions & 8 deletions src/Haspara/Accounting.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- | This module provides a collection of definitions for a rudimentary
-- accounting functionality.

module Haspara.Accounting
( Account(..)
, AccountKind(..)
Expand All @@ -12,7 +15,6 @@ module Haspara.Accounting
, Posting(..)
, postingEvents
, post
, UnsignedQuantity
, Ledger(..)
, LedgerItem(..)
, mkLedger
Expand All @@ -25,18 +27,21 @@ module Haspara.Accounting
) where


import Haspara.Accounting.Account (Account(..))
import Haspara.Accounting.AccountKind (AccountKind(..), accountKindText)
import Haspara.Accounting.Entry
import Haspara.Accounting.Account (Account(..), AccountKind(..), accountKindText)
import Haspara.Accounting.Event (Event(..), eventDate, eventObject, mkEvent, negateEvent)
import Haspara.Accounting.Ledger
( Entry(..)
, Ledger(..)
, LedgerItem(..)
, Posting(..)
, addEntry
, buildEntry
, entryCredit
, entryDate
, entryDebit
, entryObject
, entryQuantity
, mkLedger
, post
, postingEvents
)
import Haspara.Accounting.Event (Event(..), eventDate, eventObject, mkEvent, negateEvent)
import Haspara.Accounting.Ledger (Ledger(..), LedgerItem(..), addEntry, mkLedger)
import Haspara.Accounting.Posting (Posting(..), post, postingEvents)
import Haspara.Accounting.Types (UnsignedQuantity)
Loading

0 comments on commit 32c51c3

Please sign in to comment.