On Sun, Jan 27, 2013 at 12:20:25AM +, Roman Cheplyaka wrote:
Very nice! This can be generalized to arbitrary arrows:
{-# LANGUAGE ExistentialQuantification #-}
import Prelude hiding (id)
import Control.Arrow
import Control.Applicative
import Control.Category
data F
Patrick Bahr does something very similar in Modular Tree Automata [1],
also noting the relation to attribute grammars. It's implemented in the
compdata package [2].
[1] Patrick Bahr, Modular Tree Automata (MPC 2012),
http://dx.doi.org/10.1007/978-3-642-31113-0_14
[2]
Hi Chris,
thanks for insightful links. At the first glance, I think the main
difference is that machines and iteratees process streams of data, while
catamorphisms work on general recursive data structures. (I used count +
sum in the example, which could lead to the impression that it's list
Roman, this is interesting. Is this arrow generalization in some library
already? And does it have a name?
Best regards,
Petr Pudlak
2013/1/27 Roman Cheplyaka r...@ro-che.info
* Petr P petr@gmail.com [2013-01-26 23:03:51+0100]
Dear Haskellers,
I read some stuff about attribute
You have applied the so-called banana-split theorem, as described e.g. in
http://www.cs.ox.ac.uk/jeremy.gibbons/publications/acmmpc-calcfp.pdf
Indeed you are right in noticing the correspondence between AG's and
catamorphims; actually I see AG's as a domain specific language for
constructing
Dear Haskellers,
I read some stuff about attribute grammars recently [1] and how UUAGC [2]
can be used for code generation. I felt like this should be possible inside
Haskell too so I did some experiments and I realized that indeed
catamorphisms can be represented in such a way that they can be
* Petr P petr@gmail.com [2013-01-26 23:03:51+0100]
Dear Haskellers,
I read some stuff about attribute grammars recently [1] and how UUAGC [2]
can be used for code generation. I felt like this should be possible inside
Haskell too so I did some experiments and I realized that indeed
Hi Petr,
Congratulations -- you've just implemented a Moore machine! [1]
I posted something very much like this just last year [2]. It's a very
common pattern in Haskell, forming the basis of coroutines and
iteratees and many other things.
Edward Kmett includes it in his machines package [3].
Hi Chris,
While the two things solve similar problems and have other similarities,
they are still quite different.
It's hard to call Petr's type a machine — there's no dynamics in it. It's
just a pair of an f-algebra and finalizer. Values of your type return
themselves — it is exactly this