-- https://bitemyapp.com/blog/instance-local-fundeps/
{-# LANGUAGE TypeFamilies, FlexibleInstances #-}
data Bytes =
    B
  | KB
  | MB
instance (b ~ Double) => Num (Bytes -> b) where
  fromInteger i B =
    fromInteger i
  fromInteger i KB =
    fromInteger $ i * 1024
  fromInteger i MB =
    fromInteger $ i * 1024 * 1024
instance (b ~ Double) => Fractional (Bytes -> b) where
  fromRational r B =
    fromRational r
  fromRational r KB =
    fromRational $ r * 1024
  fromRational r MB =
    fromRational $ r * 1024 * 1024
main = print $ 100 KB