Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/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:  State Monad: how to use other Stateful computation on
      sub-state inside (martin)
   2.  ghci: inconsistent return values for succ (Frothy Bits)
   3. Re:  ghci: inconsistent return values for succ (Dan Stromberg)
   4. Re:  ghci: inconsistent return values for succ (Frothy Bits)
   5. Re:  ghci: inconsistent return values for succ
      (Kostiantyn Rybnikov)


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

Message: 1
Date: Sat, 17 Oct 2015 15:58:53 +0200
From: martin <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] State Monad: how to use other
        Stateful computation on sub-state inside
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252

Am 10/17/2015 um 10:01 AM schrieb martin:
> This is quite insightful. Now the problem presents itself as follows:
> 
> In fact I orginally started with plain itmAdd (the one you called itmAdd'') 
> which has no business with State or System.
> It is just Item->ItemDb -> ItemDb.
> 
> However, I wanted to use do-notation and made it monadic leading to item' :: 
> Item->State ItemDb ()
> 
> But then it becomes difficult to use it inside State System. Currently I am 
> using
> 
> subState :: (s1 -> s2) -> State s2 a -> State s1 s2
> subState accessor f   = do
>     s <- get
>     return $ execState f $ accessor s
> 
> to make the necessary transformation. I have the feeling that this way of 
> stacking things is a bit inside-out. And as
> you say, it only hides the ugliness. I will try to stack things bottom up.

This turned out okay. Thank you very much and many thanks to Karl Voelker too, 
though I am still shying away from lenses.



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

Message: 2
Date: Sat, 17 Oct 2015 19:17:04 -0700
From: Frothy Bits <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] ghci: inconsistent return values for succ
Message-ID:
        <cahpfchextedn4ur5svzbuvuyk2dnrdkvwxc8xejjocepdqs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Greetings,

Absolutely brand new to Haskell.  Taking ghci v7.10.2 out for a spin, and I
find I get inconsistent return values for succ n:

ghci> succ 3.14
4.1400000000000001

for example instead of the expected 4.14

succ 2.14 and 4.14 give the expected results. but succ 2.14 returns
2.1399999999999997.  This anomalous behavior runs through the range of
n.nn;  in the n.01 range, for example, 16.01 and 63.01 return wonky results
per above.

I tested this on Windows and Linux (various flavors) and I get the same
results there and in the interactive test code space on haskell.org.

I'm not familiar enough with the language, yet, to go debugging this on my
own, but it would seem to be at least a problem with how succ is
implemented, if not how values are handled in general.....which could
potentially be bad if you were trying to do anything requiring precise
calculations....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151017/7ae9d3da/attachment-0001.html>

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

Message: 3
Date: Sat, 17 Oct 2015 19:21:47 -0700
From: Dan Stromberg <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] ghci: inconsistent return values for
        succ
Message-ID:
        <caovkw54yzc8esj-fidxv6mmsytvt+x7roq27nzrnyp32q9d...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Sat, Oct 17, 2015 at 7:17 PM, Frothy Bits <[email protected]>
wrote:

> Greetings,
>
> Absolutely brand new to Haskell.  Taking ghci v7.10.2 out for a spin, and
> I find I get inconsistent return values for succ n:
>
> ghci> succ 3.14
> 4.1400000000000001
>
> for example instead of the expected 4.14
>

This is pretty standard for today's floating point hardware in CPU's.  It's
not a Haskell thing.  It comes up in C and Python too - that is, in pretty
much anything that uses hardware floating point.

If you need precision, try an integral type or a rational.

-- 
Dan Stromberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151017/50fad120/attachment-0001.html>

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

Message: 4
Date: Sat, 17 Oct 2015 19:48:38 -0700
From: Frothy Bits <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] ghci: inconsistent return values for
        succ
Message-ID:
        <CAHpfcHGDcucnDWfxggb7T9LRkkP=vdc6y3zqnajbhrpcm6w...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

@ Dan Stromberg:  Thanks, understood.

On Sat, Oct 17, 2015 at 7:17 PM, Frothy Bits <[email protected]>
wrote:

> Greetings,
>
> Absolutely brand new to Haskell.  Taking ghci v7.10.2 out for a spin, and
> I find I get inconsistent return values for succ n:
>
> ghci> succ 3.14
> 4.1400000000000001
>
> for example instead of the expected 4.14
>
> succ 2.14 and 4.14 give the expected results. but succ 2.14 returns
> 2.1399999999999997.  This anomalous behavior runs through the range of
> n.nn;  in the n.01 range, for example, 16.01 and 63.01 return wonky results
> per above.
>
> I tested this on Windows and Linux (various flavors) and I get the same
> results there and in the interactive test code space on haskell.org.
>
> I'm not familiar enough with the language, yet, to go debugging this on my
> own, but it would seem to be at least a problem with how succ is
> implemented, if not how values are handled in general.....which could
> potentially be bad if you were trying to do anything requiring precise
> calculations....
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151017/e3f2b161/attachment-0001.html>

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

Message: 5
Date: Sun, 18 Oct 2015 12:15:38 +0300
From: Kostiantyn Rybnikov <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] ghci: inconsistent return values for
        succ
Message-ID:
        <CAAbahfSUqL5yod1_PDmVax6qmc22PErs50C5-cwDz-Uim3C4=q...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

If you use Decimal package [0], you can have what you want:

? succ (3.14 :: Decimal)
4.14

[0]: https://hackage.haskell.org/package/Decimal

On Sun, Oct 18, 2015 at 5:17 AM, Frothy Bits <[email protected]>
wrote:

> Greetings,
>
> Absolutely brand new to Haskell.  Taking ghci v7.10.2 out for a spin, and
> I find I get inconsistent return values for succ n:
>
> ghci> succ 3.14
> 4.1400000000000001
>
> for example instead of the expected 4.14
>
> succ 2.14 and 4.14 give the expected results. but succ 2.14 returns
> 2.1399999999999997.  This anomalous behavior runs through the range of
> n.nn;  in the n.01 range, for example, 16.01 and 63.01 return wonky results
> per above.
>
> I tested this on Windows and Linux (various flavors) and I get the same
> results there and in the interactive test code space on haskell.org.
>
> I'm not familiar enough with the language, yet, to go debugging this on my
> own, but it would seem to be at least a problem with how succ is
> implemented, if not how values are handled in general.....which could
> potentially be bad if you were trying to do anything requiring precise
> calculations....
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151018/0a00f2f2/attachment-0001.html>

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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 88, Issue 14
*****************************************

Reply via email to