Mapping "()" to a leaf, and "(()())" to Leaf :*: Leafcan work, but you still have to deal with all strings, including "". That's the puzzle: you need to figure out a representation that handles every possible string.
If we only kept the parensToTree (treeToParens Tree) test case that would only show that treeToParens is a surjection, not a bijection. You need the other test to show it's a bijection.
You get the
Number
type, but not the constructor ( note that you do get the deconstructor ).No, you are not supposed to use the constructor. Not a kata issue.
I'm not sure I understand the issue here.
Mapping
"()"
to a leaf, and"(()())"
toLeaf :*: Leaf
can work, but you still have to deal with all strings, including""
. That's the puzzle: you need to figure out a representation that handles every possible string.If we only kept the
parensToTree (treeToParens Tree)
test case that would only show that treeToParens is a surjection, not a bijection. You need the other test to show it's a bijection.I tried using the constructor and ran into this, too.
You don't need the constructor, though.
The kata is solvable with just the provided imports, so I don't think this is an issue.