I've defined a function called findPaths
in a Haskell Module called BinaryTree and I am trying to call that function in the main module I've created. The type of the function call is
findPaths :: Tree -> [Path]
Where Tree
is a data type defined as:
data Tree = Leaf | Node Tree Tree
and Path
is defined as:
data Path = LeftTurn Path | RightTurn Path | This
In the main function I'm doing this and only this:
module Main where
import BinaryTree
findPaths (Node Leaf Leaf)
But when I try and compile this with the following command:
ghc -o --make Main Main.hs BinaryTree.hs
I get this error:
Couldn't match expected type `Language.Haskell.TH.Syntax.Q [Language.Haskell.TH.Syntax.Dec]' against inferred type `[Path]' In the expression: findPaths (Node Leaf Leaf)
I get the same error if I try to export the data types in the BinaryTree module:
module BinaryTree (Tree(..), Path(..), allPaths) where...
I'm at a loss... I don't know what I'm doing wrong. Suggestions, no matter how straight forward and obvious are greatly welcome. Thank you.
UPDATE
Thank you, all of you, for your help.
@Travis Aside from what everyone suggested I ended up doing this last night before I read your message:
import BinaryTree
main = do
print (findPaths (Node Leaf Leaf))
It works the way I expected it to. But in the future, I'll make sure I follow the proper semantics you referenced me.
UPDATE 2
I had responded last night with some other answers but apparently there was a power outage and 4 hours worth of answers and questions were lost. Thought maybe I had dreamt answering those questions. Good to know I'm not crazy.