[Haskell-cafe] Arrows and 'do' syntax

Anatoly Zaretsky anatoly.zaretsky at gmail.com
Wed Jul 12 07:11:20 EDT 2006


On 7/12/06, Greg Fitzgerald <garious at gmail.com> wrote:
> I'm trying to translate this HXT code to use the Arrow 'do' syntax:
> readWriteDoc :: String -> IOSLA (XIOState s) b Int
> readWriteDoc path = readDocument [(a_validate, "0")] path
>                   >>> writeDocument [(a_output_encoding, isoLatin1)] "-"
>                   >>> getErrStatus
>
> This attempt fails to compile:
> readWriteDoc :: String -> IOSLA (XIOState s) b Int
>  readWriteDoc = proc path -> do
>    doc       <- readDocument [(a_validate, "0")]                   -< path
>    result    <- writeDocument [(a_output_encoding, isoLatin1)] "-" -< doc
>    getErrStatus -< result

Hi, Greg.

Looks like readWriteDoc is not an arrow but a function from strings to
arrows. So 'path' is just an argument, not arrow input. Maybe this
should work:

readWriteDoc :: String -> IOSLA (XIOState s) b Int
readWriteDoc path = proc input -> do
   doc       <- readDocument [(a_validate, "0")] path -< input
   result    <- writeDocument [(a_output_encoding, isoLatin1)] "-" -< doc
   getErrStatus -< result

--
Tolik


More information about the Haskell-Cafe mailing list