haskell - Type mismatch between FileInfo and Text -


i'm following this tutorial , got type mismatch error while creating function builds form.

i don't know import should post here, there's all:

import control.applicative import data.text (text, unpack) import qualified data.text t import qualified data.bytestring.lazy dbl import data.conduit import data.conduit.list (consume) import yesod import yesod.static import yesod.form.bootstrap3 import data.time (utctime, getcurrenttime) import control.monad.logger (runstdoutloggingt) import database.persist import database.persist.sqlite import system.filepath import system.directory (removefile, doesfileexist) 

and code:

data page = page  share [mkpersist sqlsettings, mkmigrate "migrateall"] [persistlowercase|     image         filename text         description textarea         date utctime         deriving show |]  instance yesod page type form = html -> mform handler (formresult a, widget)  uploadform :: form image uploadform = renderdivs $ image     <$> fileaformreq (bfs ("image" :: text)) -- error line     <*> areq textareafield (bfs ("description" :: text)) nothing     <*> lift (liftio getcurrenttime) 

couldn't match type fileinfo text
-- expected type: aform handler text
------ actual type: aform handler fileinfo …

i don't think there's, actually, error within yesod's wiki on github, guess it's in code of mine, couldn't figure out.

i'm sure yesod api has changed since example written.

the problem filename field image type filename, fileaformreq returns fileinfo (docs).

try changing definition of image to:

image     fileinfo fileinfo     description textarea     date utctime     deriving show 

a fileinfo value has structure (docs):

fileinfo        filename :: !text   filecontenttype :: !text   filesourceraw :: !(source (resourcet io) bytestring)   filemove :: !(filepath -> io ()) 

so use filename accessor @ file name of fileinfo.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -