import Term import Ai data Indexed a = Indexed (Int -> a) instance Functor Indexed where fmap f (Indexed ixf) = Indexed (f . ixf) -- Arbitrary show that represents the Indexed type as a list. instance Show a => Show (Indexed a) where show (Indexed ixf) = show $ map ixf [0..3] -- Term compiler -- compile :: Indexed (Term a) -> String -- compile (Indexed ixf) = show $ ixf $ var "a[i]" i0 :: Indexed Float i0 = Indexed (\n -> [0..] !! n) i1 = fmap sin i0 t0 :: Indexed (Term Float) t0 = Indexed (\n -> var ("a[" ++ show n ++ "]")) t1 = fmap sin t0