[Haskell-cafe] Beginners arrow question
Miguel Mitrofanov
miguelimo38 at yandex.ru
Sat Apr 5 14:19:24 EDT 2008
You can't use variables introduced in "proc" anywhere except on the
right side of "-<". OK, you actually can do this, but your arrow
should be an instance of ArrowApply (which means that you don't really
need it at all, since all such arrows are in fact monads). Your
"myProblem" is desugared as something like
arr (\xml -> (xml,xml)) >>> second (getAttrValue "name") >>> second
(arr (\name -> (name,name))) >>> second (second (arr lookupFormatter))
>>> arr (\(xml,(name,fmt)) -> xml) >>> fmt
On 5 Apr 2008, at 22:05, Paul Johnson wrote:
> I'm using arrows for the first time, with HXT. I think I'm getting
> the hang of it, but one problem has me stumped. I have a function
> "lookupFormatter" which takes a string and returns an arrow, and I
> want to use that arrow. Something like this:
>
> myProblem :: (ArrowXml a) -> a XmlTree String
> myProblem = proc xml do
> name <- getAttrValue "name" -< xml
> fmt <- arr lookupFormatter -< name
> fmt -< xml
>
> But I can't figure out how to do it. I get "fmt: not in scope".
>
> Can anyone help?
>
> Thanks,
>
> Paul.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list