Re: [Haskell-cafe] How to throw an error if using cabal-install version XYZ?

2013-05-23 Thread Carter Schonwald
constraining it to = 1.17 would be better while 1.18 isn't out yet..


On Thu, May 23, 2013 at 1:42 AM, Roman Cheplyaka r...@ro-che.info wrote:

 Perhaps I'm missing something, but why not just

   cabal-version:   =1.18

 ?

 It will constrain the Cabal version, not cabal-install, but judging from
 the fix[1] this is what you actually need.

 [1]:
 https://github.com/haskell/cabal/commit/d148336e97cda2e3585c453cf9af61bc3635131a

 Roman

 * Ryan Newton rrnew...@gmail.com [2013-05-22 22:50:08-0400]
  A cabal-install bug https://github.com/haskell/cabal/issues/1284 was
  fixed recently that pertains to building C libraries with profiling.
 
  As a result, I want a certain
  packagehttp://hackage.haskell.org/package/atomic-primops-0.1.0.2to
  test if cabal-install  0.17.0 is used, and throw a preemptive error.
   Otherwise this package fails in weird ways at runtime (it's a nasty
 one).
 
  I noticed with some surprise the following sequence:
 
  *   $ cabal --version*
  *   cabal-install version 1.16.0.2*
  *   using version 1.16.0.3 of the Cabal library*
  *   $ cabal clean*
  *   $ cabal install*
  *   $ cat dist/build/autogen/cabal_macros.h  | grep VERSION_Cabal*
  *   #define VERSION_Cabal 1.17.0*
 
  Alright, so that, in retrospect, makes sense.  The version is which *my*
  library is linked with is the relevant one, not the one cabal-install was
  linked with [1].
 
  So the natural next thought is to move the MIN_VERSION_Cabal test into
  Setup.hs, and force cabal to use it by setting the build type to Custom.
   But... I just learned from this ticket that the cabal macros are not
  available in Setup.hs:
 
 http://hackage.haskell.org/trac/hackage/ticket/326
 
  Uh oh, what's left?
 
   -Ryan
 
  [1] P.S. Personally I'm now using a bash function like below, to force
 the
  two versions to be the same:
 
  function safe_cabal_install () {
VER=`cabal --version | tail -n1 | awk '{ print $3 }'`
cabal install --constraint=Cabal==$VER $*
  }

  ___
  cabal-devel mailing list
  cabal-de...@haskell.org
  http://www.haskell.org/mailman/listinfo/cabal-devel


 ___
 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] question about type constructors

