formatn 0.3.0.1 → 0.3.1.0
raw patch · 5 files changed
+151/−70 lines, 5 filesdep +doctest-paralleldep ~QuickCheckdep ~basePVP ok
version bump matches the API change (PVP)
Dependencies added: doctest-parallel
Dependency ranges changed: QuickCheck, base
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- formatn.cabal +23/−61
- readme.md +116/−0
- src/Data/FormatN.hs +0/−9
- test/doctests.hs +8/−0
+ ChangeLog.md view
@@ -0,0 +1,4 @@+0.3.1+===++- added doctests
formatn.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: formatn-version: 0.3.0.1+version: 0.3.1.0 license: BSD-3-Clause license-file: LICENSE copyright: Tony Day (c) 2016@@ -12,15 +12,21 @@ synopsis: Formatting of doubles. description: This package provides support for number formatting styles, especially styles involving significant figure calculations.- .+ == Usage- .+ >>> import Data.FormatN >>> comma (Just 3) 1234 1,230 build-type: Simple-tested-with: GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.2.5 || ==9.4.7 || ==9.6.3 || ==9.8.1+tested-with:+ , GHC == 9.10.1+ , GHC == 9.6.5+ , GHC == 9.8.2+extra-doc-files:+ ChangeLog.md+ readme.md source-repository head type: git@@ -37,69 +43,25 @@ -Wredundant-constraints common ghc2021-stanza- if impl ( ghc >= 9.2 )- default-language: GHC2021-- if impl ( ghc < 9.2 )- default-language: Haskell2010- default-extensions:- BangPatterns- BinaryLiterals- ConstrainedClassMethods- ConstraintKinds- DeriveDataTypeable- DeriveFoldable- DeriveFunctor- DeriveGeneric- DeriveLift- DeriveTraversable- DoAndIfThenElse- EmptyCase- EmptyDataDecls- EmptyDataDeriving- ExistentialQuantification- ExplicitForAll- FlexibleContexts- FlexibleInstances- ForeignFunctionInterface- GADTSyntax- GeneralisedNewtypeDeriving- HexFloatLiterals- ImplicitPrelude- InstanceSigs- KindSignatures- MonomorphismRestriction- MultiParamTypeClasses- NamedFieldPuns- NamedWildCards- NumericUnderscores- PatternGuards- PolyKinds- PostfixOperators- RankNTypes- RelaxedPolyRec- ScopedTypeVariables- StandaloneDeriving- StarIsType- TraditionalRecordSyntax- TupleSections- TypeApplications- TypeOperators- TypeSynonymInstances-- if impl ( ghc < 9.2 ) && impl ( ghc >= 8.10 )- default-extensions:- ImportQualifiedPost- StandaloneKindSignatures+ default-language: GHC2021 library import: ghc-options-stanza import: ghc2021-stanza hs-source-dirs: src build-depends:- -- just for cabal-docspec --check-properties- , QuickCheck >=2.14.2 && <2.15- , base >=4.7 && <5+ , base >=4.14 && <5 , containers >=0.6 && <0.8 , text >=1.2 && <2.2 exposed-modules: Data.FormatN++test-suite doctests+ import: ghc2021-stanza+ main-is: doctests.hs+ hs-source-dirs: test+ build-depends:+ , QuickCheck >=2.14.2 && <2.16+ , base >=4.14 && <5+ , doctest-parallel >=0.3 && <0.4+ ghc-options: -threaded+ type: exitcode-stdio-1.0
+ readme.md view
@@ -0,0 +1,116 @@++# formatn ++[](https://hackage.haskell.org/package/formatn) [](https://github.com/tonyday567/formatn/actions?query=workflow%3Ahaskell-ci)++A library for support of:++- significant figure rounding of numbers, and+- common number formatting patterns.++<a id="org95ded84"></a>++# Usage++ :reload+ :set prompt "> "+ + :set -Wno-type-defaults+ :set -XOverloadedStrings+ import Data.FormatN+ + xs = [(-1),0,0.1,1,1.01,1.02,1.1,1.2]+ + fixed (Just 2) <$> xs+ decimal (Just 2) <$> xs+ formats False False (const DecimalStyle) (Just 2) xs+ formats False True (const DecimalStyle) (Just 2) xs+ distinguish 4 False True (const DecimalStyle) (Just 2) xs++ Ok, 14 modules loaded.+ > >+ >+ > ["-1.00","0.00","0.10","1.00","1.01","1.02","1.10","1.20"]+ ["-1.0","0.0","0.10","1.0","1.0","1.0","1.1","1.2"]+ ["-1.00","0.00","0.10","1.00","1.00","1.00","1.10","1.20"]+ ["-1.0","0.0","0.1","1.0","1.0","1.0","1.1","1.2"]+ ["-1.00","0.00","0.10","1.00","1.01","1.02","1.10","1.20"]+++<a id="orgb82f98d"></a>++# getting 0 right+++<a id="orgaf42992"></a>++## fixed++ fixed (Just 3) <$> [0, 0.5, 1.5, 2.0]++ ["0.000","0.500","1.500","2.000"]++fixed defaults to representing Doubles in the same manner as Haskell does ie with a trailing ’.0’++ fixed Nothing <$> [0, 0.5, 1.5, 2]++ ["0.0","0.5","1.5","2.0"]+++<a id="org1b53172"></a>++## expt++ expt Nothing 0++ 0e0++ expt (Just 2) 1+ expt (Just 2) 0++ 1.0e0+ 0.0e0+++<a id="org90e32fb"></a>++## decimal++ decimal Nothing 0+ decimal (Just 1) 0+ decimal (Just 3) 0++ 0+ 0+ 0.00+++<a id="orgbe4b502"></a>++## percent++percent is a little weird any way you cut it.++ percent decimalSF (Just 4) 0+ percent decimalSF (Just 4) 1++ 0.0%+ 100.0%+++<a id="org549dfe5"></a>++## inclusion in lists++ formats True False commaPrecStyle Nothing [0, 0.5, 1.5, 2]+ formats True False commaPrecStyle (Just 1) [0, 1, 10]+ formats True False commaPrecStyle (Just 1) [0, 0.5, 1.5, 2]+ formats True False commaPrecStyle (Just 2) [0, 0.5, 1.5, 2]+ formats True True commaPrecStyle (Just 6) [0, 0.5, 1.5, 2]++ ["0.0","0.5","1.5","2.0"]+ [" 0"," 1","10"]+ ["0.0","0.5","2.0","2.0"]+ ["0.00","0.50","1.50","2.00"]+ ["0.0","0.5","1.5","2.0"]+
src/Data/FormatN.hs view
@@ -1,13 +1,4 @@-{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RankNTypes #-}-{-# LANGUAGE StrictData #-}-{-# LANGUAGE TupleSections #-}-{-# OPTIONS_GHC -Wall #-}-{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}-{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}--{-# HLINT ignore "Use =<<" #-} -- | Text formatting of 'Double's. --
+ test/doctests.hs view
@@ -0,0 +1,8 @@+module Main where++import System.Environment (getArgs)+import Test.DocTest (mainFromCabal)+import Prelude (IO, (=<<))++main :: IO ()+main = mainFromCabal "formatn" =<< getArgs