prefix-units 0.1.0 → 0.1.0.1
raw patch · 5 files changed
+60/−42 lines, 5 filesdep ~QuickCheckdep ~test-frameworkdep ~test-framework-quickcheck2PVP ok
version bump matches the API change (PVP)
Dependency ranges changed: QuickCheck, test-framework, test-framework-quickcheck2
API changes (from Hackage documentation)
Files
- CHANGES +5/−0
- Data/Prefix/Units.hs +29/−30
- Makefile +10/−1
- README.md +5/−0
- prefix-units.cabal +11/−11
CHANGES view
@@ -1,3 +1,8 @@+Version 0.1.0.1++* Trivial release updating upper package bounds (for testing), and+ updating homepage/related settings as part of move to github+ Version 0.1.0 * Initial release
Data/Prefix/Units.hs view
@@ -1,6 +1,6 @@ {- -Copyright 2012, Google Inc.+Copyright 2012, 2014, Google Inc. All rights reserved. Redistribution and use in source and binary forms, with or without@@ -348,7 +348,7 @@ -> a -- ^ The value to format -> (a, Maybe Unit) -- ^ Scaled value and optional unit formatValue fmt val =- let unit = either (flip recommendedUnit val) Just fmt+ let unit = either (`recommendedUnit` val) Just fmt scaled = maybe val (scaleToUnit val) unit in (scaled, unit) @@ -385,32 +385,32 @@ -- | Parses a symbol in the exact mode. See 'ParseExact' for details. parseExactSymbol :: String -> Either String Unit-parseExactSymbol "y" = Right Yocto-parseExactSymbol "z" = Right Zepto-parseExactSymbol "a" = Right Atto-parseExactSymbol "f" = Right Femto-parseExactSymbol "p" = Right Pico-parseExactSymbol "n" = Right Nano-parseExactSymbol "u" = Right Micro-parseExactSymbol "m" = Right Milli-parseExactSymbol "c" = Right Centi-parseExactSymbol "d" = Right Deci+parseExactSymbol "y" = Right Yocto+parseExactSymbol "z" = Right Zepto+parseExactSymbol "a" = Right Atto+parseExactSymbol "f" = Right Femto+parseExactSymbol "p" = Right Pico+parseExactSymbol "n" = Right Nano+parseExactSymbol "u" = Right Micro+parseExactSymbol "m" = Right Milli+parseExactSymbol "c" = Right Centi+parseExactSymbol "d" = Right Deci parseExactSymbol "da" = Right Deka-parseExactSymbol "h" = Right Hecto-parseExactSymbol "k" = Right Kilo+parseExactSymbol "h" = Right Hecto+parseExactSymbol "k" = Right Kilo parseExactSymbol "Ki" = Right Kibi-parseExactSymbol "M" = Right Mega+parseExactSymbol "M" = Right Mega parseExactSymbol "Mi" = Right Mebi-parseExactSymbol "G" = Right Giga+parseExactSymbol "G" = Right Giga parseExactSymbol "Gi" = Right Gibi-parseExactSymbol "T" = Right Tera+parseExactSymbol "T" = Right Tera parseExactSymbol "Ti" = Right Tebi-parseExactSymbol "P" = Right Peta+parseExactSymbol "P" = Right Peta parseExactSymbol "Pi" = Right Pebi-parseExactSymbol "E" = Right Exa+parseExactSymbol "E" = Right Exa parseExactSymbol "Ei" = Right Exbi-parseExactSymbol "Z" = Right Zetta-parseExactSymbol "Y" = Right Yotta+parseExactSymbol "Z" = Right Zetta+parseExactSymbol "Y" = Right Yotta parseExactSymbol unit = unknownUnit unit -- | Helper for 'parseBinarySymbol' which only deals with upper-case@@ -463,9 +463,9 @@ data ParseMode = ParseExact -- ^ Exact parser mode. This mode is fully -- case-sensitive.- | ParseKMGT -- ^ Parses only units with bigger than 'Kilo',- -- respectively 'Kibi' (for binary units). This allows- -- the parser to be case-insensitive.+ | ParseKMGT -- ^ Parses only units bigger than 'Kilo',+ -- respectively 'Kibi' (for binary units). This+ -- allows the parser to be case-insensitive. | ParseBinary -- ^ Parses binary units only. In this mode, both the -- exact and shortened forms are accepted (e.g. both -- \"k\" and \"ki\" will be converted into@@ -491,13 +491,12 @@ parseSymbol ParseKMGT = parseKMGTSymbol parseSymbol ParseBinary = parseBinarySymbol --- | Generic parse routine. Takes two function arguments which fix the--- initial and final conversion, a parse mode and the string to be--- parsed.+-- | Main parse routine. parseValue :: (Read a, RationalConvertible a) => ParseMode -- ^ The desired parse mode -> String -- ^ String to be parsed- -> Either String a+ -> Either String a -- ^ Either a Left error message, or+ -- a Right parsed value parseValue = parseGeneric UnitOptional [] -- | Validate a parsed unit using a given valid options list.@@ -527,8 +526,8 @@ -- String a" monad instance either Left (validUnit valid_units) (parseSymbol pmode unit_suffix) --- | Generic parse routine. Takes two function arguments which fix the--- initial and final conversion, a parse mode and the string to be+-- | Low-level parse routine. Takes two function arguments which fix+-- the initial and final conversion, a parse mode and the string to be -- parsed. parseGeneric :: (Read a, RationalConvertible a) => ParseOptions -- ^ Unit options
Makefile view
@@ -23,4 +23,13 @@ dist: cabal sdist -.PHONY: build int-docs haddock configure test dist+lint:+ @rm -f report.html+ hlint --report -c Data++clean:+ cabal clean+ rm -rf dist+ rm -f report.html++.PHONY: build int-docs haddock configure test dist lint clean
README.md view
@@ -20,6 +20,11 @@ are enough. Run `cabal configure --enable-tests && cabal build && cabal test` if you want to run the unit-tests. +The library is designed to have very few dependencies (only base and a+few GHC extensions), so that it's trivial to use it in projects. Hence+the use of some hand-coded conversions instead of using+TemplateHaskell to generate them automatically.+ TODO ----
prefix-units.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.1.0+Version: 0.1.0.1 -- A short (one-line) description of the package. Synopsis: A basic library for SI/binary prefix units@@ -23,7 +23,7 @@ <http://physics.nist.gov/cuu/Units/binary.html>. -- URL for the project homepage or repository.-Homepage: http://code.google.com/p/prefix-units/+Homepage: https://github.com/iustin/prefix-units -- The license under which the package is released. License: BSD3@@ -39,14 +39,14 @@ Maintainer: Iustin Pop <iustin@google.com> -- A copyright notice.-Copyright: (c) 2012 Google Inc.+Copyright: (c) 2012, 2014 Google Inc. Category: Data -- Stability field. Stability: alpha -Bug-reports: https://code.google.com/p/prefix-units/issues/+Bug-reports: https://github.com/iustin/prefix-units/issues Build-type: Simple @@ -57,16 +57,16 @@ -- Constraint on the version of Cabal needed to build this package. Cabal-version: >= 1.8.0.2 -Tested-with: GHC==6.12.1, GHC==7.4.1+Tested-with: GHC==6.12.1, GHC==7.4.1, GHC==7.6.3 Source-repository head Type: git- Location: https://code.google.com/p/prefix-units/+ Location: https://github.com/iustin/prefix-units.git Source-repository this Type: git- Location: https://code.google.com/p/prefix-units/- Tag: prefix-units-v0.1.0+ Location: https://github.com/iustin/prefix-units.git+ Tag: prefix-units-v0.1.0.1 Library -- Modules exported by the library.@@ -91,8 +91,8 @@ main-is: Properties.hs build-depends: base >= 3 && < 5 , Cabal >= 1.9.2- , test-framework >= 0.6 && < 0.7- , test-framework-quickcheck2 >= 0.2.12 && < 0.3- , QuickCheck >= 2.4.2 && < 2.5+ , test-framework >= 0.6 && < 0.9+ , test-framework-quickcheck2 >= 0.2.12 && < 0.4+ , QuickCheck >= 2.4.2 && < 2.7 , prefix-units ghc-options: -Wall -fno-warn-orphans