[Haskell-cafe] Haskell Weekly News: Issue 235

2012-07-11 Thread Daniel Santa Cruz
Welcome to issue 235 of the HWN, an issue covering crowd-sourced bits
of information about Haskell from around the web. This issue covers the
week of July 1 to 7, 2012.

Quotes of the Week

   * Kukkua: They say there are two things, once mastered, you will
 harness boundless strength from the cosmos itself, continuations
 and monads.

   * startling: saying "monad" within earshot of a muggle is pretty
 funny

   * maybefbi: Haskell is forcing me to think a lot

   * Wadler says: So, the essence of XML is this: the problem it solves
 is not hard, and it does not solve the problem well.

Top Reddit Stories

   * This is what my first attempt at writing code in Haskell went like
 Domain: self.haskell, Score: 82, Comments: 32
 On Reddit: [1] http://goo.gl/uq3Tt
 Original: [2] http://goo.gl/uq3Tt

   * The Architecture of Open Source Applications:
 The Glasgow Haskell Compiler
 Domain: aosabook.org, Score: 59, Comments: 5
 On Reddit: [3] http://goo.gl/5v906
 Original: [4] http://goo.gl/yYqUJ

   * Slides for 7 lectures on Parallel and Concurrent Haskell
 (including GPU programming with Accelerate)
 Domain: community.haskell.org, Score: 51, Comments: 10
 On Reddit: [5] http://goo.gl/pmGsr
 Original: [6] http://goo.gl/wumiT

   * How pythoners view Haskell compared with Python
 Domain: wiki.python.org, Score: 40, Comments: 70
 On Reddit: [7] http://goo.gl/Xe3AF
 Original: [8] http://goo.gl/ydpyj

   * How I made the switch to functional programming.
 Domain: self.haskell, Score: 38, Comments: 14
 On Reddit: [9] http://goo.gl/m6IXs
 Original: [10] http://goo.gl/m6IXs

   * Why Functional Matters: Your white board will never be the same
 Domain: blog.jessitron.com, Score: 35, Comments: 5
 On Reddit: [11] http://goo.gl/b71zi
 Original: [12] http://goo.gl/SkJaA

   * Building a better AES package
 Domain: tab.snarc.org, Score: 33, Comments: 19
 On Reddit: [13] http://goo.gl/A0hwE
 Original: [14] http://goo.gl/0p9PE

   * FP Complete is hiring Haskell programmers
 Domain: haskellers.com, Score: 32, Comments: 4
 On Reddit: [15] http://goo.gl/L8Xuh
 Original: [16] http://goo.gl/6AxT7

   * Parallel and Concurrent Programming in Haskell
 (Lab exercises by Simon Marlow)
 Domain: community.haskell.org, Score: 31, Comments:
 On Reddit: [17] http://goo.gl/cjBJ0
 Original: [18] http://goo.gl/olFva

   * pipes 2.1 released with prettier Frame,
 using indexed and restricted monads
 Domain: haskellforall.com, Score: 30, Comments: 31
 On Reddit: [19] http://goo.gl/Trajz
 Original: [20] http://goo.gl/vqluc

   * conduit 0.5.0 released, now with extensive tutorial
 Domain: hackage.haskell.org, Score: 27, Comments: 2
 On Reddit: [21] http://goo.gl/s5Wmh
 Original: [22] http://goo.gl/RUrpw

   * A (experimental) treat for Emacs interactive-mode users
 Domain: youtube.com, Score: 26, Comments: 2
 On Reddit: [23] http://goo.gl/13wD9
 Original: [24] http://goo.gl/C54V5

   * Exploring CPU design using Haskell - Introduction to the architecture
 Domain: random.axman6.com, Score: 25, Comments: 17
 On Reddit: [25] http://goo.gl/f1v2M
 Original: [26] http://goo.gl/xvSUF

   * Haskell is dead! (pun intended, not a flame :D)
 Domain: i.imgur.com, Score: 22, Comments: 37
 On Reddit: [27] http://goo.gl/jPRu9
 Original: [28] http://goo.gl/2DclX

   * Announcing lens-family-core, lens-family, and lens-family-th
 Domain: self.haskell, Score: 22, Comments: 8
 On Reddit: [29] http://goo.gl/Axyxs
 Original: [30] http://goo.gl/Axyxs

   * Happstack Irregular News Issue #2
 Domain: happstack.com, Score: 21, Comments: 3
 On Reddit: [31] http://goo.gl/n7a0Z
 Original: [32] http://goo.gl/kU7OV

   * "Tying the Knot" using the RWS Monad
 Domain: mergeconflict.com, Score: 21, Comments: 16
 On Reddit: [33] http://goo.gl/FavKj
 Original: [34] http://goo.gl/TESiO

   * LiveScript: a more functional JavaScript
 Domain: gkz.github.com, Score: 18, Comments: 9
 On Reddit: [35] http://goo.gl/NQecG
 Original: [36] http://goo.gl/1hsTo

