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: recommended way to get haskell 6.10 installed on ubuntu
hardy? (David Virebayre)
2. questions about quickCheck (Zsolt Ero)
3. how to install "import Foreign.C.Types( CFloat )" in Ubuntu
(Zsolt Ero)
4. Re: questions about quickCheck (Daniel Fischer)
5. Re: how to install "import Foreign.C.Types( CFloat )" in
Ubuntu (Daniel Fischer)
6. Re: combinatorial (Edward Z. Yang)
7. Re: combinatorial (Michael Mossey)
8. Easier alternatives to existential types? (Emile Melnicov)
9. Re: Easier alternatives to existential types? (Felipe Lessa)
----------------------------------------------------------------------
Message: 1
Date: Tue, 24 Nov 2009 07:42:57 +0100
From: David Virebayre <[email protected]>
Subject: Re: [Haskell-beginners] recommended way to get haskell 6.10
installed on ubuntu hardy?
To: Joe Van Dyk <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
On Mon, Nov 23, 2009 at 9:08 PM, Joe Van Dyk <[email protected]>wrote:
> There's no ubuntu package for 6.10 (only 6.8), and the haskell
> platform says you need 6.10 installed to build the source package.
>
When I was on Hardy, I just installed 6.10 from the binary tarball.
(Kubuntu)
David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20091124/e6342cda/attachment-0001.html
------------------------------
Message: 2
Date: Tue, 24 Nov 2009 07:00:52 +0000
From: Zsolt Ero <[email protected]>
Subject: [Haskell-beginners] questions about quickCheck
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hi,
I have just started learning Haskell this semester, and I have some
questions of things which puzzles me:
1. I would like to ask that how is it possible to set quickCheck test
numbers to something else then the default 100 passes?
I have found an article which says:
deepCheck p = check (defaultConfig { configMaxTest = 10000}) p
which I tried and it works at a home Ubuntu install but when I tried
it at my university network, it says:
Not in scope: `check'
Not in scope: `defaultConfig'
Not in scope: `configMaxTest'
Isn't there a way of making quickCheck use a different number by using
'==>' functions for example?
Is quickCheck p = check (defaultConfig) p?
2. How could I print the result of a complex quickCheck generator? I
mean if there is an error is says it, but what if I would like to
generate just random expressions which quickCheck can do?
Zsolt
------------------------------
Message: 3
Date: Tue, 24 Nov 2009 07:11:25 +0000
From: Zsolt Ero <[email protected]>
Subject: [Haskell-beginners] how to install "import Foreign.C.Types(
CFloat )" in Ubuntu
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
I am trying to run a file, which works well on the university system,
but I don't know what do I need to do to make it work on my home
Ubuntu system.
The particular line which makes the error is:
import Foreign.C.Types( CFloat )
And the error is:
-----------------------------------------------------------
LSystem.hs:130:4:
No instance for (ColorComponent CFloat)
arising from a use of `color' at LSystem.hs:130:4-26
Possible fix:
add an instance declaration for (ColorComponent CFloat)
.....
-------------------------------------------------------------
If I write "import Foreign.C.Types" at the Prelude it says nothing. If
I write "import Foreign.C.Types( CFloat )" at the Prelude, it says
<interactive>:1:0: parse error on input `import'
What can it be?
Cheers,
Zsolt
------------------------------
Message: 4
Date: Tue, 24 Nov 2009 14:43:43 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] questions about quickCheck
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Am Dienstag 24 November 2009 08:00:52 schrieb Zsolt Ero:
> Hi,
>
> I have just started learning Haskell this semester, and I have some
> questions of things which puzzles me:
>
> 1. I would like to ask that how is it possible to set quickCheck test
> numbers to something else then the default 100 passes?
That depends on whether you're using QuickCheck 1.* or QuickCheck 2.*.
In 1.*, you'd use
customCheck p = check (defaultConfig{ configMaxTest = whatever }) p
-- perhaps you would also want to set other fields of the config, e.g.
configMaxFail
In 2.*, things have been reorganised, so that QC 2.* is incompatible with 1.*,
there you'd
use
customCheck p = quickCheckWith (stdArgs{ maxSuccess = whatever }) p
-- perhaps you also want to set other fields of args, e.g. maxDiscard
>
> I have found an article which says:
> deepCheck p = check (defaultConfig { configMaxTest = 10000}) p
>
> which I tried and it works at a home Ubuntu install but when I tried
> it at my university network, it says:
>
> Not in scope: `check'
> Not in scope: `defaultConfig'
> Not in scope: `configMaxTest'
Probably QC 1.* at home, QC 2.* at the university.
>
> Isn't there a way of making quickCheck use a different number by using
> '==>' functions for example?
Not a good one.
>
> Is quickCheck p = check (defaultConfig) p?
In 1.*, yes, but indirectly.
You can verify such things yourself by looking at the docs + source in hackage,
e.g.
http://hackage.haskell.org/packages/archive/QuickCheck/1.2.0.0/doc/html/src/Test-
QuickCheck.html#quickCheck
vs.
http://hackage.haskell.org/packages/archive/QuickCheck/2.1.0.2/doc/html/src/Test-
QuickCheck-Test.html#quickCheck
>
> 2. How could I print the result of a complex quickCheck generator? I
> mean if there is an error is says it, but what if I would like to
> generate just random expressions which quickCheck can do?
??
perhaps you want to use verboseCheck in QC 1.* (prints out the tested data),
look at QC
2.*'s sources to find how to do it there, maybe sample' could be used.
>
> Zsolt
------------------------------
Message: 5
Date: Tue, 24 Nov 2009 15:00:37 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] how to install "import
Foreign.C.Types( CFloat )" in Ubuntu
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Am Dienstag 24 November 2009 08:11:25 schrieb Zsolt Ero:
> I am trying to run a file, which works well on the university system,
> but I don't know what do I need to do to make it work on my home
> Ubuntu system.
>
> The particular line which makes the error is:
> import Foreign.C.Types( CFloat )
>
> And the error is:
> -----------------------------------------------------------
> LSystem.hs:130:4:
> No instance for (ColorComponent CFloat)
> arising from a use of `color' at LSystem.hs:130:4-26
> Possible fix:
> add an instance declaration for (ColorComponent CFloat)
> .....
> -------------------------------------------------------------
The problem is not Foreign.C.Types, it's in your OpenGL lib.
Probably different versions at home and university.
Try adding
instance ColorComponent CFloat
to LSystem.hs
If that doesn't work, replacing (color x) with (color $ realToFrac x) in all
pertinent
places should make it work.
>
> If I write "import Foreign.C.Types" at the Prelude it says nothing. If
> I write "import Foreign.C.Types( CFloat )" at the Prelude, it says
> <interactive>:1:0: parse error on input `import'
Yes, the import at the ghci-prompt is restricted, you can only do
import Module
there, no import lists, no hiding, no import qualified M as P.
>
> What can it be?
>
> Cheers,
> Zsolt
------------------------------
Message: 6
Date: Tue, 24 Nov 2009 13:18:06 -0500
From: "Edward Z. Yang" <[email protected]>
Subject: Re: [Haskell-beginners] combinatorial
To: Michael Mossey <[email protected]>
Cc: beginners <[email protected]>
Message-ID: <1259086537-sup-7...@ezyang>
Content-Type: text/plain; charset=UTF-8
Excerpts from Michael Mossey's message of Sun Nov 22 17:30:57 -0500 2009:
> I'm not totally exactly sure what you mean here, but my evaluation function
> can in fact evaluate phrases of any length.
Say I have [A, B] which evaluates to 3. If I want to know the score of [A, B,
C],
I can't say, "Oh, but remember that [A, B] is 3." It's not a fold, essentially.
> Here's what I had in mind for a search algorithm. The idea is to combine
> features of greedy and broad search. I have no idea is this is a good idea.
> It's just a thought.
If by greedy you mean depth-first and by broad you mean breadth-first,
this is a certainly a good idea. If you'd like to look it up further,
check "beam search".
> Let's say we start by evaluating all lists of length 2 and picking those
> tied for the maximum score. Then the algorithm is,
>
> for each input list of length 2 tied for maximum,
> make all lists of length 3 that are acceptable (that don't return
> Nothing when evaluated)
> concat all those
> evaluate all of them and pick all tied for the maximum
> feed into next step (continue with lengths 4..N.)
>
> The idea is that's a greedy algorithm that still allows for some breadth of
> search by looking at ties. In my scoring system there will often be ties.
It sounds like you've basically got the algorithm written down, you have to
translate it to Haskell. Do you have a specific problem?
Cheers,
Edward
------------------------------
Message: 7
Date: Tue, 24 Nov 2009 12:50:41 -0800
From: Michael Mossey <[email protected]>
Subject: Re: [Haskell-beginners] combinatorial
To: "Edward Z. Yang" <[email protected]>
Cc: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
Edward Z. Yang wrote:
>
> If by greedy you mean depth-first and by broad you mean breadth-first,
> this is a certainly a good idea. If you'd like to look it up further,
> check "beam search".
>
I think I mean that. Thanks for the tip.
>
> It sounds like you've basically got the algorithm written down, you have to
> translate it to Haskell. Do you have a specific problem?
>
No, I think I've got it now, but it is always interesting to me to see what
new things I learn when the more experienced members on the list give me
their thoughts. I'm just checking if anyone wants to suggest that I'm off
course and a better way exists.
Thanks,
Mike
------------------------------
Message: 8
Date: Thu, 26 Nov 2009 06:37:57 +0400
From: Emile Melnicov <[email protected]>
Subject: [Haskell-beginners] Easier alternatives to existential types?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain; charset="us-ascii"
Hello everyone.
I'm trying to write RIFF parser and can't decide what to do with
"container" type. "Container" chunk should hold a header (two
Word32's), a "type" (Word32 like "WAVE" etc) and a "list" of other chunks.
Of course lists can't be used because we have far more than one chunk
types. What can I do with this?
I discovered existentials for myself recently, but those could be too hard
for me yet. It feels like I'm missing something very obvious here.
Thanks for attention.
--
Emile.
------------------------------
Message: 9
Date: Thu, 26 Nov 2009 01:41:40 -0200
From: Felipe Lessa <[email protected]>
Subject: Re: [Haskell-beginners] Easier alternatives to existential
types?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Thu, Nov 26, 2009 at 06:37:57AM +0400, Emile Melnicov wrote:
> I'm trying to write RIFF parser and can't decide what to do with
> "container" type. "Container" chunk should hold a header (two
> Word32's), a "type" (Word32 like "WAVE" etc) and a "list" of other chunks.
> Of course lists can't be used because we have far more than one chunk
> types. What can I do with this?
data Header = H {fieldAbc :: Word32
,filedXyz :: Word32}
data Type = AU | WAVE | ...
data ContainerChunk = Chunk Header Type [ContainerChunk]
Well, yes, I know that almost certanly that was not what you were
thinking when you wrote the question. The code above is how I
interpreted your question. I'm writing it so that you can
clarify the question if the others don't understand as well.
Maybe, something like this?
data WaveChunk = Wave {...}
data AuChunk = Au {...}
data Container = ...any chunk above...
doSomethingWillAllThoseFiles :: [Container] -> IO ()
You may want to keep it simple and just use
data Container = TypeWave WaveChunk
| TypeAu AuChunk
If you really want existentials, though, I'd recommend using GADT
syntax as in
class Chunk c where
...
instance Chunk WaveChunk where ...
instance Chunk AuChunk where ...
data Container where
AudioChunk :: Chunk c => c -> Container
x,y :: Container
x = AudioChunk (Wave {...})
y = AudioChunk (Au {...})
f :: Chunk c => c -> IO ()
f = ...
g :: Container -> IO ()
g (AudioChunk c) = f c
-- pattern match brings (Chunk c) into context.
Note that 'c' above doesn't appear in the type of the Container.
This roughly means that it will be existentially qualified.
HTH!
--
Felipe.
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 17, Issue 29
*****************************************