[Haskell-cafe] Combining applicative with arrows?

Nils Schweinsberg ml at n-sch.de
Fri Sep 10 04:34:04 EDT 2010


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? :)


- Nils

More information about the Haskell-Cafe mailing list