Commit 27f75527 authored by Geoffrey Mainland's avatar Geoffrey Mainland

Make Applicative-Monad fixes for tests.

parent 710bc8d7
{-# LANGUAGE ScopedTypeVariables, DatatypeContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
......@@ -151,7 +151,7 @@ instance Show (a -> b) where { show _ = "<FN>" }
------------------------------------------------------------------------------
data (Ix a) => Array a b = MkArray (a,a) (a -> b) deriving ()
data Array a b = MkArray (a,a) (a -> b) deriving ()
array :: (Ix a) => (a,a) -> [(a,b)] -> Array a b
array b ivs =
......@@ -259,6 +259,10 @@ generate n rnd (Gen m) = m size rnd'
instance Functor Gen where
fmap f m = m >>= return . f
instance Applicative Gen where
pure = return
(<*>) = liftM2 id
instance Monad Gen where
return a = Gen (\n r -> a)
Gen m >>= k =
......@@ -508,4 +512,4 @@ instance Observable StdGen where { observer = observeBase }
instance Observable a => Observable (Gen a) where
observer (Gen a) = send "Gen" (return (Gen) << a)
-}
\ No newline at end of file
-}
......@@ -361,7 +361,7 @@ cloneMArraySlow !marr !off n =
-- Utilities for simplifying RNG passing
newtype Rng s a = Rng { unRng :: StateT StdGen (ST s) a }
deriving Monad
deriving (Functor, Applicative, Monad)
-- Same as 'randomR', but using the RNG state kept in the 'Rng' monad.
rnd :: Random a => (a, a) -> Rng s a
......
......@@ -361,7 +361,7 @@ cloneMArraySlow !marr !off n =
-- Utilities for simplifying RNG passing
newtype Rng s a = Rng { unRng :: StateT StdGen (ST s) a }
deriving Monad
deriving (Functor, Applicative, Monad)
-- Same as 'randomR', but using the RNG state kept in the 'Rng' monad.
rnd :: Random a => (a, a) -> Rng s a
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment