
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".
ArrowApply is one way, if there is an instance for it: module Main where import Control.Arrow adder :: (Arrow a) => Int -> a Int Int adder i = arr (i+) adderUser :: (ArrowApply a, Arrow a) => a Int Int adderUser = proc x -> do a <- arr adder -< x y <- app -< (a,x) returnA -< y main = mapM_ (print . (adderUser :: (->) Int Int)) [1..10] Claude -- http://claudiusmaximus.goto10.org