diff options
-rw-r--r-- | users/grfn/xanthous/src/Xanthous/Data.hs | 8 | ||||
-rw-r--r-- | users/grfn/xanthous/test/Xanthous/DataSpec.hs | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/users/grfn/xanthous/src/Xanthous/Data.hs b/users/grfn/xanthous/src/Xanthous/Data.hs index 77b0f8f8be71..9b3c35c5457c 100644 --- a/users/grfn/xanthous/src/Xanthous/Data.hs +++ b/users/grfn/xanthous/src/Xanthous/Data.hs @@ -557,7 +557,6 @@ newtype Square a = Square a , Scalar ) via a - deriving Show via ShowUnitSuffix (Square a) a deriving via (a :: Type) instance ( Distribution d a , forall xx yy. Coercible xx yy => Coercible (d xx) (d yy) @@ -567,6 +566,9 @@ deriving via (a :: Type) instance Unit a => Unit (Square a) where unitSuffix = unitSuffix @a <> "²" +instance Show a => Show (Square a) where + show (Square n) = show n <> "²" + newtype Cubic a = Cubic a deriving stock (Eq, Generic) deriving anyclass (NFData, CoArbitrary, Function) @@ -574,7 +576,6 @@ newtype Cubic a = Cubic a , Scalar ) via a - deriving Show via ShowUnitSuffix (Cubic a) a deriving via (a :: Type) instance ( Distribution d a , forall xx yy. Coercible xx yy => Coercible (d xx) (d yy) @@ -584,6 +585,9 @@ deriving via (a :: Type) instance Unit a => Unit (Cubic a) where unitSuffix = unitSuffix @a <> "³" +instance Show a => Show (Cubic a) where + show (Cubic n) = show n <> "³" + -------------------------------------------------------------------------------- diff --git a/users/grfn/xanthous/test/Xanthous/DataSpec.hs b/users/grfn/xanthous/test/Xanthous/DataSpec.hs index 1aa250b1a4fe..9e67505ba928 100644 --- a/users/grfn/xanthous/test/Xanthous/DataSpec.hs +++ b/users/grfn/xanthous/test/Xanthous/DataSpec.hs @@ -99,8 +99,11 @@ test = testGroup "Xanthous.Data" , testGroup "units" [ testGroup "unit suffixes" [ testCase "density" - $ tshow (10000 :: Grams `Per` Cubic Meters) - @?= "10000.0 g/m³" + $ tshow (10000 :: Grams `Per` Cubic Meters) @?= "10000.0 g/m³" + , testCase "volume" + $ tshow (5 :: Cubic Meters) @?= "5.0 m³" + , testCase "area" + $ tshow (5 :: Square Meters) @?= "5.0 m²" ] ] ] |