Search code examples
haskellyesod

How to convert from lazy text to non-lazy text?


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.


Solution

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