Top StackOverflow Questions

   * Functional design patterns
 votes: 36, answers: 5
 Read on SO: [37] http://goo.gl/hjzwm

   * Using return vs. not using return in the list monad
 votes: 22, answers: 6
 Read on SO: [38] http://goo.gl/zkQH1

   * Compute as much of a list as possible in a fixed time
 votes: 19, answers: 3
 Read on SO: [39] http://goo.gl/BpBFe

   * Why is `logBase 10 x` slower than `log x / log 10`,
 even when specialized?
 votes: 16, answers: 2
 Read on SO: [40] http://goo.gl/4rkTi

   * How has Haskell changed?
 votes: 16, answers: 2
 Read on SO: [41] http://goo.gl/Rkz41

   * What are the similarities and differences among Haskell indentation
 modes for Emacs?
 votes: 16, answers: 0
 Read on SO: [42] http://goo.gl/xH

Re: [Haskell-cafe] What is the difference between runhaskell and compile?

2012-07-11 Thread Magicloud Magiclouds
Dug a little more. Seems that ghc 7.4.* finalizes (ldap_unbind action)
the ldap ptr before the references were actually dropped.

On Thu, Jul 12, 2012 at 9:41 AM, Magicloud Magiclouds
 wrote:
> Sorry for the attachments. They are wireshark files.
>
> On Thu, Jul 12, 2012 at 9:35 AM, Magicloud Magiclouds
>  wrote:
>> OK. Finally this problem totally prevents my project from working.
>> By some guy's suggestion, I did a packet capturing, which really
>> showed a difference.
>> The rwdc file is for a ldap that at our IDC, which did not work with
>> compiled binary. The rodc file is for a ldap that at local, which
>> worked all the time. Each file contains two parts of records, at 3.*
>> sec and 6/7.* sec. The 3.* part is for runhaskell way. The 6/7.* part
>> is for compiled binary way.
>> The big difference here is: the failed one sent unbindRequest before
>> got bindResponse success.
>> Just a clue, I have no idea what is going on
>>
>> On Fri, Jun 1, 2012 at 5:17 PM, Chris Dornan  wrote:
>>> No problem -- I have attached the executable too.
>>>
>>> Chris
>>>
>>> -Original Message-
>>> From: Magicloud Magiclouds [mailto:magicloud.magiclo...@gmail.com]
>>> Sent: 01 June 2012 02:01
>>> To: Chris Dornan
>>> Subject: Re: [Haskell-cafe] What is the difference between runhaskell and 
>>> compile?
>>>
>>> I see.
>>> Although I am using a UTF-8 environment, but all string I was using were 
>>> ASCIIs.
>>> If it is not too much trouble, may I have your LDAP compiled library files? 
>>> I think since the Main.o is identical, maybe the libraries are different.
>>>
>>> On Thu, May 31, 2012 at 2:09 PM, Chris Dornan  wrote:
 I wouldn't pay too much attention to the fact that the hash tags are
 different -- they are very unlikely to be the same across two
 installations. (For example, my GHC installations are relocated under
 /usr/hs, immediately changing the contents of all of the .conf files
 and therefore the hashes.)

 The object files are more interesting, and they are identical!

 At the moment I can only explain what we are seeing by assuming that some 
 change has affected the GHC 7.4.1 runtime system -- but only for compiled 
 programs.

 Are you using non-ASCII characters in your LDAP passwords? I am thinking 
 that maybe the compiled 7.4.1 could be using a different LOCALE from 
 everything else, leading in some way to the passwords being encoded 
 differently en route to the LDAP server. I don't know whether this could 
 actually happen, but it is the kind of mechanism that seem most likely to 
 be causing the problem.

 Did you try to running the variants that read address, account and 
 passwords from standard input? Did it show the same perverse behaviour?

 Chris





 -Original Message-
 From: Magicloud Magiclouds [mailto:magicloud.magiclo...@gmail.com]
 Sent: 31 May 2012 02:47
 To: Chris Dornan
 Subject: Re: [Haskell-cafe] What is the difference between runhaskell and 
 compile?

 Hi,
  I have compared the files. The .o-es are exactly the same. The .hi-s are 
 different.
  The interface hash, flag hash, and "import  -/ LDAP-0.6.6:LDAP.Constants 
 x(hash)" are different.
  I do not know why only this module (LDAP.Constants) has a different hash. 
 I am not quite familiar with ghc compiling process. May I know your 
 conclusion?

 On Wed, May 30, 2012 at 3:50 PM, Chris Dornan  
 wrote:
