Is it necessary (helpful) to use 'rewrite'? Nearly every time I've tried
it, in the end 'transform' has been a better choice. Then you wouldn't need
the 'Just's at all, and it should work fine.
John
From: Lyndon Maydwell maydw...@gmail.com
(missed including cafe)
f :: [Modification] -
The fixpoint nature of rewrite catches some cases that transform might
not if I'm interpreting it correctly.
(Changes [Translate 1 1, Scale 1 1, Translate 1 1]) could be rewritten
as (Translate 2 2), but I'm not sure that it could be translated as
such if it matches against (Changes [Translate _
If I'm interpreting your code properly, it's not currently catching that
case anyway.
The problem is that you've got two sets of modifiers that both should be
optimized, explicit Modifier constructors in the Image, and a list contained
in Changes. Since 'Changes' is just a list of Modifiers, and
I was considering using a matrix optimisation but things are out of
control enough already :)
Converting all Changes constructors to nested regular constructors may
be the easiest approach. It would certainly eliminate the mess of list
manipulations.
On Tue, Jun 7, 2011 at 6:21 PM, John Lato
I'm writing an optimisation routine using Uniplate. Unfortunately, a
sub-function I'm writing is getting caught in an infinite loop because
it doesn't return Nothing when there are no optimisations left.
I'd like a way to move the last Just into f, but this makes recursion
very messy. I was
On Mon, 2011-06-06 at 23:38 +0800, Lyndon Maydwell wrote:
I'm writing an optimisation routine using Uniplate. Unfortunately, a
sub-function I'm writing is getting caught in an infinite loop because
it doesn't return Nothing when there are no optimisations left.
I'd like a way to move the
(missed including cafe)
f :: [Modification] - Maybe [Modification]
and
f _ = Just $ f ...
are incompatible
I managed to get the behaviour I'm after with the use of Either, but
this really is messy:
-- Sets of changes
o (Modifier (Changes []) i) = Just $ i
o (Modifier (Changes [c]) i) = Just $
On Tue, 2011-06-07 at 04:09 +0800, Lyndon Maydwell wrote:
(missed including cafe)
f :: [Modification] - Maybe [Modification]
and
f _ = Just $ f ...
are incompatible
My bad:
f ... = let cs' = (Rotate (x+x') : fromMaybe cs (f cs))
in fromMaybe cs (f cs)
Or refactoring it:
g l =
Thanks Maciej!
An additional Just was required in the refactored version of f:
f (Rotatex : Rotatex': cs) = Just $ g (Rotate (x+x') : g cs)
This is much cleaner than what I was doing.
On Tue, Jun 7, 2011 at 4:14 AM, Maciej Piechotka uzytkown...@gmail.com wrote:
On Tue,
Hi Lyndon
Are you just coalescing adjacent elements (if they are the same constructor)?
As it seems you have a list here rather than a tree, I'd step out of
Uniplate at this point and just do a list traversal with direct
recursion.
___
Haskell-Cafe
10 matches
Mail list logo