On 12/20/11, Paul Johnson <paul@cogito.org.uk> wrote:
You definitely don't need the type class, and you don't need instances.
I have removed the type class and instances.
I have placed the location function in MONKONMOVEUP and MONKONMOVEDOWN
Now I can at least access the functions and some of values. For example
MONKMEETSHIMSELF.timeu1
<interactive>:1:1: Not in scope: `MONKMEETSHIMSELF.timeu1'
MONKMEETSHIMSELF.timed1
TimeOfDay "timeu1"
Is there
any set of imports or exports that could make the modules work together in a consistent way?
Thanks,
Pat
-- *** MODULE 1
module MONKONMOVE where
data Monk = Monk String deriving (Eq,Show)
data TimeOfDay = TimeOfDay String deriving (Eq,Show)
data LocationOnPath = LocationOnPath String deriving (Eq,Show)
meets :: Monk -> Monk -> TimeOfDay -> TimeOfDay -> LocationOnPath -> LocationOnPath -> Bool
meets m1 m2 t1 t2 l1 l2 = if (not(m1 == m2) && (t1 == t2) && (l1 == l2))
then True
else False
-- *** MODULE 2
module MONKONMOVEUP where
import MONKONMOVE
monku :: Monk
monku = Monk "munku"
timeu1 :: TimeOfDay
timeu1 = TimeOfDay "timeu1"
timeu2 :: TimeOfDay
timeu2 = TimeOfDay "timeu2"
timeu3 :: TimeOfDay
timeu3 = TimeOfDay "timeu3"
locationu1 :: LocationOnPath
locationu1 = LocationOnPath "locationu1"
locationu2 :: LocationOnPath
locationu2 = LocationOnPath "locationu2"
locationu3 :: LocationOnPath
locationu3 = LocationOnPath "locationu3"
location :: Monk -> TimeOfDay -> LocationOnPath
location monku timeu1 = locationu1
location monku timeu2 = locationu2
location monku timeu3 = locationu3
-- *** MODULE 3
module MONKONMOVEDOWN where
import MONKONMOVE
monkd :: Monk
monkd = Monk "munkd"
timed1 :: TimeOfDay
timed1 = TimeOfDay "timed1"
timed2 :: TimeOfDay
timed2 = TimeOfDay "timed2"
timed3 :: TimeOfDay
timed3 = TimeOfDay "timeu3"
locationd1 :: LocationOnPath
locationd1 = LocationOnPath "locationd3"
locationd2 :: LocationOnPath
locationd2 = LocationOnPath "locationd2"
locationd3 :: LocationOnPath
locationd3 = LocationOnPath "locationd1"
location :: Monk -> TimeOfDay -> LocationOnPath
location monkd timed1 = locationd3
location monkd timed2 = locationd2
location monkd timed3 = locationd1
-- *** MODULE 4
module MONKMEETSHIMSELF where
import MONKONMOVEUP
import MONKONMOVEDOWN
-- There is one time and location in common
locationd2 = locationu2
timed2 = timeu2
-- The start of one journey is the end of the other and visa versa
locationd1 = locationu3
locationd3 = locationu1
timed1 = timeu1
timed3 = timeu3