> Did you carry out a standard (optimised) build to get ghc-7.4.1?
>
> Are you going to try the justhub rpms or compare the object/header files 
> I sent.
>
> Chris
>
> -Original Message-
> From: Magicloud Magiclouds [mailto:magicloud.magiclo...@gmail.com]
> Sent: 30 May 2012 04:07
> To: Chris Dornan
> Cc: Haskell-Cafe
> Subject: Re: [Haskell-cafe] What is the difference between runhaskell and 
> compile?
>
> A little information.
> I did not notice the gcc/binutils versions. But in CentOS, the ghc
> 7.2.2/7.4.1 were all compiled myself with all default configurations.
>
> On Tue, May 29, 2012 at 10:54 PM, Chris Dornan  
> wrote:
>> On 29 May 2012 02:21, Magicloud Magiclouds
>>  wrote:
>>> Interesting. I have this code tested in Debian unstable/stable,
>>> CentOS 6.1, all 64 bit, with two different version of libldap2.
>>> At first, Debian-s were installed with 7.4.1, CentOS with 7.2.2.
>>> Only in CentOS the code connected after compiled.
>>> Then I removed 7.4.1 from Debian stable and installed 7.2.2. The code 
>>> worked.
>>> At last, I installed 7.4.1 in CentOS. The code did not work.
>>>
>>> Could you send the .hi/.o to me, so maybe I could find out the
>>> different? Also the exact original source.
>>> Thank you.
>>
>> Interesting indeed! I am guessing that you are u

Re: [Haskell-cafe] What is the difference between runhaskell and compile?

2012-07-11 Thread Magicloud Magiclouds
OK. Finally this problem totally prevents my project from working.
By some guy's suggestion, I did a packet capturing, which really
showed a difference.
The rwdc file is for a ldap that at our IDC, which did not work with
compiled binary. The rodc file is for a ldap that at local, which
worked all the time. Each file contains two parts of records, at 3.*
sec and 6/7.* sec. The 3.* part is for runhaskell way. The 6/7.* part
is for compiled binary way.
The big difference here is: the failed one sent unbindRequest before
got bindResponse success.
Just a clue, I have no idea what is going on

