[Haskell-cafe] How to do the permutation and combination thing?

2010-03-11 Thread Magicloud Magiclouds
Hi, For example, I have this: list1 = [a, b, c] list2 = [d, e, f] list3 = [g, h, i] Now I want: [ [(a, d, g), (b, e, h), (c, f, i)] , ... ] -- a list that contains all the combinations. How to do it pretty? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 ___

Re: [Haskell-cafe] How to do the permutation and combination thing?

2010-03-11 Thread Magicloud Magiclouds
All I could get is to use permutations and concatMap. But it looks really ugly. On Fri, Mar 12, 2010 at 2:09 PM, Casey Hawthorne cas...@istar.ca wrote: This sounds like homework. Think in abstract terms what you want to accomplish. Start with the simplest case first, usually the base case.

Re: [Haskell-cafe] How to do the permutation and combination thing?

2010-03-15 Thread Magicloud Magiclouds
Sorry, I did not make it clear, since I did not know how to say this in technical terms. With comprehension, I could get all the possibilities that draw one elem from each list and put them together. But consider this: for example, there are two types of pet, dog and cat. And there are two

Re: [Haskell-cafe] How to do the permutation and combination thing?

2010-03-15 Thread Magicloud Magiclouds
I realized I fell into the trap of wrong way. Thank you. On Fri, Mar 12, 2010 at 4:16 PM, Ketil Malde ke...@malde.org wrote: Casey Hawthorne cas...@istar.ca writes:  For example, I have this: list1 = [a, b, c] list2 = [d, e, f] list3 = [g, h, i] Think in abstract terms what you want to

Re: [Haskell-cafe] How to do the permutation and combination thing?

2010-03-15 Thread Magicloud Magiclouds
Oh, that is not a precondition. So the answer of yours are correct. I am working on permutations. I used it in a wrong way. On Mon, Mar 15, 2010 at 4:39 PM, Daniel Fischer daniel.is.fisc...@web.de wrote: Am Montag 15 März 2010 08:37:20 schrieb Magicloud Magiclouds: Sorry, I did not make

[Haskell-cafe] Problem about pattern matching.

2010-04-28 Thread Magicloud Magiclouds
Hi, I have code as below. How come case version works wrong and gives me overlap compiling warning? Thanks. if dayOfMonth == firstDayOfMonth then v day (x, y) else if dayOfMonth == lastDayOfMonth then not_ $ v day (x, y) else Mider day (x, y) case dayOfMonth of

Re: [Haskell-cafe] Problem about pattern matching.

2010-04-29 Thread Magicloud Magiclouds
On Thu, Apr 29, 2010 at 1:51 AM, Henning Thielemann schlepp...@henning-thielemann.de wrote: minh thu schrieb: 2010/4/28 Magicloud Magiclouds magicloud.magiclo...@gmail.com: Hi, I have code as below. How come case version works wrong and gives me overlap compiling warning? Thanks.  if dayOfMonth

[Haskell-cafe] How to deal with huge text file?

2010-05-24 Thread Magicloud Magiclouds
Hi, I have a file including some operation logs, in the format of the following. And I have some code to analyze it. Well, it ate all my memories. --- log: Log for item A === 09:10 read accountA 09:20 read accountB Log for item B --- code: file - U.readFile filename mapM_

Re: [Haskell-cafe] How to deal with huge text file?

2010-05-24 Thread Magicloud Magiclouds
U is for UTF8 module. And I will try the modules you mentioned. Although I thought Haskell IO is lazy enough On Tue, May 25, 2010 at 9:46 AM, Ivan Miljenovic ivan.miljeno...@gmail.com wrote: On 25 May 2010 11:41, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  I have

Re: [Haskell-cafe] How to deal with huge text file?

2010-05-24 Thread Magicloud Magiclouds
Miljenovic ivan.miljeno...@gmail.com wrote: On 25 May 2010 12:02, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: U is for UTF8 module. And I will try the modules you mentioned. Although I thought Haskell IO is lazy enough If you're only streaming data, it probably would

[Haskell-cafe] Problem when installing gtk2hs.

2010-05-26 Thread Magicloud Magiclouds
Hi, I have met similar problem before, and I do not know what to do. # cabal install --reinstall gtk2hs-buildtools Resolving dependencies... Configuring gtk2hs-buildtools-0.9... cabal: alex is required but it could not be found. cabal: Error: some packages failed to install: gtk2hs-buildtools-0.9

[Haskell-cafe] Re: [Gtk2hs-users] Problem when installing gtk2hs.

