30

I am new to Haskell, so this may be a trivial problem. I am seeing an error message that says

Couldn't match expected type 'Data.Text.Lazy.Internal.Text'
with actual type 'Data.Text.Internal.Text'

and I think the problem is that the actual type is Data.Text.Text and it expects lazy text. How can I convert one to the other?

EDIT:

here is a simplified code that gives this error.

{-# LANGUAGE OverloadedStrings #-}
import Data.Text.Lazy.Encoding import Network.Mail.Mime import Yesod
data FormData = FormData { dataField :: Textarea } deriving Show
part d = Part { partType = "text/plain; charset=utf-8" , partEncoding = None , partFilename = Nothing , partContent = encodeUtf8 $ unTextarea $ dataField d , partHeaders = [] }
main = return ()
basically I have a yesod form with a textarea input element and I want to e-mail the contents of the textarea.

akonsu
  • 28,824
  • 33
  • 119
  • 194

1 Answers1

32

toStrict from Data.Text.Lazy would do what you ask for (convert lazy to strict).

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
Thomas
  • 174,939
  • 50
  • 355
  • 478
  • 18
    From the error message, it sounds like he actually needs `fromStrict`. Also note that while the docs show it as `Text -> Text`, if you try clicking them you'll see that they are actually different types from different modules. – hammar Sep 21 '11 at 21:21
  • i have hopefully clarified my problem – akonsu Sep 21 '11 at 22:15