On Fri, Jun 1, 2012 at 5:17 PM, Chris Dornan  wrote:
> No problem -- I have attached the executable too.
>
> Chris
>
> -Original Message-
> From: Magicloud Magiclouds [mailto:magicloud.magiclo...@gmail.com]
> Sent: 01 June 2012 02:01
> To: Chris Dornan
> Subject: Re: [Haskell-cafe] What is the difference between runhaskell and 
> compile?
>
> I see.
> Although I am using a UTF-8 environment, but all string I was using were 
> ASCIIs.
> If it is not too much trouble, may I have your LDAP compiled library files? I 
> think since the Main.o is identical, maybe the libraries are different.
>
> On Thu, May 31, 2012 at 2:09 PM, Chris Dornan  wrote:
>> I wouldn't pay too much attention to the fact that the hash tags are
>> different -- they are very unlikely to be the same across two
>> installations. (For example, my GHC installations are relocated under
>> /usr/hs, immediately changing the contents of all of the .conf files
>> and therefore the hashes.)
>>
>> The object files are more interesting, and they are identical!
>>
>> At the moment I can only explain what we are seeing by assuming that some 
>> change has affected the GHC 7.4.1 runtime system -- but only for compiled 
>> programs.
>>
>> Are you using non-ASCII characters in your LDAP passwords? I am thinking 
>> that maybe the compiled 7.4.1 could be using a different LOCALE from 
>> everything else, leading in some way to the passwords being encoded 
>> differently en route to the LDAP server. I don't know whether this could 
>> actually happen, but it is the kind of mechanism that seem most likely to be 
>> causing the problem.
>>
>> Did you try to running the variants that read address, account and passwords 
>> from standard input? Did it show the same perverse behaviour?
>>
>> Chris
>>
>>
>>
>>
>>
>> -Original Message-
>> From: Magicloud Magiclouds [mailto:magicloud.magiclo...@gmail.com]
>> Sent: 31 May 2012 02:47
>> To: Chris Dornan
>> Subject: Re: [Haskell-cafe] What is the difference between runhaskell and 
>> compile?
>>
>> Hi,
>>  I have compared the files. The .o-es are exactly the same. The .hi-s are 
>> different.
>>  The interface hash, flag hash, and "import  -/ LDAP-0.6.6:LDAP.Constants 
>> x(hash)" are different.
>>  I do not know why only this module (LDAP.Constants) has a different hash. I 
>> am not quite familiar with ghc compiling process. May I know your conclusion?
>>
>> On Wed, May 30, 2012 at 3:50 PM, Chris Dornan  wrote:
>>> Did you carry out a standard (optimised) build to get ghc-7.4.1?
>>>
>>> Are you going to try the justhub rpms or compare the object/header files I 
>>> sent.
>>>
>>> Chris
>>>
>>> -Original Message-
>>> From: Magicloud Magiclouds [mailto:magicloud.magiclo...@gmail.com]
>>> Sent: 30 May 2012 04:07
>>> To: Chris Dornan
>>> Cc: Haskell-Cafe
>>> Subject: Re: [Haskell-cafe] What is the difference between runhaskell and 
>>> compile?
>>>
>>> A little information.
>>> I did not notice the gcc/binutils versions. But in CentOS, the ghc
>>> 7.2.2/7.4.1 were all compiled myself with all default configurations.
>>>
>>> On Tue, May 29, 2012 at 10:54 PM, Chris Dornan  
>>> wrote:
 On 29 May 2012 02:21, Magicloud Magiclouds
  wrote:
> Interesting. I have this code tested in Debian unstable/stable,
> CentOS 6.1, all 64 bit, with two different version of libldap2.
> At first, Debian-s were installed with 7.4.1, CentOS with 7.2.2.
> Only in CentOS the code connected after compiled.
> Then I removed 7.4.1 from Debian stable and installed 7.2.2. The code 
> worked.
> At last, I installed 7.4.1 in CentOS. The code did not work.
>
> Could you send the .hi/.o to me, so maybe I could find out the
> different? Also the exact original source.
> Thank you.

 Interesting indeed! I am guessing that you are using the GHC-7.4.1
 bindist from haskell.org.

 I will try and find some time to marshal the source code and
 intermediate files (am on the road -- will need to collect it from
 base, make it generic etc.).

 You might also like to try the http://justhub.org ghc-7.4.1-hub on
 your CentOS-6.1 node. It is a separate build from the haskell.org
 bindist and comes with it's own in-board gcc (4.6.1) and binutils
 (2.21) used for the build. It should work for you.

 (You could also try ghc-7.4.2-RC1-hub.)


Re: [Haskell-cafe] Bad interface problem.

2012-07-11 Thread Magicloud Magiclouds
But why it does not occur on other installation?

And Albert, I did not directly install QuickCheck. It was required by yesod.

On Wed, Jul 11, 2012 at 10:55 PM, Brandon Allbery  wrote:
> On Wed, Jul 11, 2012 at 5:28 AM, Magicloud Magiclouds
>  wrote:
>>
>> Even I removed all user space packages, the error was still. I think
>> it is a ghc pkg problem, that every package register itself as
>> package:function while ghc (or cabal?) required
>> package-version:function.
>
>
> That's not the problem, it's the symptom.  Package symbols are always
> versioned; ghc only shows the version when it's the only way to disambiguate
> symbols.
>
> So when it shows you a conflict where one is versioned and the other isn't,
> you have multiple versions of a package installed.
>
>>
>> But --constraint='template-haskell-2.7.0.0' did make it compiled.
>
>
> And that's how you prevent it.
>
> --
> brandon s allbery  allber...@gmail.com
> wandering unix systems administrator (available) (412) 475-9364 vm/sms
>



-- 
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] wondering about a MonadIO instance for a heap data type