2010-05-27 Thread Magicloud Magiclouds
I only have one alex installed under ~/.cabal/bin. It seems working with shell environment, but not cabal. On Thu, May 27, 2010 at 1:40 PM, Axel Simon axel.si...@in.tum.de wrote: Hi Magicloud, On May 27, 2010, at 4:11, Magicloud Magiclouds wrote: Hi, I have met similar problem before, and I

Re: [Haskell-cafe] Re: [Gtk2hs-users] Problem when installing gtk2hs.

2010-05-27 Thread Magicloud Magiclouds
That might be it. However, I linked ~/.cabal/bin/* to /usr/local/bin And it worked. On Thu, May 27, 2010 at 3:24 PM, Ivan Miljenovic ivan.miljeno...@gmail.com wrote: On 27 May 2010 16:46, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: I only have one alex installed under

[Haskell-cafe] Fwd: [Gtk2hs-users] Installation problem with cairo.

2010-06-08 Thread Magicloud Magiclouds
: Tue, Jun 8, 2010 at 7:15 PM Subject: Re: [Gtk2hs-users] Installation problem with cairo. To: Magicloud Magiclouds magicloud.magiclo...@gmail.com Cc: gtk2hs-users gtk2hs-us...@lists.sourceforge.net Hi again, it's very difficult for me to say what is happening. Could you ask on the cabal mailing list

[Haskell-cafe] How to do this in FP way?

2008-06-15 Thread Magicloud Magiclouds
Hello, I am getting familiar with FP now, and I have a program design kind of question. Say I have something like this in C: static int old; int diff (int now) { /* this would be called once a second */ int ret = now - old; old = now; return ret; } Because there is no variable in

[Haskell-cafe] NetSnmp problem.

2009-10-22 Thread Magicloud Magiclouds
Hi, I am trying to use NetSnmp to get some information from my switch. And I met this problem. After initialize, I used snmpWalk to get some information, and dealed with it. Everything is fine. Then I sleep for 5 mins. SnmpWalk again. But this time, all asnValues were unsupported format, which

Re: [Haskell-cafe] NetSnmp problem.

2009-10-22 Thread Magicloud Magiclouds
Hi, The box is just 32bit with linux. But anyway, I will try out the update. Thanks. On Thu, Oct 22, 2009 at 11:35 PM, John Dorsey hask...@colquitt.org wrote:   I am trying to use NetSnmp to get some information from my switch. And I met this problem.   After initialize, I used snmpWalk to

Re: [Haskell-cafe] NetSnmp problem.

2009-10-22 Thread Magicloud Magiclouds
It works pretty well. On Fri, Oct 23, 2009 at 7:24 AM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  The box is just 32bit with linux. But anyway, I will try out the update. Thanks. On Thu, Oct 22, 2009 at 11:35 PM, John Dorsey hask...@colquitt.org wrote:   I am trying

[Haskell-cafe] TimeZone bug?

2009-10-23 Thread Magicloud Magiclouds
Hi, As we know, CST could mean both +8 or -6 time zone. So I got a problem. In the same envoironment. When a ZonedTime is shown, I got x CST. Now it means +8 time zone. Then I read it, stupidly, it turns into -6 time zone. How could I fix this? I am using ghc 6.10.4 in rhel 5. --

[Haskell-cafe] How come pattern match does not recognize this code style?

2009-10-25 Thread Magicloud Magiclouds
Hi, In case of this: case bala of [ bala , bala , bala ] - bala bala bala _ - bala ghc 6.10.4 would fail to compile, because of the wrong indent of line , bala. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] How come pattern match does not recognize this code style?

