Hey,

I just wondered if you can define Applicative instances for arrows? Basicly what I thought of is:

I have a type for my arrow which is "CollectA" (using HXT here):

    type CollectA a = SomeArrow XmlTree a

And my datatype which I want to construct:

    data Test = Test
        { testString    :: String
        , testInt       :: Int
        }

With the functions:

    collectString :: CollectA String
    collectInt    :: CollectA Int

Now, what I currently do is something like:

    collectTest :: CollectA Test
    collectTest = getChildren
              >>> someOtherArrow  -- etc...
              >>> proc foo -> do
                  s <- collectString -< foo
                  i <- collectInt    -< foo
                  returnA -< Test s i

With Applicatives that proc-do-part would become:

    collectTest' :: CollectA Test
    collectTest' = ... -- arrow stuff
               >>> Test <$> collectString
                        <*> collectInt

Is something like this possible? I don't understand that "proc" part good enough to see what it's actually doing there, maybe someone with a better understanding for this could help out? :)


Thx,

- Nils
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to