2012-07-11 Thread Eugene Kirpichov
List is a monad because it has an associated way of sequencing
computations: namely, "collect results of the second computation
invoked on all results of the first computation". That's not because
List is a data structure (similarly to Heap), it's because it is
associated with the computational abstraction of computations with
multiple results. The heap data structure does not have an associated
computational abstraction, at least not that one I'm aware of, and
definitely not one that would make any sense in the context of
heapsort. So it doesn't make sense to pretend that it does.

On Wed, Jul 11, 2012 at 5:00 PM, Qi Qi  wrote:
> List [] is a monad, why not for heap data. Heap data could be an instance of
> Monad too.
> I have the heapsort function, and just wanted to rewrite a verbose version
> of it by using liftIO.
> But I would look into Debug.Trace. Thanks for your hint.
>
> Qi
>
>
> On Wednesday, July 11, 2012 5:28:17 PM UTC-5, Eugene Kirpichov wrote:
>>
>> Use Debug.Trace.
>> It does not make sense to declare that heap is a monad, as a monad is an
>> abstraction of sequencing computations, and a heap is not an abstraction of
>> sequencing computations at all. You don't make your String class implement
>> the "rendering engine" interface just because you want to use it in a
>> computer game program, equally you dont pretend that a heap is a way of
>> sequencing computations just because you want to sequence computations
>> related to heaps.
>>
>> The actual computation in your case is the heapsort function, not the
>> heap. If you absolutely must use IO, add IO to the functions type.
>>
>> 11.07.2012, в 15:19, Qi Qi  написал(а):
>>
>> > Hi,
>> >
>> > I was wondering about creating an instance of MonadIO for a heap data.
>> > Any hints?
>> >
>> > data Heap a = E | T Int a (Heap a) (Heap a)
>> > deriving (Eq, Ord, Read, Show)
>> >
>> > The reason is that I want to use liftIO during a heapsort to print out
>> > intermediate results.
>> >
>> > Thanks.
>> >
>> > Qi Qi
>> >
>> >
>> >
>> > ___
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe@haskell.org
>> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>> ___
>> Haskell-Cafe mailing list
>> Haskell-Cafe@haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Eugene Kirpichov
http://www.linkedin.com/in/eugenekirpichov

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] wondering about a MonadIO instance for a heap data type

2012-07-11 Thread Conrad Parker
On 12 July 2012 06:19, Qi Qi  wrote:
> Hi,
>
> I was wondering about creating an instance of MonadIO for a heap data.
> Any hints?
>
> data Heap a = E | T Int a (Heap a) (Heap a)
>  deriving (Eq, Ord, Read, Show)
>
> The reason is that I want to use liftIO during a heapsort to print out
> intermediate results.

If you just want this for debugging, you're probably better off using
Debug.Trace to print the intermediate results.

Conrad.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] wondering about a MonadIO instance for a heap data type

2012-07-11 Thread Brandon Allbery
On Wed, Jul 11, 2012 at 8:00 PM, Qi Qi  wrote:

> List [] is a monad, why not for heap data. Heap data could be an instance
> of Monad too.
>

Only if you can define a meaningful semantics for it.  Lists aren't a monad
because of liftIO, but because the monad pattern means something
(backtracking/multiple evaluation).  What does the monad pattern mean for
your heap?

I'm not saying there *isn't* one; I'm saying that you must *have* one in
order to make a monad.  Monads are not simply some sneaky way to slipstream
I/O into expressions; IO is just one possible monad, and many programs make
heavier use of other monads such as state and reader.  And in particular,
most applications of the list monad don't involve any I/O.  (Almost
necessarily, since the standard ListT is actually broken but can't be fixed
for backward compatibility reasons.)

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] wondering about a MonadIO instance for a heap data type

2012-07-11 Thread Qi Qi
List [] is a monad, why not for heap data. Heap data could be an instance 
of Monad too. 
I have the heapsort function, and just wanted to rewrite a verbose version 
of it by using liftIO.
But I would look into Debug.Trace. Thanks for your hint.

Qi

