Just for the heck of it, I tried out an implementation of scanl using
Joachim Breitner's magical oneShot primitive. Using the test
scanlA :: (b - a - b) - b - [a] - [b]
scanlA f a bs = build $ \c n -
a `c`
foldr (\b g x - let b' = f x b in (b' `c` g b'))
(const n)
bs
Wait, isn't call arity analysis meant to do this by itself now?
On 7 October 2014 17:05, David Feuer david.fe...@gmail.com wrote:
Just for the heck of it, I tried out an implementation of scanl using
Joachim Breitner's magical oneShot primitive. Using the test
scanlA :: (b - a - b) - b - [a]
Yes, and it does a very good job in many cases. In other cases, it's
not as good.
On Tue, Oct 7, 2014 at 7:59 AM, Sophie Taylor sop...@traumapony.org wrote:
Wait, isn't call arity analysis meant to do this by itself now?
On 7 October 2014 17:05, David Feuer david.fe...@gmail.com wrote:
Just
On Sep 12, 2014 2:35 PM, Joachim Breitner m...@joachim-breitner.de
wrote:
I once experimented with a magic oneShot :: (a - b) - (a - b)
function, semantically the identity, but tell the compiler not to share
the result of the computation. Using that in the definition of
foldl-as-foldr, one can
Hi,
Am Mittwoch, den 24.09.2014, 16:37 -0400 schrieb David Feuer:
On Sep 12, 2014 2:35 PM, Joachim Breitner m...@joachim-breitner.de
wrote:
I once experimented with a magic oneShot :: (a - b) - (a - b)
function, semantically the identity, but tell the compiler not to
share
the result of
Joachim Breitner wrote:
Am Samstag, den 13.09.2014, 00:01 -0400 schrieb David Feuer:
On Sep 12, 2014 2:35 PM, Joachim Breitner m...@joachim-breitner.de
wrote:
Interesting. I assumed that some wrap.unwrap=id law would hold, or
at
least some moral approximation (e.g. disregarding
Which scanl wrapper are you referring to?
The first one I figured out was quite wrong in certain ways. But I think
the new one is less controversial; it's a lot like the reverse one.
On Sun, Sep 14, 2014 at 1:03 PM, David Feuer david.fe...@gmail.com wrote:
Joachim Breitner wrote:
Am Samstag,
Your scanl wrapper might be right for scanl, but it does not satisfy the
condition Joachim proposed. In particular, if we define
(!!) :: [a] - Int - a
xs !! n
| n 0 = error Negative index.
| otherwise = foldrW indexWrap indexCons (error Large index.) xs n
where
indexCons x _ 0 = x
Hi,
Am Sonntag, den 14.09.2014, 14:47 -0400 schrieb David Feuer:
Your scanl wrapper might be right for scanl, but it does not satisfy
the condition Joachim proposed. In particular, if we define
(!!) :: [a] - Int - a
xs !! n
| n 0 = error Negative index.
| otherwise = foldrW
Hi,
Am Samstag, den 13.09.2014, 00:01 -0400 schrieb David Feuer:
On Sep 12, 2014 2:35 PM, Joachim Breitner m...@joachim-breitner.de
wrote:
Interesting. I assumed that some wrap.unwrap=id law would hold, or
at
least some moral approximation (e.g. disregarding bottoms in an
acceptable
On Sep 12, 2014 2:35 PM, Joachim Breitner m...@joachim-breitner.de
wrote:
Interesting. I assumed that some wrap.unwrap=id law would hold, or at
least some moral approximation (e.g. disregarding bottoms in an
acceptable manner). But if the wrappers have to do arbitrary stuff that
can
11 matches
Mail list logo