2009-10-25 Thread Magicloud Magiclouds
Ah, I see. The reason I have to use my style is the same as others: the list is too long On Mon, Oct 26, 2009 at 11:27 AM, Daniel Fischer daniel.is.fisc...@web.de wrote: Am Montag 26 Oktober 2009 03:39:13 schrieb Magicloud Magiclouds: Hi,   In case of this: case bala of   [ bala

[Haskell-cafe] How to fulfill the code-reuse destiny of OOP?

2009-10-29 Thread Magicloud Magiclouds
Hi, I think when people talk about OOP, especially the inheriting, their focus mainly is on functions (methods). My concern here is about the data member inheriting. In OOP, when I inherit a class, I also got the members of it. But in haskell, how to inherit a data? -- 竹密岂妨流水过 山高哪阻野云飞

Re: [Haskell-cafe] How to fulfill the code-reuse destiny of OOP?

2009-10-30 Thread Magicloud Magiclouds
On this subject, I think, any content inherit would lead to trouble somehow. But is that the reason that we should totally cut them loose? I mean the way of programming developing is easier making (writing), easier maintaining. In fact, I think this is a fork in front of me: Before any new

Re: [Haskell-cafe] How to fulfill the code-reuse destiny of OOP?

2009-10-31 Thread Magicloud Magiclouds
Somehow, I agree with you. I think inherit is not evil, the people use it wrong is. The problem here is, inherit is naked right now. So people could use it wrong. On Fri, Oct 30, 2009 at 7:42 PM, Yaakov Nemoy loupgaroubl...@gmail.com wrote: 2009/10/30 Peter Verswyvelen bugf...@gmail.com: The

Re: [Haskell-cafe] How to fulfill the code-reuse destiny of OOP?

2009-10-31 Thread Magicloud Magiclouds
...@btinternet.com: Rogan Creswick wrote: On Thu, Oct 29, 2009 at 6:54 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote:  My concern here is about the data member inheriting. In OOP, when I inherit a class, I also got the members of it. But in haskell, how to inherit a data

Re: [Haskell-cafe] How to fulfill the code-reuse destiny of OOP?

2009-11-01 Thread Magicloud Magiclouds
at 9:57 AM, Gregory Collins g...@gregorycollins.net wrote: Tom Davie tom.da...@gmail.com writes: On 10/31/09, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: After all, I never think OO as an oppsite way to all other things. The idea is so general that if you say I cannot use

[Haskell-cafe] How to convert records into Haskell structure in Haskell way?

2009-11-02 Thread Magicloud Magiclouds
Hi, Say I have something like this: [ Record { item = A1, value = 0 } , Record { item = B1, value = 13 } , Record { item = A2, value = 2 } , Record { item = B2, value = 10 } ] How to convert it into: [ XXInfo { name = A, value1 = 0, value2 = 2 } , XXInfo { name = B, value1 = 13, value2 = 10 }

[Haskell-cafe] Problem about hidden package again.

2009-11-11 Thread Magicloud Magiclouds
Hi, Today, when I compiled gtk2hs, I got this: cairo/Graphics/Rendering/Cairo.hs.pp:264:0: Failed to load interface for `Data.Array.Base': it is a member of the hidden package `array-0.2.0.0' Use -v to see a list of the files searched for. As usual, I searched for the

Re: [Haskell-cafe] Problem about hidden package again.

2009-11-12 Thread Magicloud Magiclouds
No, it is not. I used configure/make way. Well I just noticed that there is a hide-all-package options to ghc. I do not know why. Maybe the author went crazy. On Thu, Nov 12, 2009 at 5:09 PM, Magnus Therning mag...@therning.org wrote: On Thu, Nov 12, 2009 at 7:32 AM, Magicloud Magiclouds

Re: [Haskell-cafe] Problem about hidden package again.

2009-11-12 Thread Magicloud Magiclouds
, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: No, it is not. I used configure/make way. Well I just noticed that there is a hide-all-package options to ghc. I do not know why. Maybe the author went crazy. Chances are the auther DIDN'T go crazy :-) It's a common practice to hide

[Haskell-cafe] Could someone teach me why we use Data.Monoid?

2009-11-13 Thread Magicloud Magiclouds
Hi, I have looked the concept of monoid and something related, but still, I do not know why we use it? -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Could someone teach me why we use Data.Monoid?

2009-11-13 Thread Magicloud Magiclouds
helped! Regards, Rafael On Fri, Nov 13, 2009 at 14:14, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  I have looked the concept of monoid and something related, but still, I do not know why we use it? -- 竹密岂妨流水过 山高哪阻野云飞

Re: [Haskell-cafe] Could someone teach me why we use Data.Monoid?

2009-11-13 Thread Magicloud Magiclouds
That is OK. Since understand the basic concept of monoid (I mean the thing in actual math), the idea here is totally not hard for me. But the sample here does not show why (or how) we use it in programming, right? On Sat, Nov 14, 2009 at 12:48 AM, Stephen Tetley stephen.tet...@gmail.com wrote:

Re: [Haskell-cafe] Could someone teach me why we use Data.Monoid?

2009-11-13 Thread Magicloud Magiclouds
)  - ... 2009/11/13 Magicloud Magiclouds magicloud.magiclo...@gmail.com: Hi,  I have looked the concept of monoid and something related, but still, I do not know why we use it? -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe

Re: [Haskell-cafe] Re: Could someone teach me why we use Data.Monoid?

2009-11-13 Thread Magicloud Magiclouds
It is a great example, shows both howto and benefits. Thanks. 2009/11/14 Maurí­cio CA mauricio.antu...@gmail.com:  I have looked the concept of monoid and something related, but still, I do not know why we use it? I don't know if it's a good example, but it's simple. This package I wrote

Re: [Haskell-cafe] Could someone teach me why we use Data.Monoid?

2009-11-13 Thread Magicloud Magiclouds
A is just a newtype for A - A. More simply, dualization is flipping the binary operation, and the endo monoid is the monoid of functions a-a with composition. 2009/11/13 Magicloud Magiclouds magicloud.magiclo...@gmail.com: I see. Then what is about Dual and Endo? Especially Endo, I completely

[Haskell-cafe] How to deal with C buf in Haskell?

2009-12-07 Thread Magicloud Magiclouds
Hi, I am warping some C libs. In one function, I do this: 183 allocaBytes bufLen $ \buf - do 184ret - {# call buf_read #} 185 bluh 186 bala 187 buf 188 bufLen 189if ret 0 190 then userError bufRead error 191 else -- what should I do here? I am thinking

[Haskell-cafe] hackage.haskell.org cannot be accessed?

2010-08-12 Thread Magicloud Magiclouds
Hi, Today I found out that I cannot access hackage.haskell.org. I have tried vpn/proxy to see if my network has something wrong. No luck. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Wondering if this could be done.

2010-11-21 Thread Magicloud Magiclouds
Hi, For example, I have a data A defined. Then I want to add (+) and (-) operators to it, as a sugar (compared to addA/minusA). But * or other stuff defined in class Num is meanless to A. So I just do: (+) :: A - A - A (+) a b = A (elem1 a + elem1 b) (elem2 a + elem2 b) -- I got errors here,

[Haskell-cafe] How to instance class with functional dependency?

2010-11-24 Thread Magicloud Magiclouds
Hi, In System.Posix.IOCtl, there is such a class: class Storable d = IOControl req d | req - d where ioctlReqSource :: req - CInt How to instance it? I do it as: data TIOCGWINSZ = TIOCGWINSZ #starttype struct winsize #field ws_row , CUShort #field ws_col , CUShort #field ws_xpixel , CUShort

[Haskell-cafe] haskell2010 and state question.

2010-12-08 Thread Magicloud Magiclouds
Hi, Formerly, I had IORef and some state monad to do the task of keeping states. Now in haskell 2010, I cannot find anything about it. Do I have to use ghc base package for this function? -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] haskell2010 and state question.

2010-12-09 Thread Magicloud Magiclouds
On Wed, Dec 8, 2010 at 6:46 PM, Henk-Jan van Tuyl hjgt...@chello.nl wrote: On Wed, 08 Dec 2010 10:03:40 +0100, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  Formerly, I had IORef and some state monad to do the task of keeping states.  Now in haskell 2010, I cannot find

[Haskell-cafe] Cabal message problem.

2010-12-15 Thread Magicloud Magiclouds
Hi, I see this kind of information a lot when I using cabal to install package. Or sometimes same packages both exist in global and user space, which is a shadowed by message. How to resolve that? Thanks. Resolving dependencies... command line: cannot satisfy -package Cabal-1.10.0.0:

Re: [Haskell-cafe] Cabal message problem.

2010-12-15 Thread Magicloud Magiclouds
On Thu, Dec 16, 2010 at 10:55 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 16 December 2010 13:35, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  I see this kind of information a lot when I using cabal to install package. Or sometimes same packages both exist

Re: [Haskell-cafe] Cabal message problem.

2010-12-15 Thread Magicloud Magiclouds
On Thu, Dec 16, 2010 at 2:24 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: On Thu, Dec 16, 2010 at 10:55 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 16 December 2010 13:35, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  I see this kind

Re: [Haskell-cafe] Cabal message problem.

2010-12-15 Thread Magicloud Magiclouds
On Thu, Dec 16, 2010 at 2:59 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 16 December 2010 17:26, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: And, sure, I could reinstall Cabal. Then things seem fine. But it is weird. I have to have the same packages installed

Re: [Haskell-cafe] Cabal message problem.

2010-12-15 Thread Magicloud Magiclouds
On Thu, Dec 16, 2010 at 3:48 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 16 December 2010 18:30, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: On Thu, Dec 16, 2010 at 2:59 PM, Ivan Lazar Miljenovic For example, now I have message as this when installing darcs

Re: [Haskell-cafe] Cabal message problem.

2010-12-16 Thread Magicloud Magiclouds
On Thu, Dec 16, 2010 at 3:56 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: On Thu, Dec 16, 2010 at 3:48 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 16 December 2010 18:30, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: On Thu, Dec 16, 2010 at 2

Re: [Haskell-cafe] Cabal message problem.

2010-12-16 Thread Magicloud Magiclouds
On Thu, Dec 16, 2010 at 4:07 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 16 December 2010 19:06, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Oh, clean job around ~/.ghc and ~/.cabal has been done. No luck. Sounds like a dodgy GHC install then; I believe lispy

[Haskell-cafe] syb-with-class problem.

2010-12-16 Thread Magicloud Magiclouds
Hi, I am trying to make happstack work in my box, which is using ghc 7. While compiling HStringTemplate, which I did a little modification to make it work, I found that it does not work with template-haskell-2.5.0.0. I changed it to use template-haskell-2.4.0.1. This step worked fine. Then I

Re: [Haskell-cafe] syb-with-class problem.

2010-12-16 Thread Magicloud Magiclouds
? What error were you getting? Antoine On Thu, Dec 16, 2010 at 6:23 AM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  I am trying to make happstack work in my box, which is using ghc 7.  While compiling HStringTemplate, which I did a little modification to make it work, I

Re: [Haskell-cafe] syb-with-class problem.

2010-12-16 Thread Magicloud Magiclouds
is now on Hackage, and should work properly with ghc 7, I think. Cheers, Sterl. On Dec 16, 2010, at 6:21 PM, Magicloud Magiclouds wrote: On Thu, Dec 16, 2010 at 9:15 PM, Antoine Latter aslat...@gmail.com wrote: Hi there, The only version of template haskell which will work is the version

[Haskell-cafe] What is NoPush module?

2010-12-16 Thread Magicloud Magiclouds
Hi, When I compiling happstack with ghc 7, I got an error: src/Happstack/Server/Internal/Handler.hs:29:8: Could not find module `NoPush': Use -v to see a list of the files searched for. I looked around, there is no clue for the module NoPush, except it has a function call withNoPush.

Re: [Haskell-cafe] What is NoPush module?

2010-12-16 Thread Magicloud Magiclouds
that :( - jeremy On Dec 16, 2010, at 8:02 PM, Magicloud Magiclouds wrote: Hi,  When I compiling happstack with ghc 7, I got an error: src/Happstack/Server/Internal/Handler.hs:29:8:   Could not find module `NoPush':     Use -v to see a list of the files searched for.  I looked around

[Haskell-cafe] UTF-8 in Haskell.

2010-12-22 Thread Magicloud Magiclouds
Hi, Recently, I am reading ssh hackage (http://hackage.haskell.org/package/ssh). When at the part of deal with string, I got confused. I am not sure if this is a bug for the hackage, or I am just misunderstanding. An ascii char takes a Word8. So this works (LBS stands for

Re: [Haskell-cafe] UTF-8 in Haskell.

2010-12-22 Thread Magicloud Magiclouds
On Thu, Dec 23, 2010 at 2:01 PM, Mark Lentczner ma...@glyphic.com wrote: On Dec 22, 2010, at 9:29 PM, Magicloud Magiclouds wrote: Thus under all situation (ascii, UTF-8, or even UTF-32), my program always send 4 bytes through the network. Is that OK? Generally, no. Haskell strings

Re: [Haskell-cafe] UTF-8 in Haskell.

2010-12-26 Thread Magicloud Magiclouds
: On 23 December 2010 05:29, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote:  If so, OK, then I think I could make a packInt which turns an Int into 4 Word8 first. Thus under all situation (ascii, UTF-8, or even UTF-32), my program always send 4 bytes through the network. Is that OK? I

Re: [Haskell-cafe] UTF-8 in Haskell.

2010-12-26 Thread Magicloud Magiclouds
useful than a ByteString for almost all purposes. If I allready had a ByteString, the only reason I would want to convert it to a CString is to call a C function. Take care, Antoine On Sun, Dec 26, 2010 at 7:40 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Thanks for the ideas

[Haskell-cafe] How to instance MonadIO Identity?

2010-12-27 Thread Magicloud Magiclouds
Hi, From another thread in this list, I got code as: instance MonadIO Identity where liftIO = id Well, it does not work for me as: Message.hs:22:12: Couldn't match expected type `Identity a' with actual type `IO a' Expected type: IO a - Identity a Actual type: IO a - IO a

Re: [Haskell-cafe] How to instance MonadIO Identity?

2010-12-27 Thread Magicloud Magiclouds
...@snoyman.com: The only way to create such an instance would be with unsafePerformIO, which in this case would be a Very Bad Idea (tm). Michael On Tue, Dec 28, 2010 at 7:29 AM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  From another thread in this list, I got code

Re: [Haskell-cafe] How to instance MonadIO Identity?

2010-12-27 Thread Magicloud Magiclouds
none of these types involve IO, then liftIO can't be used. Antoine On Tue, Dec 28, 2010 at 12:47 AM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote:  Ah, that is a bad news.  I am using Control.Monad.Writer and Data.Encoding. Code like (not compilable) 43|instance WithMessage

[Haskell-cafe] How to make such code?

2010-12-29 Thread Magicloud Magiclouds
Hi, In Haskell's way, normally, we write: if condition then expression_true else expression_false But I just heard that, in fancy way, we could do: do ifNeedToDo doIt bluh May I have any clue here? -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe

[Haskell-cafe] Problem on overlapping instances

2011-01-05 Thread Magicloud Magiclouds
Hi, I am using Data.Binary which defined instance Binary a = Binary [a]. Now I need to define instance Binary [String] to make something special for string list. How to make it work? I looked into the chapter of overlappinginstances, nothing works. -- 竹密岂妨流水过 山高哪阻野云飞

Re: [Haskell-cafe] Problem on overlapping instances

2011-01-05 Thread Magicloud Magiclouds
Steffen Schuldenzucker: Sure. GHC would prompt that. Jasper Van der Jeugt: Not working with ghc7. But there sure are some threads about this kind of things. I do not know if this is a bug of 6.* or 7, either. Luke Palmer: Sorry, by special, I meant, for example, [a, b] will be ab by

Re: [Haskell-cafe] Problem on overlapping instances

2011-01-07 Thread Magicloud Magiclouds
at the source for the instances of the 'Binary' class for inspiration! Take care, Antoine On Wed, Jan 5, 2011 at 2:24 AM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  I am using Data.Binary which defined instance Binary a = Binary [a]. Now I need to define instance Binary

[Haskell-cafe] Wondering about networking programming in Haskell.

2011-01-19 Thread Magicloud Magiclouds
Hi, Originally, my idea for networking programming is like: read some bytes, judge if this is enough for a packet (defined in certain protocol), if not, read more until the packet is complete, then parse it into a message. Now we have lazy in Haskell. Can I do it as: buffer - hGetContents

[Haskell-cafe] How to convert DiffTime to a number?

2009-06-07 Thread Magicloud Magiclouds
Hi, Documents said that DiffTime could treat as how many seconds. So how to convert it to a number of seconds? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Re: How to convert DiffTime to a number?

2009-06-07 Thread Magicloud Magiclouds
Ah, floor $ toRational dt. On Mon, Jun 8, 2009 at 1:09 PM, Magicloud Magicloudsmagicloud.magiclo...@gmail.com wrote: Hi,  Documents said that DiffTime could treat as how many seconds. So how to convert it to a number of seconds? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 -- 竹密岂妨流水过 山高哪阻野云飞

[Haskell-cafe] How to know the build dependencies?

2009-06-13 Thread Magicloud Magiclouds
Hi, I am learning to use cabal for my code. Just when I start, I met a question, is there an easy way to find out what packages my code depends? Thanks. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] [cabal] How to deal with build-depency that not under cabal's control?

2009-06-14 Thread Magicloud Magiclouds
Hi, I use gtk2hs in linux. Well, I have no idea how to install gtk2hs by cabal, but my program needs it, and I want my program cabalized. So how to do this? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Could someone give me a sample about haskelldb?

2009-06-18 Thread Magicloud Magiclouds
Hi, I am learning it following the very few documents on its site. Well, I failed, with the import modules, I still cannot compile it. The error is on T.*. 6 import Database.HaskellDB.HDBC.SQLite3 7 import Database.HaskellDB 8 import Database.HaskellDB.DBSpec 9 import

[Haskell-cafe] Re: Could someone give me a sample about haskelldb?

2009-06-19 Thread Magicloud Magiclouds
I changed it, some other problem occured. 1. How to compare a BoolT column to a True? t!c .. True could not work. 2. What shoud I use after !? Like table!col, recordset!col, what is col? Thanks. On Fri, Jun 19, 2009 at 1:24 PM, Magicloud Magicloudsmagicloud.magiclo...@gmail.com wrote: Hi,  I am

[Haskell-cafe] haskelldb + sqlite problem.

2009-06-21 Thread Magicloud Magiclouds
Hi, I am using haskelldb and haskelldb-hdbc-sqlite3. Well, I finally got the source compiled and ran, I got this error: App: user error (SQL error: SqlError {seState = , seNativeError = 21, seErrorMsg = prepare 74: SELECT subject,\n timestamp\nFROM notes as T1\nORDER BY timestamp DESC:

[Haskell-cafe] Weird thing happened when I use gtk2hs with concurrent.

2009-06-24 Thread Magicloud Magiclouds
This is the weird code, please see line 61. 20 cpuNew :: IO CPU 21 cpuNew = do 22   self - meterNew 23   usage - newIORef $ CPUusage 0 0 0 0 0 0 0 0 24   self `on` realize $ do 25     forkIO $ redraw self usage 33     return () 34   return self 35   where 56     redraw self usage = do 57      

[Haskell-cafe] How to read safely?

2009-06-24 Thread Magicloud Magiclouds
Hi, Read often throws runtime errors, which breaks the robust of the problem. How to deal with it? Without lost too much proformance (so reads is a no). At least, if its error could be catched, that'd be better. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe

[Haskell-cafe] How to fork a process?

2009-06-25 Thread Magicloud Magiclouds
Hi, In many language, both thread and process are supported. But in haskell's document, the only thing I could find called fork is to make a thread. So how to fork the program itself, like fork () in C? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe

[Haskell-cafe] How to convert CPid to Word32?

2009-06-28 Thread Magicloud Magiclouds
Hi, I am trying to use Data.Binary with ProcessID. Well, how to convert between CPid and Word32? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Wondering about c type in haskell.

2009-06-29 Thread Magicloud Magiclouds
Hi, There are times, when we need to make some system calls, or call C library. So we have to deal with C data types. For example, CPid, which is an integer, actually. So we can do fromIntegral pid. Then why do not we define type CPid = Integer, and convert Haskell Integer with C Int

Re: [Haskell-cafe] Re: Wondering about c type in haskell.

2009-06-29 Thread Magicloud Magiclouds
need to convert, convert, convert. And, let say using Integer for pid is insane. Then if I do not convert it into Integer, when serialised, I have to point out with Word32/Word64, which is definitely bad. On Tue, Jun 30, 2009 at 11:01 AM, Ahn, Ki Yungkya...@gmail.com wrote: Magicloud Magiclouds 쓴

Re: [Haskell-cafe] Wondering about c type in haskell.

2009-06-29 Thread Magicloud Magiclouds
That is true. But I think we could avoid (or resolve) the problem of wrong type thing in other ways, or we just resolve one thing by typing much more code. On Tue, Jun 30, 2009 at 11:37 AM, Jason Dagitda...@codersbase.com wrote: On Mon, Jun 29, 2009 at 7:01 PM, Magicloud Magiclouds

[Haskell-cafe] How to present the commonness of some objects?

2009-07-02 Thread Magicloud Magiclouds
Hi, I thought class was for this purpose. But it turns out not. Code as following could not compiled. 1 main = do 2 mapM_ (\(x, y, widget) - do 3a - widgetRun widget 4putStrLn $ show a 5 ) widgetList 6 7 widgetList :: (Widget w) = [(Integer, Integer, w)] 8

Re: [Haskell-cafe] How to present the commonness of some objects?

2009-07-02 Thread Magicloud Magiclouds
: ++)) ] Before, without existential quantification, you had to have all the same type of widget (e.g. all Button or all Label) Hope this makes it more clear. -Ross On Jul 3, 2009, at 12:00 AM, Magicloud Magiclouds wrote: Hi,  I thought class was for this purpose. But it turns out not.  Code

[Haskell-cafe] Why this cannot be compiled?

2009-07-13 Thread Magicloud Magiclouds
Hi, The following code failed to compiled, with error: Attribute.hs:46:91: Couldn't match expected type `[t]' against inferred type `(a, String)' In the expression: (color_, rest_) In a case alternative: [(color_, rest_)] - (color_, rest_) In the expression:

Re: [Haskell-cafe] Why this cannot be compiled?

2009-07-13 Thread Magicloud Magiclouds
Hum I must lost my mind Thank you. On Mon, Jul 13, 2009 at 3:33 PM, Ketil Maldeke...@malde.org wrote: Magicloud Magiclouds magicloud.magiclo...@gmail.com writes:  43 instance Read Attribute where  44   readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) - lex str  45

[Haskell-cafe] How to Read this?

2009-07-13 Thread Magicloud Magiclouds
Hi, I have a data structure, which shows like this: AttrBgColor {bgColor = Color 0 0 0} And the following is my Read code. But it failed parsing 31 instance Read Attribute where 32 readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) - lex str 33

