+{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE FlexibleInstances #-}
module RealFunction (
RealFunction,
cmult,
- fexp
- )
+ fexp )
where
-
+-- Presumably this is faster without a newtype wrapper, and that's why
+-- we're about to define a bunch of orphan instances below. Note the
+-- GHC pragma thingy at the top of this file to ignore those warnings.
type RealFunction a = (a -> Double)
--
fexp :: (RealFunction a) -> Int -> (RealFunction a)
fexp f n
- | n == 0 = (\_ -> 1)
+ | n == 0 = const 1
| otherwise = \x -> (f x)^n