I have this data type :
data Node a = Node
{ label :: a,
adjacent :: [(a,Int)] } deriving (Show, Eq)
data Network a = Graph [Node a] deriving (Show, Eq)
I have a function which turns a Graph to a list of nodes :
deGraph :: ([Node a] -> Network a) -> [Node a] -> [Node a]
deGraph _ x = x
for example :
Main> deGraph Graph [ ( Node 'a' [ ( 'b' , 3 ) , ( 'c' ,2 ) ] ) , ( Node 'b' [ ('c' , 3 ) ] ) , ( Node 'c' [] ) ]
[Node {label = 'a', adjacent = [('b',3),('c',2)]},Node {label = 'b', adjacent = [('c',3)]},Node {label = 'c', adjacent = []}]
But when I use the function inside a function like this :
func1 (Graph x) = deGraph (Graph x)
I get this error :
ERROR "./Network.hs":14 - Type error in application * Expression : deGraph (Graph x) Term : Graph x Type : Network b * Does not match : [Node a] -> Network a
Can you tell me how can I solve this problem?