diff --git a/chandlr.cabal b/chandlr.cabal index 4653b24..3fc33a4 100644 --- a/chandlr.cabal +++ b/chandlr.cabal @@ -67,6 +67,7 @@ executable chandlr Network.Http Common.Network.HttpTypes Network.Client + Common.Network.Units Common.Network.ClientTypes Common.Network.CatalogPostType Common.Network.BoardType diff --git a/src/Common b/src/Common index 5ca701e..0e5547e 160000 --- a/src/Common +++ b/src/Common @@ -1 +1 @@ -Subproject commit 5ca701e30861498565fd4927ea1c9ea3ea105b8c +Subproject commit 0e5547e7475679cd5a3a449b6f09f0f6d063244e diff --git a/src/Network/Units.hs b/src/Network/Units.hs deleted file mode 100644 index 7101206..0000000 --- a/src/Network/Units.hs +++ /dev/null @@ -1,19 +0,0 @@ -module Network.Units where - -import Text.Printf (printf) - -data Unit = KiB | MiB | GiB | TiB | PiB | EiB | ZiB | YiB - | KB | MB | GB | TB | PB | EB | ZB | YB - deriving (Enum, Show, Bounded) - -bytesToHumanReadable :: Integral a => a -> Bool -> String -bytesToHumanReadable bytes binaryPrefix = printf "%.2f %s" size (show unit) - where - (factor, units) = if binaryPrefix - then (1024.0, enumFrom KiB) -- Binary prefix, 1024 base, explicitly Double - else (1000.0, enumFrom KB) -- Decimal prefix, 1000 base, explicitly Double - (size, unit) = foldl (\(accSize, accUnit) u -> - if accSize < factor then (accSize, accUnit) - else (accSize / factor, u)) - (fromIntegral bytes :: Double, if binaryPrefix then KiB else KB) -- Explicitly Double - units