Я пытаюсь создать собственный тип списка в haskell, но моя реализация содержит ошибки. Каков правильный способ сделать это приятно. Пожалуйста, объясните мне немного. Спасибо.Мой тип списка в haskell
Мой код: Код
data List a = EmptyList | ListElement a (List a)
instance (Show a) => Show (List a) where
show = showList'
showList' EmptyList = showString "[]"
showList' (ListElement a EmptyList) = show a
showList' (ListElement a b) = show a ++ show " " ++ showList' b
Ошибка:
[1 of 1] Compiling Main (tipusok.hs, interpreted)
tipusok.hs:12:39:
Couldn't match expected type `Prelude.String -> Prelude.String'
with actual type `[Char]'
Expected type: ShowS
Actual type: Prelude.String
In the return type of a call of `show'
In the expression: show a
Failed, modules loaded: none.
:) он работает, спасибо – flatronka