Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

haskell

yesod

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.

like image 335
akonsu Avatar asked Sep 21 '11 21:09

akonsu


1 Answers

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

like image 153
Thomas Avatar answered Oct 02 '22 15:10

Thomas