38705


Haskellで以下のようなコード(ほぼhttps://wiki.haskell.org/99_questionsの11と10の丸写し)を書いたところ、1行目で  
`error: parse error on input '|'`  
と言われてしまいました。  
どなたか解決策をご教授ください

[code]

    ListItem a = Single a | Multiple Int a
        deriving (Show)
    
    enc :: Eq a => [a] -> [(Int, a)]
    enc [] = []
    enc li@(x:xs) = ((length $ filter (==x) li),x):(enc $ filter (/=x) xs)
    
    encodeModified :: Eq a => [a] -> [ListItem a]
    encodeModified = map encodeHelper . enc
      where
        encodeHelper (1,x) = Single x
        encodeHelper (n,x) = Multiple n x
    
        main = do
          print $ encodeModified "aaaaafheeeeeiiiiii"
    
[/code]


CC BY-SA 3.0
2017-10-14T17:21:52.573
38704
2017-10-16T00:58:57.440
2017-10-16T00:58:57.440
19110
24965
question
haskell
Haskellで謎のエラー: parse error on input '|'


先頭の`data`が欠けているためでは？

[code]

    data ListItem a = Single a | Multiple Int a
        deriving (Show)
    
[/code]


CC BY-SA 3.0
2017-10-14T17:59:34.590
38705
2017-10-15T08:11:59.730
2017-10-15T08:11:59.730
13199
13199
38704
answer