Zuletzt geändert: So, 23.04.2006

«K12/K13» Base.hs «PDF», «POD»



Download
{-# OPTIONS_GHC -fglasgow-exts -fallow-overlapping-instances #-}
module Base where

{-
class Memoizable a where
  memoize :: a -> a

instance Memoizable (Int -> b) where
  memoize f = ([f n | n <- [0..]] !!)

instance (Integral a) => Memoizable (a -> b) where
  memoize f = \n -> (memoize f') (fromIntegral n) where
    f' :: Int -> y
    f' m = f (fromIntegral m)

instance (Memoizable (a -> b), Memoizable (b -> c)) => Memoizable (a -> b -> c) where
  memoize f = \x y -> (memoize f) x y
-}