[Haskell-cafe] Pattern matching does not work like this?

2009-07-15 Thread Magicloud Magiclouds
Hi, I do not notice this before. fun ([0, 1] ++ xs) = .. in my code could not be compiled, parse error. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Is there a sample code for hdbus?

2009-07-27 Thread Magicloud Magiclouds
Hi, Although I have used dbus with ruby a little, but still, I do not understand hdbus's APIs Is there any sample that I could learn? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] runProcess does not care about hSetBuffering?

2009-07-28 Thread Magicloud Magiclouds
Hi, Code like: (or_, ow_) - createPipe or - fdToHandle or_ ow - fdToHandle ow_ hSetBuffering ow LineBuffering hSetBuffering or LineBuffering h - runProcess cmd [] Nothing Nothing Nothing (Just ow) Nothing In the cmd process, the ow is not LineBuffering -- 竹密岂妨流水过 山高哪阻野云飞

[Haskell-cafe] Problem on existential type.

2009-09-04 Thread Magicloud Magiclouds
Hi, I am trying out existential type, some sample code works well. Well, my own code could not be compiled with message: Grid.hs:45:11: Kind error: `GridWidget' is applied to too many type arguments In the type `GridWidget widget' In the type `(GridWidget widget) - (widget - t) - t'

[Haskell-cafe] How to generate the .chi file for c2hs?

