On Fri, Nov 18, 2011 at 4:05 AM, Yves Parès wrote:
> (Sorry for the double mail)
> ...so there is no way to do that inside the function passed to modifySTRef?
> In other words, there is no way to ensure *inside* a function that its
> result will be evaluated strictly?
modifySTRef looks like thi
On 18 November 2011 13:17, Daniel Fischer
wrote:
> On Friday 18 November 2011, 13:05:06, Yves Parès wrote:
>> ...so there is no way to do that inside the function passed to
>> modifySTRef? In other words, there is no way to ensure inside a
>> function that its result will be evaluated strictly?
>
On Friday 18 November 2011, 13:05:06, Yves Parès wrote:
> ...so there is no way to do that inside the function passed to
> modifySTRef? In other words, there is no way to ensure inside a
> function that its result will be evaluated strictly?
Well,
modifySTRef ref fun = do
val <- readSTRef ref
(Sorry for the double mail)
...so there is no way to do that inside the function passed to modifySTRef?
In other words, there is no way to ensure *inside* a function that its
result will be evaluated strictly?
2011/11/18 Daniel Fischer
> On Friday 18 November 2011, 11:18:33, Yves Parès wrote:
>
Okay, thanks
I was pretty sure I was wrong (or else somebody would already have come up
with that solution), but I wanted to know why.
2011/11/18 Daniel Fischer
> On Friday 18 November 2011, 11:18:33, Yves Parès wrote:
> > Instead of rewriting modifySTRef, why not just do :
> >
> > modifySTRef
On Friday 18 November 2011, 11:18:33, Yves Parès wrote:
> Instead of rewriting modifySTRef, why not just do :
>
> modifySTRef counter (\x -> let y = x+1 in y `seq` y)
>
> Is there a problem with that?
Yes, y `seq` y is precisely the same as y.
a `seq` b means whenever evaluation of b is demande
Instead of rewriting modifySTRef, why not just do :
modifySTRef counter (\x -> let y = x+1 in y `seq` y)
Is there a problem with that?
2011/11/16 Johan Tibell
> On Wed, Nov 16, 2011 at 11:58 AM, Jason Dusek wrote:
>
>> diff --git a/Rebuild.hs b/Rebuild.hs
>> @@ -15,6 +15,7 @@ import Data.STRe
2011/11/16 Tristan Ravitch :
> Have you tried building the vector using things besides
> write/ST? It might be a bit faster to use something like
> Vector.unfoldr or Vector.generateM and ByteString.index to
> build up a pure Vector. After that you could use
> Vector.unsafeThaw to convert that pure
2011/11/16 Johan Tibell :
> On Wed, Nov 16, 2011 at 2:23 PM, Jason Dusek wrote:
>> Tried a modifySTRef' defined this way:
>>
>> modifySTRef' ref f = do
>> val <- (f $!!) <$> readSTRef ref
>> writeSTRef ref (val `seq` val)
>>
>> ...but there was no change in memo
On Wed, Nov 16, 2011 at 2:23 PM, Jason Dusek wrote:
> > Just double checked. modifySTRef is too lazy:
> > -- |Mutate the contents of an 'STRef'
> > modifySTRef :: STRef s a -> (a -> a) -> ST s ()
> > modifySTRef ref f = writeSTRef ref . f =<< readSTRef ref
> > We need Data.STRef.Strict
>
> Tried
2011/11/16 Johan Tibell :
> On Wed, Nov 16, 2011 at 12:07 PM, Johan Tibell wrote:
>> +! doesn't work unless modifySTRef is already strict in the result of the
>> function application. You need to write modifySTRef' that seq:s the result
>> of the function application before calling writeSTRef.
>
>
On Wednesday 16 November 2011, 22:45:16, Johan Tibell wrote:
> On Wed, Nov 16, 2011 at 12:33 PM, Antoine Latter
wrote:
> > We already have one in base - it re-exports Data.STRef in whole :-)
> >
> >
> > http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-STRef-
> > Strict.html
>
>
On Wed, Nov 16, 2011 at 12:33 PM, Antoine Latter wrote:
> We already have one in base - it re-exports Data.STRef in whole :-)
>
>
> http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-STRef-Strict.html
Then it's wrong. :( In what sense is it strict? I think it should be strict
in th
I ran into a similar problem with modifySTRef causing allocation and
GC. Creating my own strict version of modifySTRef got rid of all that
and my program ran without any allocation at all.
On Nov 16, 3:16 pm, Johan Tibell wrote:
> On Wed, Nov 16, 2011 at 12:07 PM, Johan Tibell wrote:
>
>
>
>
>
>
On Wed, Nov 16, 2011 at 2:16 PM, Johan Tibell wrote:
> On Wed, Nov 16, 2011 at 12:07 PM, Johan Tibell
> wrote:
>>
>> On Wed, Nov 16, 2011 at 11:58 AM, Jason Dusek
>> wrote:
>>>
>>> diff --git a/Rebuild.hs b/Rebuild.hs
>>> @@ -15,6 +15,7 @@ import Data.STRef
>>> import Data.String
>>> import Da
On Wed, Nov 16, 2011 at 12:16:34PM -0800, Johan Tibell wrote:
> Just double checked. modifySTRef is too lazy:
>
> -- |Mutate the contents of an 'STRef'
> modifySTRef :: STRef s a -> (a -> a) -> ST s ()
> modifySTRef ref f = writeSTRef ref . f =<< readSTRef ref
>
> We need Data.STRef.Strict
That wo
On Wed, Nov 16, 2011 at 12:07 PM, Johan Tibell wrote:
> On Wed, Nov 16, 2011 at 11:58 AM, Jason Dusek wrote:
>
>> diff --git a/Rebuild.hs b/Rebuild.hs
>> @@ -15,6 +15,7 @@ import Data.STRef
>> import Data.String
>> import Data.Word
>>
>> +import Control.DeepSeq
>> import Data.Vector.Unboxed (Ve
On Wed, Nov 16, 2011 at 07:58:51PM +, Jason Dusek wrote:
> 2011/11/15 Johan Tibell :
> > On Tue, Nov 15, 2011 at 12:08 PM, Jason Dusek wrote:
> >> Should I be annotating my functions with strictness, for the
> >> vector reference, for example? Should I be using STUArrays,
> >> instead?
> >
> >
On Wed, Nov 16, 2011 at 11:58 AM, Jason Dusek wrote:
> diff --git a/Rebuild.hs b/Rebuild.hs
> @@ -15,6 +15,7 @@ import Data.STRef
> import Data.String
> import Data.Word
>
> +import Control.DeepSeq
> import Data.Vector.Unboxed (Vector)
> import qualified Data.Vector.Unboxed as Vector (create,
2011/11/15 Johan Tibell :
> On Tue, Nov 15, 2011 at 12:08 PM, Jason Dusek wrote:
>> Should I be annotating my functions with strictness, for the
>> vector reference, for example? Should I be using STUArrays,
>> instead?
>
> From
> http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.4.1.0/
2011/11/15 Roman Cheplyaka :
> * Jason Dusek [2011-11-15 20:08:48+]
>> I'm having some trouble with memory usage in rebuilding a
>> ByteString with some sequences escaped. I thought I'd try
>> vectors. However, it seems that even a relatively simple
>> function, one that places all the bytes o
Hi Jason,
On Tue, Nov 15, 2011 at 12:08 PM, Jason Dusek wrote:
> Should I be annotating my functions with strictness, for the
> vector reference, for example? Should I be using STUArrays,
> instead?
>
From
http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.4.1.0/Control-Monad-ST-Safe.
* Jason Dusek [2011-11-15 20:08:48+]
> I'm having some trouble with memory usage in rebuilding a
> ByteString with some sequences escaped. I thought I'd try
> vectors. However, it seems that even a relatively simple
> function, one that places all the bytes of a ByteString in to a
> vector, us
Hi All,
I'm having some trouble with memory usage in rebuilding a
ByteString with some sequences escaped. I thought I'd try
vectors. However, it seems that even a relatively simple
function, one that places all the bytes of a ByteString in to a
vector, uses a great deal of memory.
I've pulled thi
24 matches
Mail list logo