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. wxHaskell programm segfaults when copying shared object
files into same directory (Nathan H?sken)
2. truncate results depend on strict/lazy (Bryan Vicknair)
3. Re: truncate results depend on strict/lazy (Mihai Maruseac)
4. Re: truncate results depend on strict/lazy (Chadda? Fouch?)
5. Re: truncate results depend on strict/lazy (Bryan Vicknair)
6. Re: truncate results depend on strict/lazy (Mihai Maruseac)
7. Re: truncate results depend on strict/lazy (Bryan Vicknair)
8. Re: truncate results depend on strict/lazy (Bryan Vicknair)
----------------------------------------------------------------------
Message: 1
Date: Mon, 09 Sep 2013 17:55:52 +0200
From: Nathan H?sken <[email protected]>
To: Haskell Beginners Mailinglist <[email protected]>
Subject: [Haskell-beginners] wxHaskell programm segfaults when copying
shared object files into same directory
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hey,
I have a small wxHaskell program, compiled under ubuntu linux.
I want to give it (in a compiled version) to a friend. Since wxHaskell
seems to work only with shared linking, the program depends on a lot of
*.so files. Trying to send the so files with the program, I copied all
of them (all which are wxHaskell related) into the same directory as the
program. Interestingly when I do this, and try to run the program it
segfaults.
Anyone has an Idea why?
Thanks!
Nathan
------------------------------
Message: 2
Date: Mon, 9 Sep 2013 10:26:40 -0700
From: Bryan Vicknair <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] truncate results depend on strict/lazy
Message-ID: <20130909172640.GB11030@bry-m6300>
Content-Type: text/plain; charset=us-ascii
Deep in a WAI web app, I have a function that converts a String from a web form
like "0.12" to an Int 12. Converting "0.12" to the Float 0.12 is working.
However, converting the Float 0.12 to the Int 12 does not work as expected
unless I use the trace function.
In the following, f = 0.12::Float, gotten from a function that parses "0.12"
into 0.12.
In the following expression, the result is: Success (Just 11).
> Success $ Just $ truncate (f * 100)
In the following expression, the result is: Success (Just 12)
> let expanded = f * 100
> ans = truncate expanded
> in trace (show expanded) $ Success $ Just $ ans
That made me think that "f * 100" had to be strictly evaluated before given to
truncate for some reason, so I tried using seq to get the same effect, but that
didn't work. Am I correct in assuming that laziness has something to do with
this problem?
------------------------------
Message: 3
Date: Mon, 9 Sep 2013 13:34:24 -0400
From: Mihai Maruseac <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] truncate results depend on
strict/lazy
Message-ID:
<CAOMsUML_ajNE5t_=dhnb29xjybjxm2jzn5hojw6bemaawky...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
On Mon, Sep 9, 2013 at 1:26 PM, Bryan Vicknair <[email protected]> wrote:
> Deep in a WAI web app, I have a function that converts a String from a web
> form
> like "0.12" to an Int 12. Converting "0.12" to the Float 0.12 is working.
> However, converting the Float 0.12 to the Int 12 does not work as expected
> unless I use the trace function.
Not answering your question but can't you read . drop 1 . dropWhile
(/= '.') $ "0.12" ?
>
> In the following, f = 0.12::Float, gotten from a function that parses "0.12"
> into 0.12.
>
> In the following expression, the result is: Success (Just 11).
>
>> Success $ Just $ truncate (f * 100)
>
> In the following expression, the result is: Success (Just 12)
>
>> let expanded = f * 100
>> ans = truncate expanded
>> in trace (show expanded) $ Success $ Just $ ans
>
> That made me think that "f * 100" had to be strictly evaluated before given to
> truncate for some reason, so I tried using seq to get the same effect, but
> that
> didn't work. Am I correct in assuming that laziness has something to do with
> this problem?
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
--
MM
"All we have to decide is what we do with the time that is given to us"
------------------------------
Message: 4
Date: Mon, 9 Sep 2013 19:59:28 +0200
From: Chadda? Fouch? <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] truncate results depend on
strict/lazy
Message-ID:
<CANfjZRadRSKay-Vb6YUi=whrlucpv5z0g2aseokfy0wj5po...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Mon, Sep 9, 2013 at 7:26 PM, Bryan Vicknair <[email protected]> wrote:
> Deep in a WAI web app, I have a function that converts a String from a web
> form
> like "0.12" to an Int 12. Converting "0.12" to the Float 0.12 is working.
> However, converting the Float 0.12 to the Int 12 does not work as expected
> unless I use the trace function.
>
> In the following, f = 0.12::Float, gotten from a function that parses
> "0.12"
> into 0.12.
>
> In the following expression, the result is: Success (Just 11).
>
> > Success $ Just $ truncate (f * 100)
>
> In the following expression, the result is: Success (Just 12)
>
> > let expanded = f * 100
> > ans = truncate expanded
> > in trace (show expanded) $ Success $ Just $ ans
>
> That made me think that "f * 100" had to be strictly evaluated before
> given to
> truncate for some reason, so I tried using seq to get the same effect, but
> that
> didn't work. Am I correct in assuming that laziness has something to do
> with
> this problem?
>
>
It would be a serious bug if that was true since lazyness shouldn't change
the semantic of a program, except sometimes by allowing the program to
terminate where the strict version wouldn't.
On the other hand I can't reproduce your bug, couldn't you provide more
details (including GHC version and parsing code)
--
Jeda?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130909/5f661079/attachment-0001.html>
------------------------------
Message: 5
Date: Mon, 9 Sep 2013 10:59:24 -0700
From: Bryan Vicknair <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] truncate results depend on
strict/lazy
Message-ID: <20130909175924.GC11030@bry-m6300>
Content-Type: text/plain; charset=us-ascii
On Mon, Sep 09, 2013 at 01:34:24PM -0400, Mihai Maruseac wrote:
> On Mon, Sep 9, 2013 at 1:26 PM, Bryan Vicknair <[email protected]> wrote:
> > Deep in a WAI web app, I have a function that converts a String from a web
> > form
> > like "0.12" to an Int 12. Converting "0.12" to the Float 0.12 is working.
> > However, converting the Float 0.12 to the Int 12 does not work as expected
> > unless I use the trace function.
>
> Not answering your question but can't you read . drop 1 . dropWhile
> (/= '.') $ "0.12" ?
That would work for the specific input of "0.xyz", but in general, the input
string may encode a float with an arbitrary number of digits on both sides of
the decimal.
In reality, the range is probaby from 0.10 to 1.99, so I considered writing a
parser for just that range, and I may still, but this behavior is so surprising
to me that I feel like I need to understand it.
------------------------------
Message: 6
Date: Mon, 9 Sep 2013 14:15:57 -0400
From: Mihai Maruseac <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] truncate results depend on
strict/lazy
Message-ID:
<CAOMsUMLCxM0=tac4qetjpavwjrcv1ezowneeymmx76l1xgy...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
On Mon, Sep 9, 2013 at 1:59 PM, Bryan Vicknair <[email protected]> wrote:
> That would work for the specific input of "0.xyz", but in general, the input
> string may encode a float with an arbitrary number of digits on both sides of
> the decimal.
So, you'd need to convert 10.34 to 1034? I'd start with span (/= '.')
"10.32" and go from there :) (span from Data.Char)
--
MM
"All we have to decide is what we do with the time that is given to us"
------------------------------
Message: 7
Date: Mon, 9 Sep 2013 14:57:07 -0700
From: Bryan Vicknair <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] truncate results depend on
strict/lazy
Message-ID: <20130909215707.GA6113@bry-m6300>
Content-Type: text/plain; charset=iso-8859-1
On Mon, Sep 09, 2013 at 07:59:28PM +0200, Chadda? Fouch? wrote:
> > In the following expression, the result is: Success (Just 11).
> >
> > > Success $ Just $ truncate (f * 100)
> >
> > In the following expression, the result is: Success (Just 12)
> >
> > > let expanded = f * 100
> > > ans = truncate expanded
> > > in trace (show expanded) $ Success $ Just $ ans
> >
> > That made me think that "f * 100" had to be strictly evaluated before
> > given to
> > truncate for some reason, so I tried using seq to get the same effect, but
> > that
> > didn't work. Am I correct in assuming that laziness has something to do
> > with
> > this problem?
> >
> >
> It would be a serious bug if that was true since lazyness shouldn't change
> the semantic of a program, except sometimes by allowing the program to
> terminate where the strict version wouldn't.
>
> On the other hand I can't reproduce your bug, couldn't you provide more
> details (including GHC version and parsing code)
>
> --
> Jeda?
I put together a simple library and web app to demonstrate the behavior I'm
seeing: git clone [email protected]:bryanvick/truncate.git
The README has simple instructions to view the behavior in a repl or in a web
app. The Lib.hs file is where the parsing code is.
I swear I saw different behaviour between separate cabal sandboxes while I was
testing this. Sometimes the parsing would work as expected, sometimes it
wouldn't. That made me think that maybe different versions of dependencies are
being installed for different runs. I'll start paying attention to
"cabal sandbox hc-pkg" to see if this is the case.
------------------------------
Message: 8
Date: Mon, 9 Sep 2013 15:08:34 -0700
From: Bryan Vicknair <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] truncate results depend on
strict/lazy
Message-ID: <20130909220834.GB6113@bry-m6300>
Content-Type: text/plain; charset=us-ascii
> On Mon, Sep 9, 2013 at 7:26 PM, Bryan Vicknair <[email protected]> wrote:
> > Deep in a WAI web app, I have a function that converts a String from a web
> > form
> > like "0.12" to an Int 12. Converting "0.12" to the Float 0.12 is working.
> > However, converting the Float 0.12 to the Int 12 does not work as expected
> > unless I use the trace function.
> On Mon, Sep 9, 2013 Bryan Vicknair <[email protected]> wrote:
> I put together a simple library and web app to demonstrate the behavior I'm
> seeing: git clone [email protected]:bryanvick/truncate.git
>
> The README has simple instructions to view the behavior in a repl or in a web
> app. The Lib.hs file is where the parsing code is.
>
> I swear I saw different behaviour between separate cabal sandboxes while I was
> testing this. Sometimes the parsing would work as expected, sometimes it
> wouldn't. That made me think that maybe different versions of dependencies
> are
> being installed for different runs. I'll start paying attention to
> "cabal sandbox hc-pkg" to see if this is the case.
I just witnessed the parsing code in question giving different results in
different invocations of a repl in the same cabal sandbox.
I started a cabal sandbox and installed dependencies:
> cabal sandbox init
> cabal install --only-dependencies
... <bunch of compiling>
I started a repl...
> cabal repl
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring app-0...
Preprocessing library app-0...
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package array-0.4.0.0 ... linking ... done.
Loading package deepseq-1.3.0.0 ... linking ... done.
Loading package containers-0.4.2.1 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
Loading package text-0.11.3.1 ... linking ... done.
Loading package digestive-functors-0.6.1.0 ... linking ... done.
[1 of 1] Compiling Lib ( Lib.hs, interpreted )
Ok, modules loaded: Lib.
*Lib> import Data.Text (pack)
And this time, the parsing works!
*Lib Data.Text> validateVal $ pack "0.12"
Success (Just 12)
*Lib Data.Text> :q
Leaving GHCi.
I did a dump of the libraries installed to compare to later sandboxes that
don't work:
> cabal sandbox hc-pkg list > /tmp/working-deps
I ran the web app:
> cabal run
Building app-0...
Preprocessing library app-0...
[1 of 1] Compiling Lib ( Lib.hs, dist/build/Lib.o )
In-place registering app-0...
Preprocessing executable 'app' for app-0...
[1 of 2] Compiling Lib ( Lib.hs, dist/build/app/app-tmp/Lib.o )
[2 of 2] Compiling Main ( app.hs, dist/build/app/app-tmp/Main.o )
app.hs:67:21: Warning: Defined but not used: `name'
app.hs:67:37: Warning: Defined but not used: `val'
Linking dist/build/app/app ...
running at port 8005
Thing {name = "name", val = Just 11}
The parsing didn't work there, as usual. So I went back into the repl:
> cabal repl
Preprocessing library app-0...
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package array-0.4.0.0 ... linking ... done.
Loading package deepseq-1.3.0.0 ... linking ... done.
Loading package containers-0.4.2.1 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
Loading package text-0.11.3.1 ... linking ... done.
Loading package digestive-functors-0.6.1.0 ... linking ... done.
Ok, modules loaded: Lib.
Prelude Lib> import Data.Text (pack)
And all of a sudden, the parsing code doesn't work again!:
Prelude Data.Text Lib> validateVal $ pack "0.12"
Success (Just 11)
I'm loosing my mind!
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 63, Issue 13
*****************************************