packages feed

KiCS-0.8.8: src/lib/Curry/Module/Float.hs.include

[ForFunction "prim_Float_plus"
,ForFunction "prim_Float_minus"
,ForFunction "prim_Float_times"
,ForFunction "prim_Float_divide"
,ForFunction "prim_Float_lt"
,ForFunction "prim_Float_gt"
,ForFunction "prim_Float_leq"
,ForFunction "prim_Float_geq"
,ForFunction "prim_i2f"
,ForFunction "prim_truncate"
,ForFunction "prim_round"
,ForFunction "prim_sqrt"
,ForFunction "prim_log"
,ForFunction "prim_exp"
,ForFunction "prim_sin"
,ForFunction "prim_cos"
,ForFunction "prim_tan"
]

instance Fractional C_Float where
  fromRational x = PrimValue (fromRational x)
  recip (PrimValue x) = PrimValue (recip x)

instance Floating C_Float where
  pi = PrimValue pi
  exp (PrimValue x) = PrimValue (exp x)
  log (PrimValue x) = PrimValue (log x)
  sin (PrimValue x) = PrimValue (sin x)
  cos (PrimValue x) = PrimValue (cos x)
  sinh (PrimValue x) = PrimValue (sinh x)
  cosh (PrimValue x) = PrimValue (cosh x)
  asin (PrimValue x) = PrimValue (asin x)
  acos (PrimValue x) = PrimValue (acos x)
  atan (PrimValue x) = PrimValue (atan x)
  asinh (PrimValue x) = PrimValue (asinh x)
  acosh (PrimValue x) = PrimValue (acosh x)
  atanh (PrimValue x) = PrimValue (atanh x)
  
instance RealFrac C_Float where
  properFraction (PrimValue x) = case properFraction x of (b,a) -> (b,PrimValue a)

prim_Float_plus :: C_Float -> C_Float -> Result C_Float
prim_Float_plus x y _ = x+y

prim_Float_minus :: C_Float -> C_Float -> Result C_Float
prim_Float_minus x y _ = x-y

prim_Float_times :: C_Float -> C_Float -> Result C_Float
prim_Float_times x y _ = x*y

prim_Float_divide :: C_Float -> C_Float -> Result C_Float
prim_Float_divide x y _ = x/y

prim_Float_lt :: C_Float -> C_Float -> Result C_Bool
prim_Float_lt x y _ = toCurry (x<y)

prim_Float_gt :: C_Float -> C_Float -> Result C_Bool
prim_Float_gt x y _ = toCurry (x>y)

prim_Float_leq :: C_Float -> C_Float -> Result C_Bool
prim_Float_leq x y _ = toCurry (x<=y)

prim_Float_geq :: C_Float -> C_Float -> Result C_Bool
prim_Float_geq x y _ = toCurry (x>=y)

prim_i2f :: C_Int -> Result C_Float
prim_i2f x _ = fromInteger (fromCurry x)

prim_truncate :: C_Float -> Result C_Int
prim_truncate x _ = toCurry (truncate x :: Integer)

prim_round :: C_Float  -> Result C_Int
prim_round x _ = toCurry (round x :: Integer)

prim_sqrt :: C_Float  -> Result C_Float
prim_sqrt x _ = sqrt x

prim_log :: C_Float   -> Result C_Float
prim_log x _ = log x

prim_exp :: C_Float   -> Result C_Float
prim_exp x _ = exp x

prim_sin :: C_Float   -> Result C_Float
prim_sin x _ = sin x

prim_cos :: C_Float   -> Result C_Float
prim_cos x _ = cos x

prim_tan :: C_Float   -> Result C_Float
prim_tan x _ = tan x

prim_atan :: C_Float   -> Result C_Float
prim_atan x _ = atan x