[Haskell-cafe] Beginners arrow question

Cale Gibbard cgibbard at gmail.com
Sat Apr 5 18:00:38 EDT 2008


On 05/04/2008, Paul Johnson <paul at cogito.org.uk> wrote:
>  myProblem :: (ArrowXml a) -> a XmlTree String
>  myProblem = proc xml do
>   name <- getAttrValue "name" -< xml
>   fmt <- arr lookupFormatter -< name
>   fmt -< xml
>

GHC has a special syntax for using ArrowApply (which HXT is an
instance of). Whenever the expression to the left of -< needs to
involve a local variable, you can replace -< with -<< and it should
work. To understand better what it means, you can read
http://www.haskell.org/ghc/docs/latest/html/users_guide/arrow-notation.html
-- it's basically just a shorthand for using 'app'.

>  myProblem :: (ArrowXml a) -> a XmlTree String
>  myProblem = proc xml do
>   name <- getAttrValue "name" -< xml
>   fmt <- arr lookupFormatter -< name
>   fmt -<< xml

Try that and see how it goes.

 - Cale


More information about the Haskell-Cafe mailing list