netlib-ffi-0.0: src/Numeric/Netlib/Class.hs
module Numeric.Netlib.Class where
import Foreign.Storable (Storable)
import Data.Functor.Compose (Compose(Compose, getCompose))
import Data.Complex (Complex)
import Prelude (Float, Double, ($))
class (Storable a) => Real a where
switchReal :: f Float -> f Double -> f a
instance Real Float where switchReal f _ = f
instance Real Double where switchReal _ f = f
class Floating a where
switchFloating ::
f Float -> f Double ->
f (Complex Float) -> f (Complex Double) -> f a
instance Floating Float where switchFloating f _ _ _ = f
instance Floating Double where switchFloating _ f _ _ = f
instance (Real a) => Floating (Complex a) where
switchFloating _ _ fz fc = getCompose $ switchReal (Compose fz) (Compose fc)