2013-05-23 Thread Roman Cheplyaka
* TP paratribulati...@free.fr [2013-05-23 00:34:57+0200]
 Hi,
 
 In the program I am trying to write, I have a problem that can be reduced to 
 the following dummy example:
 
 --
 {-# LANGUAGE GADTs #-}
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE KindSignatures #-}
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE IncoherentInstances #-}
 
 class PrettyPrint a where
 prettify :: a - String
 
 data Gender = Male | Female | Gender3 | Gender4
 
 data Person :: Gender - * where
 Person :: String - Person b
 Child :: String - Person a - Person b - Person c
 
 instance PrettyPrint (Person a)
 
 instance PrettyPrint (Person Male) where
 prettify (Person name) = My name is  ++ (show name)
   ++  and I am a male
 prettify (Child name person1 person2) = My name is  ++ (show name)
   ++  and my parents are: ++ (prettify person1) ++ , 
   ++ (prettify person2)
 
 main = do
 
 let p1 = Person Jim :: Person Male
 let p2 = Person Joe :: Person Male
 let p3 = Child Jack p1 p2
 
 print $ prettify p1
 print $ prettify p2
 print $ prettify p3
 --
 
 The idea is that I want to implement PrettyPrint only for a subset of the 
 possible types in Gender (through promotion process). Why? It would be 
 longer to explain (it is a bit more complicated in my real program).
 
 Anyway, in the program above, I have found that with IncoherentInstances 
 (and the empty instance definition for (Person a)), it is working, it is 
 able to use the most specific instance corresponding to the current type (I 
 don't know exactly why). For example, p1 and p2 are correctly printed above, 
 because they are of type (Person Male) and because I have implemented 
 PrettyPrint for (Person Male).
 
 But it does not work for p3, I obtain an error at runtime:
 -
 $ runghc test.hs
 My name is \Jim\ and I am a male
 My name is \Joe\ and I am a male
 test_typelost.hs: test_typelost.hs:16:10-31: No instance nor default method 
 for class operation Main.prettify
 -
 
 The reason is that the information that p1 and p2 are Male seems to be 
 lost when we construct the child Child Jack p1 p2, probably because 
 GHC only sees that in the type signature of Child, we have a more general 
 (Person a) - (Person b). So he tries to find an implementation of prettify 
 in PrettyPrint (Person a), but there is none.
 
 Is there any workaround?

The rule of thumb is that you should never use IncoherentInstances.

The proper way to do it is:

  data Person :: Gender - * where
  Person :: String - Person b
  Child
:: (PrettyPrint a, PrettyPrint b)
= String - Person a - Person b - Person c

Roman

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


Re: [Haskell-cafe] HTML framework for web-ui

2013-05-23 Thread Vlatko Basic

Hi Heinrich,

Looks simple and interesting. I browsed the git, but not much docs yet.
Just examples, or have I looked at wrong places?


I see that API is still under heavy design. When do you expect the API might 
stabilize?


(BTW, examples in Readme do not work.)

vlatko



Vlatko Basic wrote:

I'd like to start using web pages as the UI for apps. I found out for yesod,
snapp and happstack as the candidates.
Would you recommend any of them as better for app ui (not classical web
pages)? Or maybe another one?


Not sure if that's what you are looking for, but with help from Daniel Austin,
I'm currently working on a small GUI library that use the web browser to display
GUI elements.

   https://github.com/HeinrichApfelmus/threepenny-gui

It's derived from Chris Done's former Ji project.

It's not quite ready for public consumption yet, but any feedback is
appreciated, of course.


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


___
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] ANNOUNCE: new bridge! (prelude-prime)

2013-05-23 Thread Roman Cheplyaka
I liked Andreas's idea (cited below). Hence the new package
prelude-prime.

https://github.com/feuerbach/prelude-prime
http://hackage.haskell.org/package/prelude-prime

Pull requests are welcome, but let's stick to widely agreed changes
(like the Foldable/Traversable one). I think one of the reasons why
other Preludes haven't been adopted is because they were too radical.

Let's see whether people here can put their code where their mouth is :)

Roman

* Andreas Abel andreas.a...@ifi.lmu.de [2013-05-20 13:26:05+0200]
 Maybe instead of fiddling with the current Prelude (which might break
 backwards compatibility), we should design a new prelude which is not
 automatically loaded but contains roughly the current prelude (with
 the list functions generalized to collections) plus the modern type
 class stack: Functor, Applicative, Monad, Foldable, Traversable,
 Monoid etc.
 
 I am willing to write
 
   {-# LANGUAGE NoImplicitPrelude #-}
   import Base
 
 if I get a decent, modern standard set of functions that could be
 considered as the base vocabulary of modern Haskell programmers...
 
 I just do not want to think about the democratic process involved in
 this design...
 
 Cheers,
 Andreas

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


Re: [Haskell-cafe] ANNOUNCE: new bridge! (prelude-prime)

2013-05-23 Thread Anton Kholomiov
I wish it was possible to use an extension

CustomPrelude = Prelude.Prime

In the cabal file




2013/5/23 Roman Cheplyaka r...@ro-che.info

 I liked Andreas's idea (cited below). Hence the new package
 prelude-prime.

 https://github.com/feuerbach/prelude-prime
 http://hackage.haskell.org/package/prelude-prime

 Pull requests are welcome, but let's stick to widely agreed changes
 (like the Foldable/Traversable one). I think one of the reasons why
 other Preludes haven't been adopted is because they were too radical.

 Let's see whether people here can put their code where their mouth is :)

 Roman

 * Andreas Abel andreas.a...@ifi.lmu.de [2013-05-20 13:26:05+0200]
  Maybe instead of fiddling with the current Prelude (which might break
  backwards compatibility), we should design a new prelude which is not
  automatically loaded but contains roughly the current prelude (with
  the list functions generalized to collections) plus the modern type
  class stack: Functor, Applicative, Monad, Foldable, Traversable,
  Monoid etc.
 
  I am willing to write
 
{-# LANGUAGE NoImplicitPrelude #-}
import Base
 
  if I get a decent, modern standard set of functions that could be
  considered as the base vocabulary of modern Haskell programmers...
 
  I just do not want to think about the democratic process involved in
  this design...
 
  Cheers,
  Andreas

 ___
 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] ANNOUNCE: new bridge! (prelude-prime)

2013-05-23 Thread Joachim Breitner
HI,

Am Donnerstag, den 23.05.2013, 12:38 +0400 schrieb Anton Kholomiov:
 I wish it was possible to use an extension
 
 CustomPrelude = Prelude.Prime
 
 In the cabal file

as far as I know, GHC simply issues an implicit

import Prelude

without package qualifiers. So you can get what you want by not
depending on base, but rather have prelude-prime re-export all modules
from base plus its own Preldue.

A more modular variant would be to have a package preludeless-base
which re-exports all modules from base but the prelude. Then you can
select which prelude you want simply by depending on preludeless-base
(instead of base) plus a package (say prelude-prime) which exports a
module named Prelude.

If prelude-prime itself wants to use base, it can still use
package-qualified imports. Or it could itself be based on
preludeless-base.

Greetings,
Joachim


-- 
Joachim nomeata Breitner
Debian Developer
  nome...@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: nome...@joachim-breitner.de | http://people.debian.org/~nomeata



signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: new bridge! (prelude-prime)

2013-05-23 Thread Michael Snoyman
On Thu, May 23, 2013 at 11:38 AM, Anton Kholomiov anton.kholom...@gmail.com
 wrote:

 I wish it was possible to use an extension

 CustomPrelude = Prelude.Prime

 In the cabal file



I'm not necessarily opposed to this idea, but I'd like to point out that it
can have a negative impact on readability of an individual module, since
you can't tell which Prelude is being used. This is the same argument used
for putting LANGUAGE pragmas in a modules instead of listing them in a
cabal file. I think in the case of an alternate Prelude, the argument is
stronger, since language extensions often don't change the meaning of code,
but instead allow previously invalid code to be valid.

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


Re: [Haskell-cafe] ANNOUNCE: new bridge! (prelude-prime)

2013-05-23 Thread Bas van Dijk
On 23 May 2013 11:26, Joachim Breitner m...@joachim-breitner.de wrote:
 So you can get what you want by not
 depending on base, but rather have prelude-prime re-export all modules
 from base plus its own Preldue.

How would you re-export all base's modules from the prelude-prime
package? I didn't know this was already possible.

Bas

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


Re: [Haskell-cafe] ANNOUNCE: new bridge! (prelude-prime)

2013-05-23 Thread Joachim Breitner
Hi,

Am Donnerstag, den 23.05.2013, 11:52 +0200 schrieb Bas van Dijk:
 On 23 May 2013 11:26, Joachim Breitner m...@joachim-breitner.de wrote:
  So you can get what you want by not
  depending on base, but rather have prelude-prime re-export all modules
  from base plus its own Preldue.
 
 How would you re-export all base's modules from the prelude-prime
 package? I didn't know this was already possible.

manually...

you create a .hs file for every module in base, which imports the module
in base (using a package-qualified import), gives it a qualified name
and puts that name in the export list.

Greetings,
Joachim

-- 
Joachim nomeata Breitner
Debian Developer
  nome...@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: nome...@joachim-breitner.de | http://people.debian.org/~nomeata



signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: new bridge! (prelude-prime)

2013-05-23 Thread Bas van Dijk
On 23 May 2013 11:54, Joachim Breitner m...@joachim-breitner.de wrote:
 Hi,

 Am Donnerstag, den 23.05.2013, 11:52 +0200 schrieb Bas van Dijk:
 On 23 May 2013 11:26, Joachim Breitner m...@joachim-breitner.de wrote:
  So you can get what you want by not
  depending on base, but rather have prelude-prime re-export all modules
  from base plus its own Preldue.

 How would you re-export all base's modules from the prelude-prime
 package? I didn't know this was already possible.

 manually...

 you create a .hs file for every module in base, which imports the module
 in base (using a package-qualified import), gives it a qualified name
 and puts that name in the export list.

I see. Thanks for the clarification.

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


Re: [Haskell-cafe] question about type constructors

2013-05-23 Thread TP
Roman Cheplyaka wrote:

 The rule of thumb is that you should never use IncoherentInstances.
 
 The proper way to do it is:
 
   data Person :: Gender - * where
   Person :: String - Person b
   Child
 :: (PrettyPrint a, PrettyPrint b)
 = String - Person a - Person b - Person c

Thanks a lot. Now I am using FlexibleContexts, and it works correctly (see 
code below). I think I have understood the problem.
However, I have still one question. In the code below, I have added data 
constructors Child2, Child3 (imagining a world where every people has 
three children). The problem is that I am compelled to repeat the context 
(PrettyPrint (Person a), PrettyPrint (Person b)) for each one of the 
constructors. Is there any way to specify the context only once? I have 
tried using forall, but without any success.

Thanks,

TP

-
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}

class PrettyPrint a where
prettify :: a - String

data Gender = Male | Female | Gender3 | Gender4

data Person :: Gender - * where
Person :: String - Person b
Child1 :: (PrettyPrint (Person a)
 , PrettyPrint (Person b)
 ) = String - Person a - Person b - Person c
Child2 :: (PrettyPrint (Person a)
 , PrettyPrint (Person b)
 ) = String - Person a - Person b - Person c
Child3 :: (PrettyPrint (Person a)
 , PrettyPrint (Person b)
 ) = String - Person a - Person b - Person c

instance PrettyPrint (Person Male) where
prettify (Person name) = My name is  ++ (show name)
  ++  and I am a male
prettify (Child1 name person1 person2) = My name is  ++ (show name)
  ++  and my parents are: ++ (prettify person1) ++ , 
  ++ (prettify person2)

main = do

let a = Person Jim :: Person Male
let b = Person Joe :: Person Male
let c = Child1 Jack a b :: Person Male

print $ prettify a
print $ prettify b
print $ prettify c


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


Re: [Haskell-cafe] question about type constructors

2013-05-23 Thread Roman Cheplyaka
* TP paratribulati...@free.fr [2013-05-23 13:23:36+0200]
 Roman Cheplyaka wrote:
 
  The rule of thumb is that you should never use IncoherentInstances.
  
  The proper way to do it is:
  
data Person :: Gender - * where
Person :: String - Person b
Child
  :: (PrettyPrint a, PrettyPrint b)
  = String - Person a - Person b - Person c
 
 Thanks a lot. Now I am using FlexibleContexts, and it works correctly (see 
 code below). I think I have understood the problem.
 However, I have still one question. In the code below, I have added data 
 constructors Child2, Child3 (imagining a world where every people has 
 three children). The problem is that I am compelled to repeat the context 
 (PrettyPrint (Person a), PrettyPrint (Person b)) for each one of the 
 constructors. Is there any way to specify the context only once? I have 
 tried using forall, but without any success.

No, because the type variables are independent across different
constructors.  They are (implicitly) existentially quantified, which
becomes clearer if you rewrite your type as

  data Person (c :: Gender)
= forall a b . (PrettyPrint (Person a), PrettyPrint (Person b))
  = Child1 String (Person a) (Person b)
| forall a b . (PrettyPrint (Person a), PrettyPrint (Person b))
  = Child2 String (Person a) (Person b)
| ...

What you can do is factor out the Child type as

  data Child where
Child :: ( PrettyPrint (Person a)
 , PrettyPrint (Person b)
 ) = String - Person a - Person b - Child

  data Person a where
Child1 :: Child - Person c
Child2 :: Child - Person c
Child3 :: Child - Person c

 -
 {-# LANGUAGE GADTs #-}
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE KindSignatures #-}
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE FlexibleContexts #-}
 
 class PrettyPrint a where
 prettify :: a - String
 
 data Gender = Male | Female | Gender3 | Gender4
 
 data Person :: Gender - * where
 Person :: String - Person b
 Child1 :: (PrettyPrint (Person a)
  , PrettyPrint (Person b)
  ) = String - Person a - Person b - Person c
 Child2 :: (PrettyPrint (Person a)
  , PrettyPrint (Person b)
  ) = String - Person a - Person b - Person c
 Child3 :: (PrettyPrint (Person a)
  , PrettyPrint (Person b)
  ) = String - Person a - Person b - Person c
 
 instance PrettyPrint (Person Male) where
 prettify (Person name) = My name is  ++ (show name)
   ++  and I am a male
 prettify (Child1 name person1 person2) = My name is  ++ (show name)
   ++  and my parents are: ++ (prettify person1) ++ , 
   ++ (prettify person2)
 
 main = do
 
 let a = Person Jim :: Person Male
 let b = Person Joe :: Person Male
 let c = Child1 Jack a b :: Person Male
 
 print $ prettify a
 print $ prettify b
 print $ prettify c
 
 
 ___
 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] ANNOUNCE: new bridge! (prelude-prime)

2013-05-23 Thread Manuel Gómez
On Thu, May 23, 2013 at 3:07 AM, Roman Cheplyaka r...@ro-che.info wrote:
 Pull requests are welcome, but let's stick to widely agreed changes
 (like the Foldable/Traversable one). I think one of the reasons why
 other Preludes haven't been adopted is because they were too radical.

 * Andreas Abel andreas.a...@ifi.lmu.de [2013-05-20 13:26:05+0200]
 Maybe instead of fiddling with the current Prelude (which might break
 backwards compatibility), we should design a new prelude which is not
 automatically loaded but contains roughly the current prelude (with
 the list functions generalized to collections) plus the modern type
 class stack: Functor, Applicative, Monad, Foldable, Traversable,
 Monoid etc.

Is this strategy adequate for attacking the issue of the type class
stack, though?  Defining, say, a new Monad class with the desired
Functor constraint wouldn’t be of much use, as everything else on
Hackage (and on the GHC libraries!) would still use the “real” Monad.

I still see value in this package — a conservative extension to the
Prelude would certainly come in handy.  Thanks!

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


Re: [Haskell-cafe] ANNOUNCE: new bridge! (prelude-prime)

2013-05-23 Thread Roman Cheplyaka
* Manuel Gómez tar...@gmail.com [2013-05-23 08:33:15-0430]
 On Thu, May 23, 2013 at 3:07 AM, Roman Cheplyaka r...@ro-che.info wrote:
  Pull requests are welcome, but let's stick to widely agreed changes
  (like the Foldable/Traversable one). I think one of the reasons why
  other Preludes haven't been adopted is because they were too radical.
 
  * Andreas Abel andreas.a...@ifi.lmu.de [2013-05-20 13:26:05+0200]
  Maybe instead of fiddling with the current Prelude (which might break
  backwards compatibility), we should design a new prelude which is not
  automatically loaded but contains roughly the current prelude (with
  the list functions generalized to collections) plus the modern type
  class stack: Functor, Applicative, Monad, Foldable, Traversable,
  Monoid etc.
 
 Is this strategy adequate for attacking the issue of the type class
 stack, though?  Defining, say, a new Monad class with the desired
 Functor constraint wouldn’t be of much use, as everything else on
 Hackage (and on the GHC libraries!) would still use the “real” Monad.

No, it definitely isn't.

Roman

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


Re: [Haskell-cafe] HTML framework for web-ui

2013-05-23 Thread Heinrich Apfelmus

Vlatko Basic wrote:

Hi Heinrich,

Looks simple and interesting. I browsed the git, but not much docs yet.
Just examples, or have I looked at wrong places?


Thanks! Only examples and Haddock documentation so far, though the 
latter is extensive.


I see that API is still under heavy design. When do you expect the API 
might stabilize?


The current API probably won't change much until the first release, but 
I can't guarantee anything beyond that. It involves lots of aesthetic 
decisions.



(BTW, examples in Readme do not work.)


That would be one of the corners where it's not ready for public 
consumption yet. ;)



Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


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


