
It's sometimes difficult to figure out a good choice when you're searching for a new feature/library (when you go beyond safety of the HP). I'm looking for a generic zipper to (hopefully) navigate over an AST… so a hetrogeneous structure. It's probably sufficient to make this traversable in a fixed way, but a zipper seemed like a good idea. Google says there are lots of options (various papers and their related implementations etc). I see a generic zipper in an 'syz' package that is based on generics, which looks like a nice choice as it's now easy to add the extension for deriving generics on ADTs. However, that package looks pretty old and unmaintained. Does anyone have any suggestions/advice? Cheers -- Luke

* Luke Evans
It's sometimes difficult to figure out a good choice when you're searching for a new feature/library (when you go beyond safety of the HP). I'm looking for a generic zipper to (hopefully) navigate over an AST… so a hetrogeneous structure.
It's probably sufficient to make this traversable in a fixed way, but a zipper seemed like a good idea. Google says there are lots of options (various papers and their related implementations etc).
I see a generic zipper in an 'syz' package that is based on generics, which looks like a nice choice as it's now easy to add the extension for deriving generics on ADTs. However, that package looks pretty old and unmaintained.
Does anyone have any suggestions/advice?
I plan to add an syz-like zipper to traverse-with-class[1] soon. The main advantage is that it'll let you to specify, via GTraversable instances, at which nodes it should "stop" and which nodes it should "skip". [1]: http://hackage.haskell.org/package/traverse-with-class For example, when you navigate around a list with syz, it'll "stop" at (:) and [] nodes, apart from the actual list elements, which may or may not be what you want. Apart from that, I am not aware of any problems with syz. Roman

Hmm, in my naivety I failed to notice that the 'official' GHC.Generics are completely different to SYB on which syz is built. Classic case of reading the same words/names and assuming they're exactly the same thing.
Maybe it's not that hard to rewrite syz in terms of GHC.Generics.Generic (I'll perhaps take a look), but maybe there's a generic Zipper library already based on the GHC stuff?
On 2013-04-10, at 3:19 PM, Roman Cheplyaka
...Apart from that, I am not aware of any problems with syz.
Roman

Note that syz is essentially based on Data.Data, which is no less
"official" than GHC.Generics. (The compiler can derive Data with
-XDeriveDataTypeable.)
I am not sure what your primary concern is. In case you are concerned
with the ease of deriving generic instances, almost every generics
library out there, including traverse-with-class, provides a TH function
for deriving the necessary instances.
You can write a zipper based on GHC.Generics, but it won't be a
straightforward translation of syz (nor would it be a trivial
undertaking).
Roman
* Luke Evans
Hmm, in my naivety I failed to notice that the 'official' GHC.Generics are completely different to SYB on which syz is built. Classic case of reading the same words/names and assuming they're exactly the same thing.
Maybe it's not that hard to rewrite syz in terms of GHC.Generics.Generic (I'll perhaps take a look), but maybe there's a generic Zipper library already based on the GHC stuff?
On 2013-04-10, at 3:19 PM, Roman Cheplyaka
wrote: ...Apart from that, I am not aware of any problems with syz.
Roman

Thanks Roman.
I'll probably go with Data.Data then. Certainly, I'm not looking for any significant distractions and I'll heed your cautionary note.
I read that GHC.Generics is fit and fast in comparison to SYB, but that's not really a big concern for me at the moment.
I just fell in to believing that GHC.Generics was the true religion given its apparent status as the adopted generics in GHC.
On 2013-04-10, at 11:24 PM, Roman Cheplyaka
Note that syz is essentially based on Data.Data, which is no less "official" than GHC.Generics. (The compiler can derive Data with -XDeriveDataTypeable.)
You can write a zipper based on GHC.Generics, but it won't be a straightforward translation of syz (nor would it be a trivial undertaking).
Roman

Hi Luke,
Even though you might have made up your mind already, here's some more
info. If you want a
zipper that does not use Typeable (and thus runtime type comparison and
casting, which are
potentially inefficient), you can use the zipper in Multirec [1].
Creating a zipper based on GHC.Generics should be easy taking the zipper
based on
instant-generics [2], or you can just use Sean Leather's rendering [3].
Cheers,
Pedro
[1] http://hackage.haskell.org/package/multirec
[2] http://hackage.haskell.org/package/instant-zipper
[3] https://github.com/spl/generic-deriving-extras
On Thu, Apr 11, 2013 at 8:44 AM, Luke Evans
Thanks Roman.
I'll probably go with Data.Data then. Certainly, I'm not looking for any significant distractions and I'll heed your cautionary note. I read that GHC.Generics is fit and fast in comparison to SYB, but that's not really a big concern for me at the moment. I just fell in to believing that GHC.Generics was the true religion given its apparent status as the adopted generics in GHC.
On 2013-04-10, at 11:24 PM, Roman Cheplyaka
wrote: Note that syz is essentially based on Data.Data, which is no less "official" than GHC.Generics. (The compiler can derive Data with -XDeriveDataTypeable.)
You can write a zipper based on GHC.Generics, but it won't be a straightforward translation of syz (nor would it be a trivial undertaking).
Roman
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
José Pedro Magalhães
-
Luke Evans
-
Roman Cheplyaka