2009-09-07 Thread Magicloud Magiclouds
Hi, I want to make a binding of a gtk function, which returns a X11 type. gtk2hs is made by c2hs, which is OK to give me the .chi file. Well, X11 is not. So if I make my binding c2hs style, I have to make a .chi file for X11 myself. How to do it? -- 竹密岂妨流水过 山高哪阻野云飞

Re: [Haskell-cafe] Problem on existential type.

2009-09-07 Thread Magicloud Magiclouds
Thank you all guys. This explained so much. On Sun, Sep 6, 2009 at 2:53 AM, Ryan Ingramryani.s...@gmail.com wrote: On Thu, Sep 3, 2009 at 11:05 PM, Magicloud Magicloudsmagicloud.magiclo...@gmail.com wrote: data GridWidget = forall widget. (WidgetClass widget) = GridWidget widget liftGW ::

[Haskell-cafe] Re: How to generate the .chi file for c2hs?

2009-09-07 Thread Magicloud Magiclouds
Hum, seems like the c2hs in gtk2hs is a non-standard version, and the chi it gives could not be used by c2hs (nor can standard c2hs used in gtk2hs's compiling) On Mon, Sep 7, 2009 at 4:45 PM, Magicloud Magicloudsmagicloud.magiclo...@gmail.com wrote: Hi,  I want to make a binding of a gtk

[Haskell-cafe] How to decide if a number is an integer?

2009-09-28 Thread Magicloud Magiclouds
Hi, In other weak-type language, `round i == i` would work. But in haskell, what should I do? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Re: How to decide if a number is an integer?

2009-09-29 Thread Magicloud Magiclouds
Hi, Here is an example: let l = fun num in if isIntegral l then l else 0 How to do the isIntegral thing? On Tue, Sep 29, 2009 at 1:58 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  In other weak-type language, `round i == i` would work. But in haskell, what

Re: [Haskell-cafe] How to decide if a number is an integer?

2009-09-29 Thread Magicloud Magiclouds
It never matches to (_, 0.0) I mean case properFraction l of (_, 0) - l _ - 0 -- always goes here. On Tue, Sep 29, 2009 at 2:18 PM, Jimmy Hartzell j...@shareyourgifts.net wrote: Use properFraction: http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AproperFraction

Re: [Haskell-cafe] How to decide if a number is an integer?

2009-09-29 Thread Magicloud Magiclouds
, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: It never matches to (_, 0.0) I mean case properFraction l of  (_, 0) - l  _ - 0 -- always goes here. Odd, it works fine for me. f x =        case properFraction x of                (_,0) - True                _     - False *Main

Re: [Haskell-cafe] How to decide if a number is an integer?

2009-09-29 Thread Magicloud Magiclouds
, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: The original code is givenSum num = map (\a -                      let l = (sqrt $ fromIntegral (a * a + 2 + 2 * num)) - (fromIntegral a) in                      case properFraction l of                        (_, 0

Re: [Haskell-cafe] How to decide if a number is an integer?

2009-09-29 Thread Magicloud Magiclouds
wrote: On Mon, Sep 28, 2009 at 11:35 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: It never matches to (_, 0.0) I mean case properFraction l of  (_, 0) - l  _ - 0 -- always goes here. Odd, it works fine for me. f x =        case properFraction x of                (_,0

Re: [Haskell-cafe] How to decide if a number is an integer?

2009-09-29 Thread Magicloud Magiclouds
thomas.dubuis...@gmail.com wrote: On Mon, Sep 28, 2009 at 11:35 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: It never matches to (_, 0.0) I mean case properFraction l of  (_, 0) - l  _ - 0 -- always goes here. Odd, it works fine for me. f x =        case

[Haskell-cafe] Does gtk2hs support VTE?

2009-02-16 Thread Magicloud Magiclouds
Hi, I always see a file named vte something in doc folder, but I never see vte in reference or source. So I wonder if gtk2hs actually supports VTE. And I'd like to have that supporting -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list

  1   2   3   >