[augeas-devel] [Augeas] #231: Set issue with recursive lens and indentation
Augeas
trac at fedorahosted.org
Thu Nov 17 10:35:37 UTC 2011
#231: Set issue with recursive lens and indentation
----------------------+-----------------------------------------------------
Reporter: raphink | Owner: lutter
Type: defect | Status: new
Priority: major | Milestone: next
Component: Augeas | Version: devel
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Old description:
> I've tried to build recursive lenses a few times, and always end up with
> weird situations involving some kind of failure to match labels.
>
> Here is a simple example:
>
> {{{
> module Malformed =
>
> let fix_kv (lns:lens) = [ key /[a-z]+/
> . ( (del /\./ "." . lns)
> | (del "=" "=" . store /[a-z]+/) ) ]
>
> let rec kv = fix_kv kv
>
> let lns = Util.indent . kv
>
> test lns get "foo.bar=baz" = { "foo" { "bar" = "baz" } }
>
> test lns put "foo.bar=baz" after
> set "foo/bar" "faz" = ?
> }}}
>
> The get test works, but the set test fails with:
> {{{
> malformed.aug:13.2-14.28:exception thrown in test
> malformed.aug:13.7-14.24:exception: Failed to match
> <<rec:{ /[a-z]+/ = /(([a-z]+))/ }>>
> with tree
> { "foo" }
> Lens: malformed.aug:9.12-.28:
> Error encountered at path
>
> Syntax error in lens definition
> Failed to load malformed.aug
> }}}
>
> When removing the Util.indent from lns, the lens works.
New description:
I've tried to build recursive lenses a few times, and always end up with
weird situations involving some kind of failure to match labels.
Here is a simple example:
{{{
module Malformed =
let fix_kv (lns:lens) = [ key /[a-z]+/
. ( (del /\./ "." . lns)
| (del "=" "=" . store /[a-z]+/) ) ]
let rec kv = fix_kv kv
let lns = Util.indent . kv
test lns get "foo.bar=baz" = { "foo" { "bar" = "baz" } }
test lns put "foo.bar=baz" after
set "foo/bar" "faz" = ?
}}}
The get test works, but the set test fails with:
{{{
malformed.aug:13.2-14.28:exception thrown in test
malformed.aug:13.7-14.24:exception: Failed to match
<<rec:{ /[a-z]+/ = /(([a-z]+))/ }>>
with tree
{ "foo" }
Lens: malformed.aug:9.12-.28:
Error encountered at path
Syntax error in lens definition
Failed to load malformed.aug
}}}
When removing the Util.indent from lns, the lens works:
{{{
Test result: malformed.aug:13.2-14.28:
"foo.bar=faz"
}}}
--
Ticket URL: <https://fedorahosted.org/augeas/ticket/231#comment:2>
Augeas <http://augeas.net/>
a configuration API
More information about the augeas-devel
mailing list