David,

Thanks for your query. Here's an example from Hinze and Jeuring's
paper<http://www.informatik.uni-bonn.de/%7Eralf/publications/TheWeb.ps.gz>,
the syntax is Haskell(ish), but it's also simple enough to transliterate to
Scala.

rhs = Abs "n" (If (App (App (Var "=") (Var "n")) (Var "0"))
                          (Var "1")
                          (App (App (Var "+") (Var "n"))
                               (App (Var "fac") (App (Var "pred") (Var
"n")))))

This is the body of a factorial calculation that has a typo in it. It should
have a (Var "*") where there is a (Var "+"). We'd like to navigate to that
location. Using a zipper our navigation would look like

> top rhs
Abs "n" (If (App ... ) )
> down $$
If (App (App ...) )
> down $$
App (App (Var ...) )
> right $$
Var "1"
> right $$
App (App (Var "+") (Var "n")) (App (Var "fac") ...)
> down $$
App (Var "+") (Var "n")
> down $$
Var "+"
> $${ it = (Var "*") }
Var "*"
> up $$
App (Var "*") (Var "n")

Let me know if this helps.

Best wishes,

--greg

On Sat, Jul 18, 2009 at 4:38 PM, David Pollak <feeder.of.the.be...@gmail.com
> wrote:

> Greg,
> This sounds interesting... but I'd like to see what the Scala code would
> look like that would manipulate the Zipper-based data structures.  If you've
> got a pile of XML, what does it look like to map it to nested [case]
> classes?  What does it look like to manipulate the XML?
>
> Thanks,
>
> David
>
>
> On Fri, Jul 17, 2009 at 10:54 AM, Meredith Gregory <
> lgreg.mered...@gmail.com> wrote:
>
>> Guys,
>>
>> After playing around with integrating Lift and Jersey before the Jersey
>> guys did an 'official' integration and thinking hard about how i wanted to
>> reference locations in data structures via URLs, i realized that 
>> zipper<http://en.wikipedia.org/wiki/Zipper_%28data_structure%29>(cf. this
>> explanation <http://www.haskell.org/haskellwiki/Zipper>) is a much
>> better, much more functional, generic and maintainable solution.
>>
>> Briefly, the way this works is to automate the calculation of a context
>> type, C(T), from a data type T. The context type will allow for the
>> representation of locations in an instance of T in terms of contexts and
>> holes. There's a natural way to get from contexts to paths. So, there's a
>> natural map from URLs (viewed as paths) to locations. One great example of
>> how this works in practice is Oleg Kiselyov's Zipper-based file system. The
>> analogy between paths to files and URLs to resources should be clear.
>>
>> This has led me to look at where to cut the line on calculating zippers.
>> As the wikipedia article mentions above, it is possible do this completely
>> generically, provided one has a notion of differentiation on data
>> structures; that is, the zipper can be expressed in terms of the derivative
>> of a data structure. There are two natural (and somewhat competing) places
>> to hang the differentiation calculation:
>>
>>    - the new collections library for scala
>>    - the target of a mapping from one of the XML schema proposals to
>>    scala types
>>
>> Jorge and i were chatting about this the other day. Either route is a bit
>> of a large task and i've got a bunch of other stuff on my plate right now.
>> However, i'd be very happy to collaborate with anyone who wants to make this
>> happen. Also, by the way, this works really well with a lot of other
>> monadically based machinery.
>>
>> Best wishes,
>>
>> --greg
>>
>>
>> On Fri, Jul 17, 2009 at 8:17 AM, TylerWeir <tyler.w...@gmail.com> wrote:
>>
>>>
>>> >>Wait a few days, and I think there'll be some very good news on this
>>> front.
>>>
>>> Tease! :)
>>>
>>> On Jul 17, 10:51 am, David Pollak <feeder.of.the.be...@gmail.com>
>>> wrote:
>>> > There are benefits to both approaches.  I prefer the partial function
>>> > composition, but annotations on Pojos have their place.
>>> > Wait a few days, and I think there'll be some very good news on this
>>> front.
>>> >
>>> > On Fri, Jul 17, 2009 at 7:28 AM, Timothy Perrett
>>> <timo...@getintheloop.eu>wrote:
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > Hey guys,
>>> >
>>> > > I've been taking a look at Jersey and how it operates with Lift by
>>> way
>>> > > of the recent integration that cropped up on dev.java.net...
>>> >
>>> > > From my perspective, I see how having a standard RS service framework
>>> > > could be helpful, but it appears to bypass important lift concepts
>>> > > like SiteMap etc so I'm just wondering what the benefit of using such
>>> > > a layer would be over using DispatchPF etc to create REST services or
>>> > > serving xml fragments for templates? (I have no idea about Jersey
>>> > > apart from the basic docs ive read, so if im missing a major benefit
>>> > > id love to hear discuss)
>>> >
>>> > > Cheers for any thoughts
>>> >
>>> > > Tim
>>> >
>>> > --
>>> > Lift, the simply functional web frameworkhttp://liftweb.net
>>> > Beginning Scalahttp://www.apress.com/book/view/1430219890
>>> > Follow me:http://twitter.com/dpp
>>> > Git some:http://github.com/dpp
>>> >>>
>>>
>>
>>
>> --
>> L.G. Meredith
>> Managing Partner
>> Biosimilarity LLC
>> 1219 NW 83rd St
>> Seattle, WA 98117
>>
>> +1 206.650.3740
>>
>> http://biosimilarity.blogspot.com
>>
>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>



-- 
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to