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.  Closing a channel (Lyndon Maydwell)
   2.  Genetic algorithm for knapsack problem (Karol Samborski)
   3.  Are there summary sheets of operations on lists etc. i.e.
      shorter than Data.List (KC)
   4.  Deserializing data with ProtocolBuffers (Raphael P?bst)
   5. Re:  Deserializing data with ProtocolBuffers (Daniel Fischer)
   6. Re:  Deserializing data with ProtocolBuffers (Raphael P?bst)
   7. Re:  Deserializing data with ProtocolBuffers (Daniel Fischer)
   8. Re:  Genetic algorithm for knapsack problem (AJ Sherbondy)
   9.  Compiling with HDBC (Christopher Howard)


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

Message: 1
Date: Thu, 12 May 2011 18:20:01 +0800
From: Lyndon Maydwell <[email protected]>
Subject: [Haskell-beginners] Closing a channel
To: Biginners Haskell Mailinglist <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

Hi Beginners.

I'm trying to implement a program that accumulates a list of items
through many IO actions, then use these in another part of the program
as a list.

I've found Control.Concurrent.Chan which seems to provide a nice
abstraction with getChanContents :: Chan a -> IO [a], but there
doesn't seem to be a way for the source to close the channel.

Are channels the right abstraction for something like this? Should
look in to (itter|enumer)at(or|ee)s instead... They seem to encompass
this model, but look quite involved.



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

Message: 2
Date: Thu, 12 May 2011 16:24:15 +0200
From: Karol Samborski <[email protected]>
Subject: [Haskell-beginners] Genetic algorithm for knapsack problem
To: Biginners Haskell Mailinglist <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

Hi all,

I'm a student and I got recently a task to do (and I want to do it in
haskell). I have to implement "genetic algorithm for knapsack problem"
and it would be nice if it will be fast.  So my question is: what
haskell datatypes, modules etc. should I use for this algorithm to
achieve this goal? I mean fast as compared to implementation in
imperative languages like C.

Any advices ?

Best regards,
Karol Samborski



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

Message: 3
Date: Thu, 12 May 2011 08:14:28 -0700
From: KC <[email protected]>
Subject: [Haskell-beginners] Are there summary sheets of operations on
        lists etc. i.e. shorter than Data.List
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

-- 
--
Regards,
KC



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

Message: 4
Date: Thu, 12 May 2011 18:21:45 +0200
From: Raphael P?bst <[email protected]>
Subject: [Haskell-beginners] Deserializing data with ProtocolBuffers
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Hey!
I am currently working on a project, where I need to serialize data
with ProtocolBuffers.
I have managed to compile a .proto file and serialize messages with
messagePut. However, when I try to deserialize a ByteString again, I
get the following error:

ambiguous type variable `msg0' in the constraints:
(Text.ProtocolBuffers.WireMessage.Wire msg0) arising from a use of
"messageGet" at...
(Text.ProtocolBuffers.Reflections.ReflectDescriptor msg0) arising from
a use of "messageGet" at ...
Probable fix: add a type signature that fixes these type variables in
the expression "messageGet bs"
in an equation for `IT':  "IT = messageGet bs"

I'm trying to call messageGet from the prompt in ghc. What exactly am
I doing wrong? And how can I fix this?

Many Thanks

Raphael



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

Message: 5
Date: Thu, 12 May 2011 18:39:10 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Deserializing data with
        ProtocolBuffers
To: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain;  charset="iso-8859-1"

On Thursday 12 May 2011 18:21:45, Raphael P?bst wrote:
> Hey!
> I am currently working on a project, where I need to serialize data
> with ProtocolBuffers.
> I have managed to compile a .proto file and serialize messages with
> messagePut. However, when I try to deserialize a ByteString again, I
> get the following error:
> 
> ambiguous type variable `msg0' in the constraints:
> (Text.ProtocolBuffers.WireMessage.Wire msg0) arising from a use of
> "messageGet" at...
> (Text.ProtocolBuffers.Reflections.ReflectDescriptor msg0) arising from
> a use of "messageGet" at ...
> Probable fix: add a type signature that fixes these type variables in
> the expression "messageGet bs"
> in an equation for `IT':  "IT = messageGet bs"
> 
> I'm trying to call messageGet from the prompt in ghc. What exactly am
> I doing wrong? And how can I fix this?

You have to tell it which type you want, so it can choose the correct 
messageGet.

If you type

ghci> read "True"

it doesn't know either and you have to tell it (and of course the result 
would be different for result type Bool than for Integer).

So you have to type

ghci> messageGet bs :: WhateverWireYouWant

to disambiguate the type.

In programmes, there's rarely a need to provide such expression type 
signatures because the type can usually be inferred from the context.
If there's not enough context to infer the type - especially if there's no 
context - you have to provide an explicit type.

> 
> Many Thanks
> 
> Raphael



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

Message: 6
Date: Thu, 12 May 2011 19:25:27 +0200
From: Raphael P?bst <[email protected]>
Subject: Re: [Haskell-beginners] Deserializing data with
        ProtocolBuffers
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Ah, thank you! Now it works.
Now I need only to get rid of the Right from the returned Either value
and I'm done.

Raphael

