1
data Node = Blue | Green | Red
data Tree = Leaf Node | Node [Tree]
main = do
let a = Blue[Leaf Red]
print 1
それは私に次のエラー与える:ツリーデータは、Haskellでコンパイルされません
main.hs:5:15: error:
• Couldn't match expected type ‘[Tree] -> t’
with actual type ‘Node’
• The function ‘Blue’ is applied to one argument,
but its type ‘Node’ has none
In the expression: Blue [Leaf Red]
In an equation for ‘a’: a = Blue [Leaf Red]
• Relevant bindings include a :: t (bound at main.hs:5:11)
をそして、それはそれではなく、
第1のデータ宣言の「ノード」は、第2の宣言の「ノード」とは完全に無関係であることに注意してください。 1つは型名前空間にあり、2つ目は値名前空間にあります。 – Alec
どうすれば動作させることができますか? –
あなたがしようとしていることを説明しなければならないでしょう。なぜなら、 'Blue [Leaf Red]'はあなたがHaskell構文を何か他のものと混同しているからです。目標C、多分? – Carl