I am an Absolute Newbie to Haskell. But I really like it. I have been reading Learn You A Haskell and Real World Haskell and practicing along. I am on the Functionally Solving Problems section in the Learn You A Haskell book and I need someone to explain the following to me:
data Node = Node Road Road | EndNode Road
data Road = Road Int Node
Questions:
- Is this some recursive data type creation?
- Why Can't I do: Node "A" "B" and get a valid Node type? When I try something I can an error saying that Haskell can't match [Char] with Expected Road and I understand that. But I can't create a Node X Y without a Road Int Node. I thought Road was a type synonym for String but since it isn't declared it certainly is not. If anyone read the book and understood this thing PLEASE EXPLAIN WHAT THOSE DATA TYPES MEAN AND PROVIDE EXAMPLE IF POSSIBLE.