Re: [Haskell-cafe] How to throw an error if using cabal-install version XYZ?

2013-05-23 Thread Ryan Newton
Great!  Thanks.  I adapted that trick and it worked fine:

https://github.com/rrnewton/haskell-lockfree-queue/blob/cb8ca1a5d8b4c02e45eeca54fbc66f0c58aeff56/AtomicPrimops/Setup.hs



On Wed, May 22, 2013 at 11:53 PM, Carter Schonwald 
carter.schonw...@gmail.com wrote:

 Hey Ryan,
 I ran into a related issue, heres a a way you can do this safe IN the
 cabal file (or at least you can modify my hack for your purposes)

 heres a link to the workaround I did for making LLVM-hs work across =
 1.17 and  1.17 cabal, but you could abuse it to make sure setup.hs barfs
 on old cabal
 https://github.com/bos/llvm/blob/master/base/Setup.hs#L89-L116

 heres a quick one off gist that takes my trick and does something helpful
 for you variant + makes sure the tool can't build otherwise

 https://gist.github.com/cartazio/5632636

 I just wrote a snippet that you can just add to your setup.hs and it
 should guarantee the setup.hs will barf with a helpful error message on
 cabal  1.17.0


 On Wed, May 22, 2013 at 10:50 PM, Ryan Newton rrnew...@gmail.com wrote:

 A cabal-install bug https://github.com/haskell/cabal/issues/1284 was
 fixed recently that pertains to building C libraries with profiling.

 As a result, I want a certain 
 packagehttp://hackage.haskell.org/package/atomic-primops-0.1.0.2to test if 
 cabal-install  0.17.0 is used, and throw a preemptive error.
  Otherwise this package fails in weird ways at runtime (it's a nasty one).

 I noticed with some surprise the following sequence:

 *   $ cabal --version*
 *   cabal-install version 1.16.0.2*
 *   using version 1.16.0.3 of the Cabal library*
 *   $ cabal clean*
 *   $ cabal install*
 *   $ cat dist/build/autogen/cabal_macros.h  | grep VERSION_Cabal*
 *   #define VERSION_Cabal 1.17.0*

 Alright, so that, in retrospect, makes sense.  The version is which *my*
 library is linked with is the relevant one, not the one cabal-install was
 linked with [1].

 So the natural next thought is to move the MIN_VERSION_Cabal test into
 Setup.hs, and force cabal to use it by setting the build type to Custom.
  But... I just learned from this ticket that the cabal macros are not
 available in Setup.hs:

http://hackage.haskell.org/trac/hackage/ticket/326

 Uh oh, what's left?

  -Ryan

 [1] P.S. Personally I'm now using a bash function like below, to force
 the two versions to be the same:

 function safe_cabal_install () {
   VER=`cabal --version | tail -n1 | awk '{ print $3 }'`
   cabal install --constraint=Cabal==$VER $*
 }


 ___
 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] How not to force ghci debugger but still know the _result?

