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: Evaluate function (Derek McLoughlin)
2. Re: Evaluate function (Kim-Ee Yeoh)
3. Re: Evaluate function (Daniel Trstenjak)
4. apply a function to all params of another function
(Kees Bleijenberg)
5. Re: Evaluate function (Brent Yorgey)
6. Re: apply a function to all params of another function
(Brent Yorgey)
7. Using "cabal test" and getting "cabal: Prelude.read: no
parse" (Daniel King)
8. Re: Using "cabal test" and getting "cabal: Prelude.read: no
parse" (Boris)
----------------------------------------------------------------------
Message: 1
Date: Mon, 26 May 2014 14:03:37 +0100
From: Derek McLoughlin <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Evaluate function
Message-ID:
<CAAw9fm=tdwkonmbqhjpv4czsjdgg8h9ad2r73_xjtvmjj6h...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Thanks. Reading back, this is actually explained on page 14 - sorry for
that.
On 26 May 2014 11:22, "Daniel Fischer" <[email protected]>
wrote:
> On Monday 26 May 2014, 10:00:33, Derek McLoughlin wrote:
> > Reading "Parallel and Concurrent Programming in Haskell", at the bottom
> of
> > page 27 the author wants to force the evaluation of a list of Strings:
> >
> > evaluate ( length puzzles )
> >
> > Why not just
> >
> > evaluate puzzles
> >
> > ?
> >
> > https://github.com/simonmar/parconc-examples/blob/master/sudoku4.hs
>
> Because "evaluate" means "evaluate to weak head normal form", that is, to
> the
> outermost constructor or lambda.
>
> evaluate puzzles
>
> would evaluate the list just so far that it is known whether the list is
> empty
> or not.
>
> To evaluate something completely, one needs to evaluate a value that
> depends
> on the complete structure. Presumably, to determine the length of the list,
> one needs to evaluate all paths completely to see whether they lead to a
> valid
> puzzle, hence the evaluation is forced by demanding the evaluation of the
> length.
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140526/cd850497/attachment-0001.html>
------------------------------
Message: 2
Date: Mon, 26 May 2014 20:21:36 +0700
From: Kim-Ee Yeoh <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Evaluate function
Message-ID:
<capy+zdskn-a3b+7thb3ggsm89hu5bas2hvxr_mcfjgm8t9h...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Mon, May 26, 2014 at 5:21 PM, Daniel Fischer <
[email protected]> wrote:
> To evaluate something completely, one needs to evaluate a value that
> depends
> on the complete structure. Presumably, to determine the length of the list,
> one needs to evaluate all paths completely to see whether they lead to a
> valid
> puzzle, hence the evaluation is forced by demanding the evaluation of the
> length.
>
To avoid that presumption, you could also write
evaluate $ rnf x
whenever x is an instance of NFData.
The length function strikes me as a kludgy stand-in for rnf when rnf is
really what's meant.
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140526/43dc69a5/attachment-0001.html>
------------------------------
Message: 3
Date: Mon, 26 May 2014 16:25:35 +0200
From: Daniel Trstenjak <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Evaluate function
Message-ID: <20140526142535.GA18240@machine>
Content-Type: text/plain; charset=us-ascii
On Mon, May 26, 2014 at 08:21:36PM +0700, Kim-Ee Yeoh wrote:
> The length function strikes me as a kludgy stand-in for rnf when rnf is really
> what's meant.
And depending on the type of the list entries, calling length won't
always have the same effect then calling rnf on the list and therefore
on all entries of the list.
Greetings,
Daniel
------------------------------
Message: 4
Date: Mon, 26 May 2014 16:46:29 +0200
From: "Kees Bleijenberg" <[email protected]>
To: "'The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell'" <[email protected]>
Subject: [Haskell-beginners] apply a function to all params of another
function
Message-ID: <001201cf78f1$474cf130$d5e6d390$@[email protected]>
Content-Type: text/plain; charset="us-ascii"
In have a lot of functions in a program with params that are alle Int's.
f :: Int -> Int -> Int
g :: Int -> Int -> Int
h :: Int -> Int -> Int -> Int
...
and convertParam :: Int -> Int -- say (+1)
I want to call functions like f, g and h, but apply convertParam to all
params first.
f2 a b c = f (convertParam a) (convertParam b) (convertParam c)
I tried:
run1p f conv = \a -> f (conv a) -- for functions with one
param
run2p f conv = \a b -> f (conv a) (conv b) -- for functions with two
params
.
Can you do this in a more generalized way (using currying?)
Any ideas?
Kees
------------------------------
Message: 5
Date: Mon, 26 May 2014 12:21:57 -0400
From: Brent Yorgey <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Evaluate function
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Mon, May 26, 2014 at 04:25:35PM +0200, Daniel Trstenjak wrote:
> On Mon, May 26, 2014 at 08:21:36PM +0700, Kim-Ee Yeoh wrote:
> > The length function strikes me as a kludgy stand-in for rnf when rnf is
> > really
> > what's meant.
>
> And depending on the type of the list entries, calling length won't
> always have the same effect then calling rnf on the list and therefore
> on all entries of the list.
>
Though I could imagine a situation where one wants to force the spine
of the list but not the elements it contains. In that case rnf would
do too much, and 'length' would do the right thing. However, 'length'
still feels kludgy here. What is really wanted is a domain-specific
language for expressing which parts of a structure should be forced.
Such a domain-specific language can be found here:
http://hackage.haskell.org/package/parallel-3.2.0.4/docs/Control-Seq.html
In particular, forcing the spine of a list but not its elements can be
expressed by
evaluate (puzzles `using` seqList r0)
.
-Brent
------------------------------
Message: 6
Date: Mon, 26 May 2014 12:25:27 -0400
From: Brent Yorgey <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] apply a function to all params of
another function
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Mon, May 26, 2014 at 04:46:29PM +0200, Kees Bleijenberg wrote:
> In have a lot of functions in a program with params that are alle Int's.
> f :: Int -> Int -> Int
> g :: Int -> Int -> Int
> h :: Int -> Int -> Int -> Int
> ...
> and convertParam :: Int -> Int -- say (+1)
> I want to call functions like f, g and h, but apply convertParam to all
> params first.
> f2 a b c = f (convertParam a) (convertParam b) (convertParam c)
>
> I tried:
> run1p f conv = \a -> f (conv a) -- for functions with
> one
> param
> run2p f conv = \a b -> f (conv a) (conv b) -- for functions with two
> params
> .
> Can you do this in a more generalized way (using currying?)
> Any ideas?
class Convertible t where
convert :: t -> t
instance Convertible Int where
...
instance Convertible t => Convertible (Int -> t) where
...
I'll let you fill in the ... ! =) Note this only works well because
the base case is Int. You could also add some extra base cases for
other concrete return types. However, it is quite difficult to give a
Convertible instance which applies to "all types which are not
functions", so this will only work if you are willing to make one
instance for each concrete result type your functions use.
-Brent
------------------------------
Message: 7
Date: Mon, 26 May 2014 14:01:38 -0400
From: Daniel King <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Using "cabal test" and getting "cabal:
Prelude.read: no parse"
Message-ID:
<caoshcwr-bpuwce0-o1bykg9ncgnwxrpsyvd-04htypzhtgj...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi all,
I created a cabal project with the attached cabal file. I run:
cabal configure --enable-tests
cabal build
cabal test
and then I get the error:
cabal: Prelude.read: no parse
I'm not sure how to debug this any further. If I execute:
./dist/build/scientific-pl-testsStub/scientific-pl-testsStub
with any input I've tried (numbers, array notation, string notation,
etc.) and I get that same error.
I can post the whole project if that is helpful.
Thanks for the debugging tips!
The full log is:
danking@spock # cabal configure --enable-tests
Resolving dependencies...
Configuring scientific-pl-0.1.0.0...
danking@spock # cabal build
Building scientific-pl-0.1.0.0...
Preprocessing test suite 'scientific-pl-tests' for scientific-pl-0.1.0.0...
[1 of 3] Compiling SPLData ( SPLData.hs, dist/build/SPLData.o )
[2 of 3] Compiling SPLEval ( SPLEval.hs, dist/build/SPLEval.o )
[3 of 3] Compiling Tests ( tests/Tests.hs, dist/build/Tests.o )
In-place registering scientific-pl-tests-0.1.0.0...
[1 of 1] Compiling Main (
dist/build/scientific-pl-testsStub/scientific-pl-testsStub-tmp/scientific-pl-testsStub.hs,
dist/build/scientific-pl-testsStub/scientific-pl-testsStub-tmp/Main.o
)
Linking dist/build/scientific-pl-testsStub/scientific-pl-testsStub ...
Preprocessing executable 'scientific-pl' for scientific-pl-0.1.0.0...
[1 of 3] Compiling SPLData ( SPLData.hs,
dist/build/scientific-pl/scientific-pl-tmp/SPLData.o )
[2 of 3] Compiling SPLEval ( SPLEval.hs,
dist/build/scientific-pl/scientific-pl-tmp/SPLEval.o )
[3 of 3] Compiling Main ( Main.hs,
dist/build/scientific-pl/scientific-pl-tmp/Main.o )
Linking dist/build/scientific-pl/scientific-pl ...
danking@spock # cabal test
Running 1 test suites...
Test suite scientific-pl-tests: RUNNING...
cabal: Prelude.read: no parse
1 danking@spock #
--
Dan King
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scientific-pl.cabal
Type: application/octet-stream
Size: 999 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140526/3916eac2/attachment-0001.obj>
------------------------------
Message: 8
Date: Mon, 26 May 2014 21:13:51 +0200
From: Boris <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Using "cabal test" and getting
"cabal: Prelude.read: no parse"
Message-ID: <[email protected]>
Content-Type: text/plain
Hello,
Last time I got such an error, it was because I was using 'read' for a
type I had defined myself, deriving Read, but on something that was not
reelated to the type. For instance:
data Foo = Foo deriving (Read, Show)
x :: Foo
x = read "Bar"
Do you use read somwhere?
HTH
Daniel King <[email protected]> writes:
> Hi all,
>
> I created a cabal project with the attached cabal file. I run:
>
> cabal configure --enable-tests
> cabal build
> cabal test
>
> and then I get the error:
>
> cabal: Prelude.read: no parse
>
> I'm not sure how to debug this any further. If I execute:
>
> ./dist/build/scientific-pl-testsStub/scientific-pl-testsStub
>
> with any input I've tried (numbers, array notation, string notation,
> etc.) and I get that same error.
>
> I can post the whole project if that is helpful.
>
> Thanks for the debugging tips!
>
> The full log is:
>
> danking@spock # cabal configure --enable-tests
> Resolving dependencies...
> Configuring scientific-pl-0.1.0.0...
> danking@spock # cabal build
> Building scientific-pl-0.1.0.0...
> Preprocessing test suite 'scientific-pl-tests' for scientific-pl-0.1.0.0...
> [1 of 3] Compiling SPLData ( SPLData.hs, dist/build/SPLData.o )
> [2 of 3] Compiling SPLEval ( SPLEval.hs, dist/build/SPLEval.o )
> [3 of 3] Compiling Tests ( tests/Tests.hs, dist/build/Tests.o )
> In-place registering scientific-pl-tests-0.1.0.0...
> [1 of 1] Compiling Main (
> dist/build/scientific-pl-testsStub/scientific-pl-testsStub-tmp/scientific-pl-testsStub.hs,
> dist/build/scientific-pl-testsStub/scientific-pl-testsStub-tmp/Main.o
> )
> Linking dist/build/scientific-pl-testsStub/scientific-pl-testsStub ...
> Preprocessing executable 'scientific-pl' for scientific-pl-0.1.0.0...
> [1 of 3] Compiling SPLData ( SPLData.hs,
> dist/build/scientific-pl/scientific-pl-tmp/SPLData.o )
> [2 of 3] Compiling SPLEval ( SPLEval.hs,
> dist/build/scientific-pl/scientific-pl-tmp/SPLEval.o )
> [3 of 3] Compiling Main ( Main.hs,
> dist/build/scientific-pl/scientific-pl-tmp/Main.o )
> Linking dist/build/scientific-pl/scientific-pl ...
> danking@spock # cabal test
> Running 1 test suites...
> Test suite scientific-pl-tests: RUNNING...
> cabal: Prelude.read: no parse
> 1 danking@spock #
--
Boris Daix
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 71, Issue 31
*****************************************