On Wednesday, July 11, 2012 5:28:17 PM UTC-5, Eugene Kirpichov wrote:
>
> Use Debug.Trace.
> It does not make sense to declare that heap is a monad, as a monad is an 
> abstraction of sequencing computations, and a heap is not an abstraction of 
> sequencing computations at all. You don't make your String class implement 
> the "rendering engine" interface just because you want to use it in a 
> computer game program, equally you dont pretend that a heap is a way of 
> sequencing computations just because you want to sequence computations 
> related to heaps.
>
> The actual computation in your case is the heapsort function, not the 
> heap. If you absolutely must use IO, add IO to the functions type.
>
> 11.07.2012, в 15:19, Qi Qi  написал(а):
>
> > Hi,
> > 
> > I was wondering about creating an instance of MonadIO for a heap data.
> > Any hints?
> > 
> > data Heap a = E | T Int a (Heap a) (Heap a)
> > deriving (Eq, Ord, Read, Show)
> > 
> > The reason is that I want to use liftIO during a heapsort to print out
> > intermediate results.
> > 
> > Thanks.
> > 
> > Qi Qi
> > 
> > 
> > 
> > ___
> > Haskell-Cafe mailing list
> > Haskell-Cafe@haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] wondering about a MonadIO instance for a heap data type

2012-07-11 Thread Eugene Kirpichov
Use Debug.Trace.
It does not make sense to declare that heap is a monad, as a monad is an 
abstraction of sequencing computations, and a heap is not an abstraction of 
sequencing computations at all. You don't make your String class implement the 
"rendering engine" interface just because you want to use it in a computer game 
program, equally you dont pretend that a heap is a way of sequencing 
computations just because you want to sequence computations related to heaps.

The actual computation in your case is the heapsort function, not the heap. If 
you absolutely must use IO, add IO to the functions type.

11.07.2012, в 15:19, Qi Qi  написал(а):

> Hi,
> 
> I was wondering about creating an instance of MonadIO for a heap data.
> Any hints?
> 
> data Heap a = E | T Int a (Heap a) (Heap a)
> deriving (Eq, Ord, Read, Show)
> 
> The reason is that I want to use liftIO during a heapsort to print out
> intermediate results.
> 
> Thanks.
> 
> Qi Qi
> 
> 
> 
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] wondering about a MonadIO instance for a heap data type

2012-07-11 Thread Qi Qi
Hi,

I was wondering about creating an instance of MonadIO for a heap data.
Any hints?

data Heap a = E | T Int a (Heap a) (Heap a)
 deriving (Eq, Ord, Read, Show)

The reason is that I want to use liftIO during a heapsort to print out
intermediate results.

Thanks.

Qi Qi
 


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bad interface problem.

2012-07-11 Thread Albert Y. C. Lai

On 12-07-11 05:28 AM, Magicloud Magiclouds wrote:

I am using ghc 7.4.2 which includes template-haskell-2.7.0.0.
When I installed QuickCheck-2.5, it requires template-haskell-2.6.0.0.
Even I removed all user space packages, the error was still.


Cannot reproduce. I start with ubuntu 11.04 x86 32-bit, fresh ghc 7.4.2 
(linux x86 32-bit), fresh cabal-install 0.14:


$ cabal install --dry-run QuickCheck
Resolving dependencies...
In order, the following would be installed (use -v for more details):
QuickCheck-2.5

No pulling in template-haskell-2.6.0.0.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] What's wrong with these foreign calls?

2012-07-11 Thread Андрей Янкин
Hi all!