2013-05-23 Thread haskell-cafe
Hi,

As the subject says, I'd like to use the GHCI debugger to inspect the results
of some functions. I tried to set :break-points on these functions and
:step through them, but unless I use :force I never get to see the result
of these functions.

Is it possible to somehow break when the result is evaluated?

Please find below a log of my attempts to debug a small example, where during
debugging none of the _result values is ever known/shown.

Maarten Faddegon

--

$ cat bla1.hs
blabla:: [Int] - Int
bla   :: Int - Int
papperlap :: Int - Int - Int

bla x = x+x
papperlap y x = ((y *) . bla) x
blabla xs = foldl papperlap 0 xs
$ ghci bla1.hs
GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( bla1.hs, interpreted )
Ok, modules loaded: Main.
*Main :break blabla
Breakpoint 0 activated at bla1.hs:7:1-36
*Main :break papperlap
Breakpoint 1 activated at bla1.hs:6:1-31
*Main :break bla
Breakpoint 2 activated at bla1.hs:5:1-19
*Main blabla [1,2,3]
Stopped at bla1.hs:7:1-36
_result :: Int = _
[bla1.hs:7:1-36] *Main :step
Stopped at bla1.hs:7:17-36
_result :: Int = _
xs :: [Int] = [1,2,3]
[bla1.hs:7:17-36] *Main :step
Stopped at bla1.hs:6:1-31
_result :: Int = _
[bla1.hs:6:1-31] *Main :step
Stopped at bla1.hs:6:17-31
_result :: Int = _
x :: Int = 3
y :: Int = _
[bla1.hs:6:17-31] *Main :step
Stopped at bla1.hs:6:1-31
_result :: Int = _
[bla1.hs:6:1-31] *Main :step
Stopped at bla1.hs:6:17-31
_result :: Int = _
x :: Int = 2
y :: Int = _
[bla1.hs:6:17-31] *Main :step
Stopped at bla1.hs:6:1-31
_result :: Int = _
[bla1.hs:6:1-31] *Main :step
Stopped at bla1.hs:6:17-31
_result :: Int = _
x :: Int = 1
y :: Int = 0
[bla1.hs:6:17-31] *Main :step
Stopped at bla1.hs:5:1-19
_result :: Int = _
[bla1.hs:5:1-19] *Main :step
Stopped at bla1.hs:5:17-19
_result :: Int = _
x :: Int = 1
[bla1.hs:5:17-19] *Main :step
Stopped at bla1.hs:5:1-19
_result :: Int = _
[bla1.hs:5:1-19] *Main :step
Stopped at bla1.hs:5:17-19
_result :: Int = _
x :: Int = 2
[bla1.hs:5:17-19] *Main :step
Stopped at bla1.hs:5:1-19
_result :: Int = _
[bla1.hs:5:1-19] *Main :step
Stopped at bla1.hs:5:17-19
_result :: Int = _
x :: Int = 3
[bla1.hs:5:17-19] *Main :step
0
*Main 

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


Re: [Haskell-cafe] Debugging embedded ruby interpreter

2013-05-23 Thread Simon Marechal
On 05/22/2013 11:36 PM, Simon Marechal wrote:
 Anyone has an idea on how I should approach this problem ?

For future reference : I believe I have found the problem, and it was
quite obvious ...

When generating Ruby objects from Haskell, they are not referenced by
anything in the interpreter. This means they will be collected everytime
there is a GC run.

I now manually enable / disable / start GC, and things seem to work.

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