-- | Overloaded natural numbers. module Overloaded.Naturals ( FromNatural (..), ) where import Numeric.Natural (Natural) -- -- | Class for 'Natural'-like datastructures -- -- A numeric literal @42@ is desugared to -- -- @ -- 'fromNatural' 42 -- @ -- ---- Enabled with: -- -- @ -- {-\# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Naturals #-} -- @ -- class FromNatural a where fromNatural :: Natural -> a instance FromNatural Natural where fromNatural :: Natural -> Natural fromNatural = Natural -> Natural forall a. a -> a id instance FromNatural Integer where fromNatural :: Natural -> Integer fromNatural = Natural -> Integer forall a b. (Integral a, Num b) => a -> b fromIntegral