I want to use GLFW-b (
http://hackage.haskell.org/packages/archive/GLFW-b/0.1.0.2/doc/html/Graphics-UI-GLFW.html)
and I wrote this:
  initWindow = do
True <- GLFW.initialize
print =<< GLFW.openGLProfile
print =<< GLFW.getGlfwVersion
print =<< *GLFW.getGlVersion*
print "Trying to open the window"
result <- GLFW.openWindow GLFW.defaultDisplayOptions
print result

And got this:
  DefaultProfile
  Version {versionBranch = [2,7,2], versionTags = []}
  Version {versionBranch = [*-1867951663,39789305,39789305*], versionTags =
[]}
  "Trying to open the window"
  False

Why do I always get random numbers as GLVersion?
How can I detect incompatibility preventing me from opening a window?

Thanks in advance
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghci and TH cannot: unknown symbol `stat64`

2012-07-11 Thread Bardur Arantsson
On 07/11/2012 05:12 PM, Michael Snoyman wrote:
> 
> Thanks for the feedback. However, looking at sqlite3.c, I see the
> necessary #include statements:
> 
> #include 
> #include 
> #include 
> 
> I'm confident that none of my code is making calls to stat/stat64 via
> the FFI. In case it makes a difference, this problem also disappears
> if I compile the library against the system copy of sqlite3 instead of
> using the C source.

You may need some extra defines, see the comments in "man stat64".

Regards,


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghci and TH cannot: unknown symbol `stat64`

2012-07-11 Thread Michael Snoyman
On Wed, Jul 11, 2012 at 5:47 PM, Brandon Allbery  wrote:
> On Wed, Jul 11, 2012 at 10:25 AM, Michael Snoyman 
> wrote:
>>
>> test.hs:
>> /home/ubuntu/.cabal/lib/persistent-sqlite-1.0.0/ghc-7.4.1/HSpersistent-sqlite-1.0.0.o:
>> unknown symbol `stat64'
>> test.hs: test.hs: unable to load package `persistent-sqlite-1.0.0'
>
>
> The immediate cause is that some C source file is calling stat() or lstat()
> without the right #include files; they go through several levels of backward
> compatibility macros that end in different system calls.  Alternately,
> something is trying to use one of those functions via the FFI instead of
> System.Posix.File.
>
> --
> brandon s allbery  allber...@gmail.com
> wandering unix systems administrator (available) (412) 475-9364 vm/sms
>

Hi Brandon,

Thanks for the feedback. However, looking at sqlite3.c, I see the
necessary #include statements:

#include 
#include 
#include 

I'm confident that none of my code is making calls to stat/stat64 via
the FFI. In case it makes a difference, this problem also disappears
if I compile the library against the system copy of sqlite3 instead of
using the C source.

Michael

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bad interface problem.

2012-07-11 Thread Brandon Allbery
On Wed, Jul 11, 2012 at 5:28 AM, Magicloud Magiclouds <
magicloud.magiclo...@gmail.com> wrote:

> Even I removed all user space packages, the error was still. I think
> it is a ghc pkg problem, that every package register itself as
> package:function while ghc (or cabal?) required
> package-version:function.
>

That's not the problem, it's the symptom.  Package symbols are always
versioned; ghc only shows the version when it's the only way to
disambiguate symbols.

So when it shows you a conflict where one is versioned and the other isn't,
you have multiple versions of a package installed.


> But --constraint='template-haskell-2.7.0.0' did make it compiled.
>

And that's how you prevent it.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghci and TH cannot: unknown symbol `stat64`

2012-07-11 Thread Brandon Allbery
On Wed, Jul 11, 2012 at 10:25 AM, Michael Snoyman wrote:

> test.hs:
> /home/ubuntu/.cabal/lib/persistent-sqlite-1.0.0/ghc-7.4.1/HSpersistent-sqlite-1.0.0.o:
> unknown symbol `stat64'
> test.hs: test.hs: unable to load package `persistent-sqlite-1.0.0'
>

The immediate cause is that some C source file is calling stat() or lstat()
without the right #include files; they go through several levels of
backward compatibility macros that end in different system calls.
 Alternately, something is trying to use one of those functions via the FFI
instead of System.Posix.File.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ghci and TH cannot: unknown symbol `stat64`

2012-07-11 Thread Michael Snoyman
Hi all,

A quick search indicates that this problem has come up in the past,
but I haven't seen any solutions yet. I'm working on the next
Persistent release, and one of the changes is that the included
sqlite3 C library has been updated (I believe that's the trigger
here). I can compile programs against persistent-sqlite, but if
there's TH code involved, or I try to runghc the file, I get an error
message like:

test.hs: 
/home/ubuntu/.cabal/lib/persistent-sqlite-1.0.0/ghc-7.4.1/HSpersistent-sqlite-1.0.0.o:
unknown symbol `stat64'
test.hs: test.hs: unable to load package `persistent-sqlite-1.0.0'

I'm running GHC 7.4.1 on Ubuntu 12.04 64-bit. Does anyone have insight
into what might be causing this?

Thanks,
Michael

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [Haskell] ANNOUNCE: control-monad-loop 0.1

2012-07-11 Thread Roman Cheplyaka
* Joey Adams  [2012-07-09 14:29:43-0400]
> > Also, it's not obvious how your tests work. Please consider using HUnit
> > and test-framework (or similar) to organize them.
> 
> The tests currently aren't automated.  It's hard to write an automated
> test to make sure a program doesn't leak.  Not impossible (thanks to
> GHC.Stats), but hard.