On 5/12/11, Daniel Fischer <[email protected]> wrote:
> On Thursday 12 May 2011 18:21:45, Raphael P?bst wrote:
>> Hey!
>> I am currently working on a project, where I need to serialize data
>> with ProtocolBuffers.
>> I have managed to compile a .proto file and serialize messages with
>> messagePut. However, when I try to deserialize a ByteString again, I
>> get the following error:
>>
>> ambiguous type variable `msg0' in the constraints:
>> (Text.ProtocolBuffers.WireMessage.Wire msg0) arising from a use of
>> "messageGet" at...
>> (Text.ProtocolBuffers.Reflections.ReflectDescriptor msg0) arising from
>> a use of "messageGet" at ...
>> Probable fix: add a type signature that fixes these type variables in
>> the expression "messageGet bs"
>> in an equation for `IT':  "IT = messageGet bs"
>>
>> I'm trying to call messageGet from the prompt in ghc. What exactly am
>> I doing wrong? And how can I fix this?
>
> You have to tell it which type you want, so it can choose the correct
> messageGet.
>
> If you type
>
> ghci> read "True"
>
> it doesn't know either and you have to tell it (and of course the result
> would be different for result type Bool than for Integer).
>
> So you have to type
>
> ghci> messageGet bs :: WhateverWireYouWant
>
> to disambiguate the type.
>
> In programmes, there's rarely a need to provide such expression type
> signatures because the type can usually be inferred from the context.
> If there's not enough context to infer the type - especially if there's no
> context - you have to provide an explicit type.
>
>>
>> Many Thanks
>>
>> Raphael
>



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

Message: 7
Date: Thu, 12 May 2011 19:28:50 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Deserializing data with
        ProtocolBuffers
To: Raphael P?bst <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain;  charset="iso-8859-1"

On Thursday 12 May 2011 19:25:27, Raphael P?bst wrote:
> Ah, thank you! Now it works.
> Now I need only to get rid of the Right from the returned Either value
> and I'm done.

Pattern-match:

ghci> case messageGet bs of { Left err -> undefined; Right result -> 
result; } :: type

or use either (\_ -> error "oops") id

> 
> Raphael



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

Message: 8
Date: Thu, 12 May 2011 17:18:20 -0400
From: AJ Sherbondy <[email protected]>
Subject: Re: [Haskell-beginners] Genetic algorithm for knapsack
        problem
To: Karol Samborski <[email protected]>
Cc: Biginners Haskell Mailinglist <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

Karol,

I don't know if you have looked at this module on Hackage or whether it will
even help you, but there is an evolution algorithm the individual functions
of which might be useful to you and is described as follows:

AI.SimpleEA

A framework for simple evolutionary algorithms. Provided with a function for
evaluating a genome's fitness, a function for probabilistic selection among
a pool of genomes, and recombination and mutation operators,
runEA<file:///Users/aj/Library/Haskell/ghc-7.0.3/lib/SimpleEA-0.1.1/doc/html/AI-SimpleEA.html#v:runEA>
will
run an EA that lazily produces an infinite list of generations.

AI.SimpleEA.Utils contains utilitify functions that makes it easier to write
the genetic operators.

ajsher

On Thu, May 12, 2011 at 10:24 AM, Karol Samborski <[email protected]>wrote:

> Hi all,
>
> I'm a student and I got recently a task to do (and I want to do it in
> haskell). I have to implement "genetic algorithm for knapsack problem"
> and it would be nice if it will be fast.  So my question is: what
> haskell datatypes, modules etc. should I use for this algorithm to
> achieve this goal? I mean fast as compared to implementation in
> imperative languages like C.
>
> Any advices ?
>
> Best regards,
> Karol Samborski
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>



-- 
AJ Sherbondy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110512/8960782e/attachment-0001.htm>

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

Message: 9
Date: Thu, 12 May 2011 21:35:29 -0800
From: Christopher Howard <[email protected]>
Subject: [Haskell-beginners] Compiling with HDBC
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Hi. I'm very new to Haskell, but I'm trying to compile a simple program
that uses HDBC with ODBC. I am working on an amd64 Gentoo Linux system.
I've installed hdbc and hdbc-odbc with the unixOBDC bindings. So far, I
created a small hello world type program. It doesn't use any HDBC
functionality yet, but I inserted the following two lines at the top to
see if I could compile correctly:

import Database.HDBC
import Database.HDBC.ODBC

However, when I try to compile I get this:

$ ghc Main.hs
Main.o: In function `s1cY_info':
(.text+0x1ef): undefined reference to
`__stginit_HDBCzmodbczm1zi1zi3zi0_DatabaseziHDBCziODBC_'
Main.o: In function `s1cY_info':
(.text+0x1fb): undefined reference to
`__stginit_HDBCzm2zi2zi6zi1_DatabaseziHDBC_'
collect2: ld returned 1 exit status

Though, these errors do not show up when I run the .hs file with runhaskell.

I'm guessing I just don't know how to link to the correct library or
libraries. I tried adding -lodbc to the ghc line but that did not help.
In /usr/lib I see libodbc.so, as well as the directories hdbc-1.1.3 and
hdbc-odbc-1.1.3.0. I would appreciate any guidance.

-- 
frigidcode.com
theologia.indicium.us



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

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


End of Beginners Digest, Vol 35, Issue 23
*****************************************

Reply via email to