Category "sml"

Dfs to find visited nodes in sml

What is wrong with this part of code ? I'm trying to make a function which (given a graph) returns a list with all visited nodes, but the compiler keeps saying

foldl function in SML/NJ: Right-hand-side of clause doesn't agree with function result type

I have a function named dfs which produces a list of all visited nodes in a graph represented by a list of tuples such as [(node1,node2,weight),....] and I get