Hello i was wondering how do you solve circular dependency in Haskell
I have :
Module for a type.
module Company where
import Tclass
data Worker=Worker{
age::Int,
name::String,
title::Title,
income::Int
}
data Title=Manager | Dev | Tester deriving (Show)
data Company=Company{
cname::String,
people::[Worker],
yf::Int
}
Module for the instance of the typeclass
module Tclass where
import System.Environment
import Company
class Console a where
wLine::a->IO()
rLine::IO String->a
instance Show Worker where
show w="to be defined"
print =putStr . show
If i just want to load the type in ghci and use it ; how do i import them without getting the error:
Module imports form a cycle:
module `Tclass' (.\Tclass.hs)
imports `Company' (Company.hs)
which imports `Tclass' (.\Tclass.hs)
P.S I have tried creating a auxiliary module that imports the two modules and the two modules would import it too,but no luck with this one either :
module Au where
import Tclass
import Company
module Company
import Au
module Tclass
import Au
import Tclass
and retry? – Olivier SohnTClass
inside theCompany
module i can not use instance ofShow
forWorker
type. – Bercovici Adrian