units 2.4.1 → 2.4.1.1
raw patch · 6 files changed
+90/−27 lines, 6 files
Files
- CHANGES.md +4/−0
- Data/Metrology/Show.hs +2/−1
- Data/Metrology/Z.hs +1/−1
- Tests/LennardJones.hs +20/−20
- Tests/Main.hs +0/−2
- units.cabal +63/−3
CHANGES.md view
@@ -1,6 +1,10 @@ Release notes for `units` ========================= +Version 2.4.1.1+---------------+* Fix some GHC compatibility issues, thanks to @ocharles.+ Version 2.4.1 ------------- * Add `Units` superclass to `UnitFactor`, easing type inference in
Data/Metrology/Show.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE PolyKinds, DataKinds, TypeOperators, FlexibleInstances,- ScopedTypeVariables, FlexibleContexts, ConstraintKinds, CPP #-}+ ScopedTypeVariables, FlexibleContexts, ConstraintKinds, CPP,+ UndecidableInstances #-} #if __GLASGOW_HASKELL__ < 709 {-# LANGUAGE OverlappingInstances #-}
Data/Metrology/Z.hs view
@@ -10,7 +10,7 @@ {-# LANGUAGE TypeFamilies, DataKinds, TypeOperators, UndecidableInstances, GADTs, PolyKinds, TemplateHaskell, ScopedTypeVariables,- EmptyCase, CPP #-}+ EmptyCase, CPP, TypeSynonymInstances, FlexibleInstances #-} {-# OPTIONS_GHC -fno-warn-missing-signatures #-} -----------------------------------------------------------------------------
Tests/LennardJones.hs view
@@ -33,19 +33,19 @@ sSix = SS sFive-sSeven = SS sSix -sEight = SS sSeven -sNine = SS sEight -sTen = SS sNine -sEleven = SS sTen -sTwelve = SS sEleven -sThirteen= SS sTwelve +sSeven = SS sSix+sEight = SS sSeven+sNine = SS sEight+sTen = SS sNine+sEleven = SS sTen+sTwelve = SS sEleven+sThirteen= SS sTwelve data EV = EV instance Show EV where show _ = "eV" instance Unit EV where- type BaseUnit EV = Joule + type BaseUnit EV = Joule conversionRatio _ = 1.60217657e-19 data ProtonMass = ProtonMass@@ -87,7 +87,7 @@ type BPara = MkQu_DLN BParameterDim ljForceP :: Energy l Float -> Length l Float -> Length l Float -> Force l Float-ljForceP eps sigma r +ljForceP eps sigma r = redim $ 24 *| eps |*| sigma|^ sSix |/| r |^ sSeven |-| 48 *| eps |*| sigma|^ sTwelve |/| r |^ sThirteen @@ -103,7 +103,7 @@ ljForcePOpt :: APara l Float -> BPara l Float -> Length l Float -> Force l Float-ljForcePOpt a b r +ljForcePOpt a b r = redim $ b |/| r |^ sSeven |-| a |/| r |^ sThirteen @@ -141,16 +141,16 @@ val = 9.3407324e-14 in testGroup "LennardJones"- [ testCase "NaN" (assert (isNaN $ ljForce (4 % Å) # Newton))- , testCase "NaNPoly" (assert (isNaN $ (ljForceP (convert epsAr) (convert sigmaAr) (4 % Å) :: Force SI Float) # Newton))+ [ testCase "NaN" (assertBool "NaN" (isNaN $ ljForce (4 % Å) # Newton))+ , testCase "NaNPoly" (assertBool "NaNPoly" (isNaN $ (ljForceP (convert epsAr) (convert sigmaAr) (4 % Å) :: Force SI Float) # Newton)) , testCase "CU" ((ljForceP (convert epsAr) (convert sigmaAr) (4 % Å) :: Force CU Float) # Newton @?~ val)- , testCase "ansNaN" (assert $ isNaN $ (ans :: Force SI Float) # Newton)+ , testCase "ansNaN" (assertBool "ansNaN" $ isNaN $ (ans :: Force SI Float) # Newton) , testCase "ansCU" ((ans :: Force CU Float) # Newton @?~ val)- , testCase "optNaN" (assert $ isNaN $ (ljForcePOpt aParaAr bParaAr (4%Å) :: Force SI Float) # Newton)+ , testCase "optNaN" (assertBool "optNaN" $ isNaN $ (ljForcePOpt aParaAr bParaAr (4%Å) :: Force SI Float) # Newton) , testCase "optCU" ((ljForcePOpt aParaAr bParaAr (4%Å) :: Force CU Float) # Newton @?~ val)- , testCase "precompNaN" (assert $ isNaN $ (ljForcePOpt aParaAr' bParaAr' (4%Å) :: Force SI Float) # Newton)- , testCase "precompNaN2" (assert $ isNaN $ (ljForcePOpt aParaAr' bParaAr' (4%Å) :: Force CU Float) # Newton)- , testCase "precompPolyNaN" (assert $ isNaN $ (ljForcePOpt aParaAr'' bParaAr'' (4%Å) :: Force SI Float) # Newton)+ , testCase "precompNaN" (assertBool "precompNaN" $ isNaN $ (ljForcePOpt aParaAr' bParaAr' (4%Å) :: Force SI Float) # Newton)+ , testCase "precompNaN2" (assertBool "precompNaN2" $ isNaN $ (ljForcePOpt aParaAr' bParaAr' (4%Å) :: Force CU Float) # Newton)+ , testCase "precompPolyNaN" (assertBool "precompPolyNaN" $ isNaN $ (ljForcePOpt aParaAr'' bParaAr'' (4%Å) :: Force SI Float) # Newton) , testCase "precompPolyCU" ((ljForcePOpt aParaAr'' bParaAr'' (4%Å) :: Force CU Float) # Newton @?~ val) ] {- main :: IO ()@@ -169,7 +169,7 @@ let ans :: (ConvertibleLCSUs_D D.Length SI l, ConvertibleLCSUs_D D.Energy SI l)=> Force l Float ans = ljForceP (convert epsAr) (convert sigmaAr) (4 % Å) - putStrLn "We compare again:" + putStrLn "We compare again:" putStrLn $ (ans :: Force SI Float) `showIn` (Newton) putStrLn $ (ans :: Force CU Float) `showIn` (Newton) @@ -181,10 +181,10 @@ putStrLn $ "We cannot use the default LCSU for calculating constants in this case." putStrLn $ (ljForcePOpt aParaAr' bParaAr' (4%Å):: Force SI Float) `showIn` Newton putStrLn $ (ljForcePOpt aParaAr' bParaAr' (4%Å):: Force CU Float) `showIn` Newton- + putStrLn $ "We must pay attention in which LCSU the constants are computed in." putStrLn $ (ljForcePOpt aParaAr'' bParaAr'' (4%Å):: Force SI Float) `showIn` Newton- putStrLn $ (ljForcePOpt aParaAr'' bParaAr'' (4%Å):: Force CU Float) `showIn` Newton + putStrLn $ (ljForcePOpt aParaAr'' bParaAr'' (4%Å):: Force CU Float) `showIn` Newton
Tests/Main.hs view
@@ -31,7 +31,6 @@ import qualified Tests.Linearity import qualified Tests.OffSystemAdd import qualified Tests.OffSystemCSU-import qualified Tests.Parser import qualified Tests.PhysicalConstants import qualified Tests.Show import qualified Tests.Travel@@ -51,7 +50,6 @@ , Tests.Linearity.tests , Tests.OffSystemAdd.tests , Tests.OffSystemCSU.tests- , Tests.Parser.tests , Tests.PhysicalConstants.tests , Tests.Show.tests , Tests.Travel.tests
units.cabal view
@@ -1,5 +1,5 @@ name: units-version: 2.4.1+version: 2.4.1.1 cabal-version: >= 1.10 synopsis: A domain-specific type system for dimensional analysis homepage: https://github.com/goldfirere/units@@ -24,7 +24,7 @@ license: BSD3 license-file: LICENSE build-type: Simple-Tested-With: GHC == 7.8.4, GHC == 7.10.2, GHC == 7.10.3, GHC == 8.0.1, GHC == 8.0.2, GHC == 8.2.1+Tested-With: GHC == 7.8.4, GHC == 7.10.2, GHC == 7.10.3, GHC == 8.0.1, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.1, GHC == 8.6.3 description: The units package provides a mechanism for compile-time@@ -47,7 +47,7 @@ source-repository this type: git location: https://github.com/goldfirere/units.git- tag: v2.4.1+ tag: v2.4.1.1 library ghc-options: -Wall@@ -128,3 +128,63 @@ -- GHC 7.10 requires this in more places, and I don't feel like ferreting out exactly -- where. default-extensions: FlexibleContexts++ other-modules:+ Data.Constants.Math+ Data.Dimensions.SI+ Data.Metrology+ Data.Metrology.Combinators+ Data.Metrology.Dimensions+ Data.Metrology.Factor+ Data.Metrology.Internal+ Data.Metrology.LCSU+ Data.Metrology.Parser+ Data.Metrology.Poly+ Data.Metrology.Qu+ Data.Metrology.Quantity+ Data.Metrology.SI+ Data.Metrology.SI.Mono+ Data.Metrology.SI.MonoTypes+ Data.Metrology.SI.Poly+ Data.Metrology.SI.PolyTypes+ Data.Metrology.Set+ Data.Metrology.Show+ Data.Metrology.TH+ Data.Metrology.Units+ Data.Metrology.Unsafe+ Data.Metrology.Validity+ Data.Metrology.Vector+ Data.Metrology.Z+ Data.Units.CGS+ Data.Units.SI+ Data.Units.SI.Parser+ Data.Units.SI.Prefixes+ Data.Units.US+ Data.Units.US.Avoirdupois+ Data.Units.US.Liquid+ Data.Units.US.Misc+ Data.Units.US.Survey+ Tests.Compile.CGS+ Tests.Compile.EvalType+ Tests.Compile.Lcsu+ Tests.Compile.MetrologySynonyms+ Tests.Compile.NoVector+ Tests.Compile.Physics+ Tests.Compile.Quantity+ Tests.Compile.Readme+ Tests.Compile.Simulator+ Tests.Compile.T23+ Tests.Compile.TH+ Tests.Compile.UnitParser+ Tests.Compile.UnitParser.Quoters+ Tests.Compile.Units+ Tests.Imperial+ Tests.LennardJones+ Tests.Linearity+ Tests.OffSystemAdd+ Tests.OffSystemCSU+ Tests.PhysicalConstants+ Tests.Show+ Tests.Travel+ Tests.Vector+