Unfortunately, in Haskell space usage is not modular[1], so ensuring
that a library (as opposed to a particular program) doesn't lead to
memory leaks is often hard.

Unit/property tests have more obvious benefits, IMO.

[1]: http://ro-che.info/articles/2012-04-08-space-usage-reasoning.html

-- 
Roman I. Cheplyaka :: http://ro-che.info/

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bad interface problem.

2012-07-11 Thread Magicloud Magiclouds
I am using ghc 7.4.2 which includes template-haskell-2.7.0.0.
When I installed QuickCheck-2.5, it requires template-haskell-2.6.0.0.
Even I removed all user space packages, the error was still. I think
it is a ghc pkg problem, that every package register itself as
package:function while ghc (or cabal?) required
package-version:function.
But --constraint='template-haskell-2.7.0.0' did make it compiled.

On Wed, Jul 11, 2012 at 1:34 PM, Claude Heiland-Allen
 wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hi,
>
> On 11/07/12 05:51, Magicloud Magiclouds wrote:
>> I cleaned out everything, no luck
>>
>> On Fri, Jul 6, 2012 at 2:14 AM, Albert Y. C. Lai 
>> wrote:
>>> On 12-07-03 04:19 AM, Magicloud Magiclouds wrote:
 template-haskell-2.6.0.0:Language.Haskell.TH differs from name
 found in the interface file
 template-haskell:Language.Haskell.TH
>
> You installed a bad template-haskell version.  You can only use a
> version corresponding to your ghc version.
>
> I had a similar problem recently.  My solution process was as follows:
>
> 1. check which template-haskell version came with my ghc:
>
> $ ghc -V
> The Glorious Glasgow Haskell Compilation System, version 7.4.2
> $ ghc-pkg list template-haskell
> /home/claude/opt/lib/ghc-7.4.2/package.conf.d
>template-haskell-2.7.0.0
> /home/claude/.ghc/x86_64-linux-7.4.2/package.conf.d
> $
>
> 2. make sure to forbid every other version of template-haskell
> (because it will break horribly, as you found):
>
> $ cabal install --constraint='template-haskell==2.7.0.0' foo
>
> 3. if foo fails to install because it thinks it needs a different
> version of template-haskell, try adjusting dependencies in foo.cabal
>
> 4. if foo installs and works with the adjusted dependencies, let the
> maintainer know
>
>>> I think things are so messed up that it is time to clean out
>>> everything. See my
>>> http://www.vex.net/~trebla/haskell/sicp.xhtml#remove
>>>
>>> In fact, time to read the whole article and avoid unsafe
>>> re-installs and "upgrades".
>
> It's a good read for sure!  Perhaps it could be updated to add a
> problem I ran into recently:
>
> "cabal install --solver=modular --avoid-reinstalls" sounds perfect, if
> sicp.xhtml scared you properly.   But excessively avoiding reinstalls
> is bad, as cabal-install seems to install a different allowable
> version instead.  The result for me was horrible diamond dependency
> problems - half my packages were built with one version of
> mtl/transformers, and the other half with a different version of
> mtl/transformers.
>
> When I then tried to ghci using some modules from both halves of my
> installed packages, I got very very confusing type errors complaining
> about almost-identical-looking types not being identical.
>
>
> Claude
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.12 (GNU/Linux)
>
> iQEcBAEBAgAGBQJP/RBbAAoJEHZDo4jueIiW164IALlHcaauJX2AjBZTDExU0mKC
> wlH+dIbaKkl8H1IMIXQnWSX0GxFGMsbPTdBXf/BC2CMXTcSJr8YMiyKewMAs734g
> DijNU/x/nQlcVruOk1c8EAijIKs938vT3dF0j863+afMAA+cRWlyLWfV50Y7AIG6
> 4hF0Fr5Q73GwonFzTXuX+iWLxBL1i2jXgPjKJvNTJZr+iGn5txCj+6ZpJyfIXaaw
> PZtQrnX/37vQ/ctbKsnDqRQI27/ENJyW3zm76Gax47EIpMvL8fHzEg8IpyR9/eR8
> 8ZfGKYNA1EsARHT3KS6pBPsVQdhn/qYInVZ5NYQ1r/kd9D6nqoy5pETdz3z/23Y=
> =Rzob
> -END PGP SIGNATURE-
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe