about summary refs log tree commit diff
path: root/users/grfn/xanthous/src/Xanthous/Data.hs
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2021-06-30T00·35-0400
committergrfn <grfn@gws.fyi>2021-07-06T18·32+0000
commitad8d38c64cc98e71059538ca10bd4b979cd2cf74 (patch)
tree451279170fd11727d405f65b876b341b189e638b /users/grfn/xanthous/src/Xanthous/Data.hs
parente62f578687a8ee81394d00a5775843bb0bd813a0 (diff)
fix(xanthous): Fix display of square/cubic units r/2684
Previously this'd display `5 m m³`, because it'd show the underlying
value then add the unit suffix on at the end

Change-Id: Idd240ddfebc212460f9fb529eff72732a5dafe2a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3241
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/grfn/xanthous/src/Xanthous/Data.hs')
-rw-r--r--users/grfn/xanthous/src/Xanthous/Data.hs8
1 files changed, 6 insertions, 2 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 <> "³"
+
 
 --------------------------------------------------------------------------------