Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  ACID-state - how does it evaluate data (Antoine Latter)
   2. Re:  Netwire fromRational (Ertugrul S?ylemez)


----------------------------------------------------------------------

Message: 1
Date: Thu, 4 Oct 2012 12:38:19 -0500
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] ACID-state - how does it evaluate
        data
To: Konrad Szyc <[email protected]>
Cc: [email protected]
Message-ID:
        <CAKjSnQEPx2pqS0e1RijE_yJGuT2Krkz1bJOMa8D=qztqrm+...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

On Thu, Oct 4, 2012 at 3:06 AM, Konrad Szyc <[email protected]> wrote:
> Dear Haskell-Beginners
>
> I have a problem understanding how ACID-state stores its data. To be
> more specific, I would like to know how does it deal with lazy
> evaluation. I suppose it tries to "strictly" evaluate functions before
> serializing, but then how does it handle infinitely-recursive
> structures?
>

The acid-state library uses the safecopy library to perform
serialization and deserialization:

http://hackage.haskell.org/package/safecopy

The safecopy library has template-haskell functions to write
serializers and de-serializers for your types for you, however you may
hand-write them if you desire.

The auto-generated serialization code will fully-evaluate their
arguments, and I have no idea what they would do if a type had cycles
in it.

In order to write code to be aware of laziness and cycles you would
need to use some very low-level hooks in GHC (or whichever compiler
you are using) and put that knowledge into your hand-written
serializer and deserializer for your type.

So the short answer is "No".

Antoine



------------------------------

Message: 2
Date: Thu, 4 Oct 2012 03:19:17 +0200
From: Ertugrul S?ylemez <[email protected]>
Subject: Re: [Haskell-beginners] Netwire fromRational
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

Nathan H?sken <[email protected]> wrote:

> Let me simplify the example:
>
> testW1 :: WireP () Double
> testW1 = pure 1.0
>
> testW2 :: WireP () Double
> testW2 = 1.0
>
> main = do
>   let (res, _) = stepWire 1.0 () testW
>   putStrLn $ show res
>
> (set testW to testW1 or testW2).
> When I test this with testW=testW2 I see that "fromRational" is called
> which converts a Rational (=Ration Integer) to a WireP () Double (I
> tested this by adding a "trace" to the fromRational
> Control/Wire/Classes.hs).
> This means the "1.0" is converted to a Rational and then back to a
> WireP () Double, correct?

That's incorrect.  There is absolutely no difference between the two
except perhaps some RULE pragmas might apply.  Let me elaborate.  For
Wire the 'fromRational' function is defined like this:

    fromRational = pure . fromRational

Then the following holds:

    -- Using Double's Fractional instance:
    pure 1.0 = pure (fromRational (1 % 1))

    -- Using Wire's Fractional instance:
    1.0 = (pure . fromRational) (1 % 1)
        = pure (fromRational (1 % 1))


Greets,
Ertugrul

-- 
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20121004/04afb9a9/attachment-0001.pgp>

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 52, Issue 6
****************************************

Reply via email to