Bu gerçekten de noobish bir soru olabilir, ancak bu sorunu atlayamıyorum (sadece Haskell'i öğrenmeye başladığımdan). Ben alıyorum nedenBeklenen tür "Metin" ile eşleştirilemedi Gerçek tipi "[Char] '
<interactive>:108:19: error: * Couldn't match expected type `Text' with actual type `[Char]' * In the first argument of `Data.Text.replace', namely `"ofo"' In the expression: Data.Text.replace "ofo" "bar" "ofofo" In an equation for `it': it = Data.Text.replace "ofo" "bar" "ofofo" <interactive>:108:25: error: * Couldn't match expected type `Text' with actual type `[Char]' * In the second argument of `Data.Text.replace', namely `"bar"' In the expression: Data.Text.replace "ofo" "bar" "ofofo" In an equation for `it': it = Data.Text.replace "ofo" "bar" "ofofo" <interactive>:108:31: error: * Couldn't match expected type `Text' with actual type `[Char]' * In the third argument of `Data.Text.replace', namely `"ofofo"' In the expression: Data.Text.replace "ofo" "bar" "ofofo" In an equation for `it': it = Data.Text.replace "ofo" "bar" "ofofo"
Bilmiyorum: Ben str
ile bu ararsanız
module SomeTest where
import Data.Text
str = replace "ofo" "bar" "ofofo"
, alıyorum:
Ben basit bir kod bloğu var Bu hata ve nasıl geçilir.Text
[Char]
için bir eş anlamlı değil mi?
Hayır, 'Metin 'tamamen farklı bir türüdür. 'String' ise 'Char'' ile eşanlamlıdır. – melpomene
Ne yazık ki, Haskell karakter dizileri için çeşitli çakışan türleri vardır. Sizin durumunuzda, programınızın ilk satırı olarak '{- # LANGUAGE Aşırı Yüklenenİlerleme Sayısı - -}' nı derlemek, derlemesini sağlamalıdır. – stholzm
Teşekkürler, bu gerçekten işe yaradı. Lütfen bu yorumdan bir cevap verin ve kabul edeceğim. –