Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-06 Thread Yves Parès
2012/1/6 AUGER Cédric sedri...@gmail.com

 when you write forall a. exists b. a - b - a, then you allow the
 caller to have access to b to produce a (didn't you write a-b-a?)


Yes, sorry, I always assumed independence between the type variables. Like
in:
f :: forall a. a - (forall b. b - a)
being the same than:
f :: forall a b. a - b - a
I should have specified: *if* a doesn't depend on b in the latter.
Of course the latter allows that, whereas the first does not (since its
what prevents STRefs from escaping runST, by forbidding the return type of
runST to depend on the phantom type 's' of the ST action).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-06 Thread Steve Horne


I was messing around with type-classes (familiarization exercises) when 
I hit a probably newbie problem. Reducing it to the simplest case...


module BinTree ( WalkableBinTree, BT (Branch, Empty) ) where
  --  n : node type
  --  d : data item type wrapped in each node
  class WalkableBinTree n where
wbtChildren   :: n - Maybe (n, n)
wbtData   :: n - Maybe d

  --  Simple tree type, mostly for testing
  data BT x = Branch x (BT x) (BT x)
| Empty

  instance WalkableBinTree (BT x) where
wbtChildren (Branch d l r) = Just (l, r)
wbtChildren  Empty = Nothing

wbtData (Branch d l r) = Just d
wbtData  Empty = Nothing

Loading this code into GHCi, I get...

Prelude :load BinTree
[1 of 1] Compiling BinTree  ( BinTree.hs, interpreted )

BinTree.hs:16:39:
Couldn't match type `x' with `d'
  `x' is a rigid type variable bound by
  the instance declaration at BinTree.hs:12:32
  `d' is a rigid type variable bound by
  the type signature for wbtData :: BT x - Maybe d
  at BinTree.hs:16:5
In the first argument of `Just', namely `d'
In the expression: Just d
In an equation for `wbtData': wbtData (Branch d l r) = Just d
Failed, modules loaded: none.
Prelude

I've tried varying a number of details. Adding another parameter to the 
type-class (for the item-data type) requires an extension, and even then 
the instance is rejected because (I think) the tree-node and item-data 
types aren't independent.


In any case, I can't understand why those types can't match.


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


Re: [Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-06 Thread Steffen Schuldenzucker



On 01/06/2012 11:16 AM, Steve Horne wrote:


I was messing around with type-classes (familiarization exercises) when
I hit a probably newbie problem. Reducing it to the simplest case...

module BinTree ( WalkableBinTree, BT (Branch, Empty) ) where
-- n : node type
-- d : data item type wrapped in each node
class WalkableBinTree n where
wbtChildren :: n - Maybe (n, n)
wbtData :: n - Maybe d


With 'd' not being mentioned anywhere, the signature of wbtData means 
forall d. n - Maybe d. In particular, wbtData == const Nothing.




-- Simple tree type, mostly for testing
data BT x = Branch x (BT x) (BT x)
| Empty

instance WalkableBinTree (BT x) where
wbtChildren (Branch d l r) = Just (l, r)
wbtChildren Empty = Nothing

wbtData (Branch d l r) = Just d
wbtData Empty = Nothing


The signature of this function is 'BT x - Maybe x', so it doesn't match 
the one above.




Loading this code into GHCi, I get...

Prelude :load BinTree
[1 of 1] Compiling BinTree ( BinTree.hs, interpreted )

BinTree.hs:16:39:
Couldn't match type `x' with `d'
`x' is a rigid type variable bound by
the instance declaration at BinTree.hs:12:32
`d' is a rigid type variable bound by
the type signature for wbtData :: BT x - Maybe d
at BinTree.hs:16:5
In the first argument of `Just', namely `d'
In the expression: Just d
In an equation for `wbtData': wbtData (Branch d l r) = Just d
Failed, modules loaded: none.
Prelude


...which this error message tells you.



I've tried varying a number of details. Adding another parameter to the
type-class (for the item-data type) requires an extension, and even then
the instance is rejected because (I think) the tree-node and item-data
types aren't independent.


Did you try something like

 {-# LANGUAGE MultiParamTypeClasses #-}
 class WalkableBinTree n d where
   ... (same code as above, but 'd' is bound now)
 ...
 instance WalkableBinTree (BT x) x where
   ...

-- Steffen

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


Re: [Haskell-cafe] ghc default options

2012-01-06 Thread Ivan Perez
I don't know if there's a ghc main config file (I haven't found any) but
you can always use one of the following:

1) alias

2) Modify the lib field of one of the package config files in .ghc or
/usr/lib/ghc,
probably of ghc itself.

3) Modify your cabal files. You can use extra-lib-dirs or ghc-options.

(I guess you can also do it with a pragma in your haskell files,
but I find that even worse than having to use -L in the command
line).

3 is the one I use.

On 5 January 2012 22:17, Victor Miller victorsmil...@gmail.com wrote:
 Is there a place where I can specify default options for ghc?  I just
 installed ghc 7.0.4 on my Redhat system.  Since gmp isn't available on
 our system libraries I installed gmp in the lib file in my home
 directory.  I've set LIB_PATH and LD_LIBRARY_PATH to point to it.
 ghci works ok (it finds the dynamic link library in my directory), but
 unless I add -L$HOME/lib as an option to ghc --make it can't find it.
 So how can I tell ghc to look in that directory by default?  Because
 of this I can't install the haskell platform.

 Victor

 PS. I spent a while looking at the ghc manual but couldn't find
 anything appropriate.

 ___
 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] How to split this string.

2012-01-06 Thread Jon Fairbairn
Steve Horne sh006d3...@blueyonder.co.uk writes:

 On 05/01/2012 11:09, Brandon Allbery wrote:
 On Thu, Jan 5, 2012 at 05:57, Steve Horne
 sh006d3...@blueyonder.co.uk
 mailto:sh006d3...@blueyonder.co.uk wrote:

  --  groupCut - Similar to groupBy, but where groupBy assumes an
 equivalence relation,
  --  groupCut takes a function that indicates where to cut. The
 two parameters to this
  --  function are always adjacent items from the list, and if the
 function returns True,
  --  a cut is done between the two items.

 span/break?

 Using those, the test function won't always be passed two
 *adjacent* elements from the list. After all, they're based
 on takeWhile and dropWhile, which take unary functions,
 meaning an element has already been curried in (the starting
 element of the group).

 That's probably how the current groupBy is implemented - the
 approach that assumes an equivalence relation, giving
 unexpected results when the By function isn't an equivalence
 relation.

groupBy is currently implemented using span.

It strikes me that we ought to specify some properties for what
we want. Start by defining:

   pairwiseInOrderBy p l = all (uncurry p) (l `zip` drop 1 l)

giving

   all (pairwiseInOrderBy p) (groupCut p l)

and we would want

   concat (groupCut p l) == l

(all modulo nontermination side conditions). Anything else?

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk


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


Re: [Haskell-cafe] haxr standalone server?

2012-01-06 Thread Michael Snoyman
On Thu, Jan 5, 2012 at 5:40 PM, Johannes Waldmann
waldm...@imn.htwk-leipzig.de wrote:
 How could I use haxr (http://www.haskell.org/haskellwiki/HaXR)
 to build a stateful server?

 It should listen on some port,
 and fork threads (inside Haskell land) to handle incoming calls.
 Any of the Haskell web frameworks can do this?

 I guess this is the same question as:
 http://www.haskell.org/pipermail/haskell-cafe/2009-December/071185.html

Just an FYI for everyone. Johannes and I discussed this a bit
off-list, and decided that the wai-frontend-monadcgi package would be
a good fit for this use case. I deprecated this package because
MonadCGI requires lazy I/O for the request body, and enumerator-based
WAI 0.4 cannot provide a lazy request body[1]. However, WAI 1.0 will
be based on conduits, which does allow lazy I/O. I've added the
wai-frontend-monadcgi to the wai repository[2] and will release it
when the rest of WAI 1.0 is released.

Michael

[1] Without resorting to hacks like forking a separate thread and
piping data through a Chan.
[2] https://github.com/yesodweb/wai

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


Re: [Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-06 Thread Steve Horne

On 06/01/2012 10:29, Steffen Schuldenzucker wrote:



On 01/06/2012 11:16 AM, Steve Horne wrote:


I was messing around with type-classes (familiarization exercises) when
I hit a probably newbie problem. Reducing it to the simplest case...

module BinTree ( WalkableBinTree, BT (Branch, Empty) ) where
-- n : node type
-- d : data item type wrapped in each node
class WalkableBinTree n where
wbtChildren :: n - Maybe (n, n)
wbtData :: n - Maybe d


With 'd' not being mentioned anywhere, the signature of wbtData means 
forall d. n - Maybe d. In particular, wbtData == const Nothing.


I'm not sure what to make of that. Even if the result of wbtData is 
always Nothing, surely it still has a static type?




I've tried varying a number of details. Adding another parameter to the
type-class (for the item-data type) requires an extension, and even then
the instance is rejected because (I think) the tree-node and item-data
types aren't independent.


Did you try something like

 {-# LANGUAGE MultiParamTypeClasses #-}
 class WalkableBinTree n d where
   ... (same code as above, but 'd' is bound now)
 ...
 instance WalkableBinTree (BT x) x where
   ...



Precisely that. In that case, I get...

C:\_SVN\dev_trunk\haskell\examplesghci -XMultiParamTypeClasses
GHCi, version 7.0.4: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude :load BinTree
[1 of 1] Compiling BinTree  ( BinTree.hs, interpreted )

BinTree.hs:12:12:
Illegal instance declaration for `WalkableBinTree (BT x) x'
  (All instance types must be of the form (T a1 ... an)
   where a1 ... an are *distinct type variables*,
   and each type variable appears at most once in the instance head.
   Use -XFlexibleInstances if you want to disable this.)
In the instance declaration for `WalkableBinTree (BT x) x'
Failed, modules loaded: none.
Prelude

If I specify both extensions (-XMultiParamTypeClasses and 
-XFlexibleInstances) it seems to work, but needing two language 
extensions is a pretty strong hint that I'm doing it the wrong way.


The goal is fairly obvious - to have type-classes for binary tree 
capabilities so that different implementations can support different 
subsets of those capabilities. Being able to walk a binary tree doesn't 
need ordering of keys, whereas searching does. A red-black tree needs 
somewhere to store it's colour in the node, yet the walking and 
searching functions don't need to know about that.


As far as I remember, none of the tutorials I've read have done this 
kind of thing - but it seemed an obvious thing to do. Obviously in the 
real world I should just use library containers, but this is about 
learning Haskell better in case a similar problem arises that isn't 
about binary trees.


How should I be handling this?


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


Re: [Haskell-cafe] How to split this string.

2012-01-06 Thread Steve Horne

On 06/01/2012 10:39, Jon Fairbairn wrote:
groupBy is currently implemented using span. It strikes me that we 
ought to specify some properties for what we want. Start by defining: 
pairwiseInOrderBy p l = all (uncurry p) (l `zip` drop 1 l) giving all 
(pairwiseInOrderBy p) (groupCut p l) and we would want concat 
(groupCut p l) == l (all modulo nontermination side conditions). 
Anything else? 
To be honest, I've worked out what's going on in this case and I have an 
implementation or two of what I'd want in case I need it, plus I've 
posted it in case it was useful to the OP. There's nothing I really want 
to persue any further.



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


Re: [Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-06 Thread Steffen Schuldenzucker



On 01/06/2012 11:51 AM, Steve Horne wrote:

On 06/01/2012 10:29, Steffen Schuldenzucker wrote:

On 01/06/2012 11:16 AM, Steve Horne wrote:

 [...]


module BinTree ( WalkableBinTree, BT (Branch, Empty) ) where
-- n : node type
-- d : data item type wrapped in each node
class WalkableBinTree n where
wbtChildren :: n - Maybe (n, n)
wbtData :: n - Maybe d


[...]

Did you try something like

 {-# LANGUAGE MultiParamTypeClasses #-}
 class WalkableBinTree n d where
 ... (same code as above, but 'd' is bound now)
 ...
 instance WalkableBinTree (BT x) x where
 ...



 [...]


If I specify both extensions (-XMultiParamTypeClasses and
-XFlexibleInstances) it seems to work, but needing two language
extensions is a pretty strong hint that I'm doing it the wrong way.

 [...]

Well, if your instances always look like

 instance WalkableBinTree (SomeTypeConstructor x) x

you could make WalkableBinTree take a type constructor of kind (* - *) 
like this:


 class WalkableBinTree t where
 wbtChildren :: t x - (t x, t x)
 wbtData :: t x - Maybe x
 instance WalkableBinTree BT where ...

Of course, you loose flexibility compared to the multi param approach, 
e.g. you couldn't add type class constraints for the element type 'x' in 
an instance declaration.


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


Re: [Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-06 Thread Philip K. F. Hölzenspies
Dear Steve, et al.,

On 6 Jan 2012, at 11:00, haskell-cafe-requ...@haskell.org
 haskell-cafe-requ...@haskell.org wrote:

 From: Steve Horne sh006d3...@blueyonder.co.uk
 Date: 6 January 2012 10:51:58 GMT
 To: Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de
 Cc: Haskell Cafe Mailing List haskell-cafe@haskell.org
 Subject: Re: [Haskell-cafe] Simple type-class experiment turns out not so 
 simple...
 
 
 On 06/01/2012 10:29, Steffen Schuldenzucker wrote:
 With 'd' not being mentioned anywhere, the signature of wbtData means 
 forall d. n - Maybe d. In particular, wbtData == const Nothing.
 
 I'm not sure what to make of that. Even if the result of wbtData is always 
 Nothing, surely it still has a static type?

I think what Steffen was saying here is that the only implementation of wbtData 
that satisfies the general type forall d. n - Maybe d is const Nothing 
which has precisely that static type (the forall doesn't make it a dynamic 
type).

 Precisely that. In that case, I get...
 
 C:\_SVN\dev_trunk\haskell\examplesghci -XMultiParamTypeClasses
 GHCi, version 7.0.4: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 Loading package ffi-1.0 ... linking ... done.
 Prelude :load BinTree
 [1 of 1] Compiling BinTree  ( BinTree.hs, interpreted )
 
 BinTree.hs:12:12:
Illegal instance declaration for `WalkableBinTree (BT x) x'
  (All instance types must be of the form (T a1 ... an)
   where a1 ... an are *distinct type variables*,
   and each type variable appears at most once in the instance head.
   Use -XFlexibleInstances if you want to disable this.)
In the instance declaration for `WalkableBinTree (BT x) x'
 Failed, modules loaded: none.
 Prelude
 
 If I specify both extensions (-XMultiParamTypeClasses and 
 -XFlexibleInstances) it seems to work, but needing two language extensions is 
 a pretty strong hint that I'm doing it the wrong way.

This isn't a general truth, but if you're still in early stages of learning 
about GHCs type-class implementation, you're probably right.

 The goal is fairly obvious - to have type-classes for binary tree 
 capabilities so that different implementations can support different subsets 
 of those capabilities. Being able to walk a binary tree doesn't need ordering 
 of keys, whereas searching does. A red-black tree needs somewhere to store 
 it's colour in the node, yet the walking and searching functions don't need 
 to know about that.

The problem with the forall d. n - Maybe d type is that it makes d too 
general (universal, in fact), while d is fixed by n. There is an alternative 
extension you may want to look into for your furtherance of the capabilities of 
GHC, being TypeFamilies. These would lead to the following alternative 
implementation:

{-# LANGUAGE TypeFamilies #-}

class WalkableBinTree n where
  type ElemTp n
  wbtChildren :: n - Maybe (n, n)
  wbtData :: n - Maybe (ElemTp n)

instance WalkableBinTree (BT x) where
  type ElemTp (BT x) = x

  wbtChildren (Branch d l r) = Just (l, r)
  wbtChildren  Empty = Nothing

  wbtData (Branch d l r) = Just d
  wbtData  Empty = Nothing


This says that the instance fixes the element type ElemTp to something 
specific. However, it seems perfectly reasonable for the goal you describe to 
demand that whatever tree-type this class is instantiated for must be 
parametric in its element type. This can be done without any language 
extension, i.e.:

class WalkableBinTree n where
  wbtChildren :: n d - Maybe (n d, n d)
  wbtData :: n d - Maybe d

instance WalkableBinTree BT where
  wbtChildren (Branch d l r) = Just (l, r)
  wbtChildren  Empty = Nothing

  wbtData (Branch d l r) = Just d
  wbtData  Empty = Nothing

Notice that now, the class is instantiated for BT and *not* (BT x).

 As far as I remember, none of the tutorials I've read have done this kind of 
 thing - but it seemed an obvious thing to do. Obviously in the real world I 
 should just use library containers, but this is about learning Haskell better 
 in case a similar problem arises that isn't about binary trees.

A good way to learn a lot about type classes is to study the default library. 
Admittedly, this can be a bit of a daunting task to just dive in. Luckily, 
Brent Yorgey wrote up a nice article that was transferred and updated by 
numerous people on the HaskellWiki. It's worth giving it a read:

http://www.haskell.org/haskellwiki/Typeclassopedia

Happy Haskelling!

Regards,
Philip

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


Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-06 Thread AUGER Cédric
Le Fri, 6 Jan 2012 10:59:29 +0100,
Yves Parès limestr...@gmail.com a écrit :

 2012/1/6 AUGER Cédric sedri...@gmail.com
 
  when you write forall a. exists b. a - b - a, then you allow the
  caller to have access to b to produce a (didn't you write
  a-b-a?)
 
 
 Yes, sorry, I always assumed independence between the type variables.
 Like in:
 f :: forall a. a - (forall b. b - a)
 being the same than:
 f :: forall a b. a - b - a
 I should have specified: *if* a doesn't depend on b in the latter.
 Of course the latter allows that, whereas the first does not (since
 its what prevents STRefs from escaping runST, by forbidding the
 return type of runST to depend on the phantom type 's' of the ST
 action).

You misunderstood me.

 f :: forall a. a - (forall b. b - a)

is equal to:
 f :: forall a. a - forall b. b - a
(parenthesis are uneeded here)

which is equivalent to:
 f :: forall a b. a - b - a

(assuming what you said of course, but with only type variables it is
the case)

Although GHC may complain if it gets one type instead of the other;
(but in that case, just replacing f with (\x y - f x y) should do
the trick as this is an eta expansion which accepts both signatures).

It is not the case with existential variables:
in mathematics, you cannot change order of different quantifications;
it is the same in type theory:

∀ a. ∃ b. p a b is not the same as ∃ b. ∀ a. p a b

Think of ∀ a. ∃ b. b = a+1 and ∃ b. ∀ a. b = a+1

(but of course you can swap 2 existential quantifications as well as
you can swap 2 universal quantifications)

To understand how to eliminate exist p. t[p], to have only forall
expressions, you must consider elimination principle of the ∃ rule;
but it will change the type.

It is the same thing for datatypes:

data Bool = True
  | False

can be eliminated in the types:

Bool = forall a. a - a - a
True = \x y - x
False = \x y - y

So now a function like:

f :: Bool - SomeType
f b = if b then someTerm1 else someTerm2

can be rewritten as:

f2 :: (forall a. a - a - a) - SomeType
f2 b = b someTerm1 someTerm2

(note that a is existentially quantified in the type of f2)

For the existential types, it is the same thing; the easiest way to
understand them is as inductive types, so that the type is stored
somewhere. But elimination of an inductive type completely changes the
signature!

exists b. t[b] as a syntactic sugar of:
Exists (t::*-*) is isomorphic to:
forall a. (forall b. (t[b]) - a) - a

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


[Haskell-cafe] OpenAL bindings?

2012-01-06 Thread Jason Dagit
Hello,

Looks like the repo [1] for the OpenAL bindings that Sven Panne
created [2] is no longer available. I assume this is a result of The
Great Server Outage of 2011 [3].  Do other bindings exist (I didn't
see any on hackage, google, or the wiki [4])?

I can import the source that is available on hackage into a github
repo and hack from there, but I wanted to ask first: Is the source of
this repo gone for good?

As a side note, I have plenty of other repos and things on my plate so
I'm not really interested in becoming the maintainer of this binding.
Any OpenAL experts interested in taking it over?  I know from
experience that Sven appears to be MIA in the Haskell community these
days.

Thanks,
Jason

--

[1] http://darcs.haskell.org/packages/OpenAL/
[2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OpenAL
[3] http://www.haskell.org/pipermail/haskell-cafe/2011-February/088829.html
[4] http://www.haskell.org/haskellwiki/OpenAL

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


[Haskell-cafe] Package for QuickCheck instances

2012-01-06 Thread Antoine Latter
Hi Haskell,

I was writing some tests that involved a large number of quickcheck
properties which don't ship with the library itself, so I thought I
would package them all together and put the orphan instances on
Hackage. Here's what I have so far:

https://github.com/aslatter/qc-instances/tree/93a87fa06b5575ddcc12c2f9eb0f4672c6f9a317

The policy would be to allow anything into to package which is a part
of the Haskell Platform or is a GHC build library.

Has anyone already done this? I didn't find anything from grepping the
Hackage package list.

Has anyone already talked about doing this sort of thing? Are their
any non-obvious pitfalls (aside from the package eventually becoming a
cesspool of CPP conditions)?

Thanks,
Antoine

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


Re: [Haskell-cafe] Experiments in Haskell Packaging

2012-01-06 Thread Chris Dornan
Thanks Sanket,
 
That ticket https://github.com/haskell-hub/hub-gen/issues/8  on the need
for user-space installs is a model of clarity.
 
I don't have any problem with installing the tools into user-land - this
will be true of all of the components in the justhub distro - provided you
start with the source code.
 
I want so solve this problem, but it may have be done with non-RPM
packaging.
 
I will have to think about this a bit and get back to you.
 
Thanks again!
 
Chris
 
From: Sanket Agrawal [mailto:sanket.agra...@gmail.com] 
Sent: 06 January 2012 00:56
To: Chris Dornan
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Experiments in Haskell Packaging
 
Hi Chris,
 
I have created a ticket request for user-space install of GHC and haskell
platform. For some of us, development environment is very similar to
production environment (minus the dev tools) to keep the deployment
procedures consistent, and simple. So, we don't have root privileges in dev
environment too. But, this is not really a big deal as all of the
development tools that I am familiar with, can be installed in user-land in
user-defined locations.
 

Thanks,
Sanket
On Thu, Jan 5, 2012 at 5:15 AM, Chris Dornan ch...@chrisdornan.com wrote:
Hi Sanket,
 
If you like you can put a ticket into the issue tracker
https://github.com/haskell-hub/hub-gen/issues  (otherwise I will do it
myself).
 
I am sorry that you have had to go to such lengths to get Haskell working on
your systems.
 
Unfortunately I don't think it is going to be straightforward to make the
packages relocatable. 
 
Could you say a little more about why you need to do this? Do you need a
user-space install?
 
I had targeted this distribution primarily at development systems and build
servers where I would expect populating /usr/hs with read-only data and code
wouldn't be a problem.
 
It sounds like you might be immediately better off working directly with the
source code. I can help with this obviously as I have had to solve these
problems. (The REHEL5-supplied gcc and binutils tools are too to build
recent GHC releases, so I use more recent tools, which I also package with
the distribution.)
 
In the medium/long term It may be easier to address these needs with a
separate 'lite' distribution focused on field-deployment with relocatable
packages, which may as well be user-space deployable too. 
 
This will need to be researched and could take some time.
 
If anybody else is interested in this then please get in contact.
 
Also, if anybody has any other gripes or ideas about how Haskell
distributions generally it would be good to hear.
 
Chris
 
From: Sanket Agrawal [mailto:sanket.agra...@gmail.com] 
Sent: 05 January 2012 01:36
To: Chris Dornan
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Experiments in Haskell Packaging
 
Hi Chris,
 
Is it possible to also make the GHC and haskell platform distributions
available as relocatable rpms, instead of HUB packaging? The reason is that
for some of us, when we work in complex production environment which has its
own deployment procedures, we have to deploy it differently. A hard-coded
path like /usr/hs won't work, and a packaging environment that depends on
that hard-coded path won't work either in that case.
 
I actually downloaded RHEL5 GHC binary rpm from justhub.org, and unpacked it
using rpm2cpio. Then, I ended up doing grep and sed to replace all
occurrences of /usr/hs with the path I installed it in. It worked well
except for some caveats - some of the binary/data files such as *.hi seem to
have the hard-coded path in them. That hasn't caused any issues so far,
except for haddock which fails if gcc is called since it is coded to
/usr/hs/bin/gcc (though haddock bash shell has right gcc path coded in it -
I guess it ignores it in favor of the path in some binary file). 
 
It will be very nice to have what I did above, as relocatable rpms, and
without HUB dependency. That will help with, I suspect, reducing the
duplication of efforts when some of us, who want to use haskell at work, end
up compiling our own binaries for RHEL platform (since glibc on RHEL 5/6 is
older than what ghc-pwd demands). I tried to compile GHC 7.4 on RHEL 5, but
it failed to link because of some GHC bug. That is how I ended up using your
compiled binary with my grep/sed hack. It was a great time-saver. Thank you
for doing this work.
 
-Sanket
 
On Tue, Jan 3, 2012 at 7:49 AM, Chris Dornan ch...@chrisdornan.com wrote:
'Antoine Latter' aslat...@gmail.com:

 All of this is in my head, but assuming I already had some sort of
 Linux build-server set up, it would be nice to combine it with your
 work to make it easier to have the build-server run tests against
 multiple versions of GHC/HP. That's all I was getting at.

Working within the Hub framework this is straightforward. If you are using
public releases rather than special builds of the tools then it should be
quite easy.

Supposing you needed to test with Haskell Platform 2011.2.0.1 and

Re: [Haskell-cafe] Package for QuickCheck instances

2012-01-06 Thread Bryan O'Sullivan
On Fri, Jan 6, 2012 at 8:43 AM, Antoine Latter aslat...@gmail.com wrote:


 I was writing some tests that involved a large number of quickcheck
 properties which don't ship with the library itself, so I thought I
 would package them all together and put the orphan instances on
 Hackage.


That's a great idea. Thanks for doing this!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Problems with libgmp on Amazon Linux

2012-01-06 Thread Nicu Ionita

Hello,

I saw [1] there is a lot of activity in the Haskell community regarding 
Amazon Web Services (AWS). As they allow an easy start [2], I decided to 
giv it a try and followed the procedure published by JP Moresmau [3] to 
install the Haskell Plattform on Amazon Linux (a minimal linux 
distribution maintained by Amazon), but with the new Haskell Platform, 
2011.4.0.0 (and ghc 7.0.4).


It seemed to work pretty well, with some problems when configuring HP, 
because although libgmp was already installed, it was not recognized. I 
installed the newer version 5.0.2 (from sources) [4], did some tricks 
(cp /usr/lib/lib/libgmp* /usr/lib), then configure worked and HP was 
built and installed.


But then later I wanted to install the aws package (cabal install aws) 
and then the vector package could not be installed - again because of 
libgmp! Here are the last messages, followed by a ls of /usr/lib, where 
it's clear that the libraries are there:


[ 4 of 30] Compiling Data.Vector.Internal.Check ( 
Data/Vector/Internal/Check.hs, dist/build/Data/Vector/Internal/Check.o )
[ 5 of 30] Compiling Data.Vector.Fusion.Stream.Monadic ( 
Data/Vector/Fusion/Stream/Monadic.hs, 
dist/build/Data/Vector/Fusion/Stream/Monadic.o )

Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... command line: can't load .so/.DLL for: 
gmp (libgmp.so: cannot open shared object file: No such file or directory)

cabal: Error: some packages failed to install:
vector-0.9.1 failed during the building phase. The exception was:
ExitFailure 1
[ec2-user@ip-10-234-49-92 ~]$ ls -l /usr/lib/libgmp*
-rw-r--r-- 1 root root 1175336 Jan  4 22:21 /usr/lib/libgmp.a
-rwxr-xr-x 1 root root 915 Jan  4 22:21 /usr/lib/libgmp.la
-rwxr-xr-x 1 root root  484673 Jan  4 22:21 /usr/lib/libgmp.so
-rwxr-xr-x 1 root root  484673 Jan  4 22:21 /usr/lib/libgmp.so.10
-rwxr-xr-x 1 root root  484673 Jan  4 22:21 /usr/lib/libgmp.so.10.0.2
[ec2-user@ip-10-234-49-92 ~]$

I'm just asking here hoping that someone had already solved this 
problem. Or perhaps someone can explain how cabal ensures that a library 
is there. The error message - as it is - is meaningless, as the file 
exists and has read permissions for everybody.


Thank you,
Nicu

[1] 
http://www.reddit.com/r/haskell/comments/o1u2g/deploying_a_haskell_app_to_amazon_ec2/

[2] https://aws.amazon.com/free/
[3] 
http://jpmoresmau.blogspot.com/2011/04/install-ghc7-and-yesod-on-amazon-linux.html

[4] ftp://ftp.gnu.org/gnu/gmp/

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


[Haskell-cafe] [ANNOUNCE] First release of crypto-conduit

2012-01-06 Thread Felipe Almeida Lessa
Hello!

I'm pleased to announce the first release of crypto-conduit [1]!  The
crypto-api [2] package provides APIs for many cryptographic
operations, such as cryptographic hashes and block ciphers.  This new
crypto-conduit package allows you to use many of these operations with
conduits [3], giving you safe I/O using constant memory and no leaks.

As an example, here's how you could get the SHA1 hash a file:

  import Crypto.Conduit -- from crypto-conduit
  import Crypto.Hash.SHA1 (SHA1) -- from cryptohash
  import Data.Conduit -- from conduit
  import Data.Conduit.Binary (sourceFile) -- from conduit

  main = do
hash - runResourceT $ sourceFile my-file $$ sinkHash
print (hash :: SHA1)

The code snippet above, despite having only sourceFile ... $$
sinkHash on its core, guarantees that the file handle is not kept
open and uses a constant amount of memory.  Sweet!

Please break this package!  Although it comes with a test suite, it
has just seen the light of the day.

Cheers, =)

[1] http://hackage.haskell.org/package/crypto-conduit
[2] http://hackage.haskell.org/package/crypto-api
[3] http://hackage.haskell.org/package/conduit

-- 
Felipe.

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


Re: [Haskell-cafe] Problems with libgmp on Amazon Linux

2012-01-06 Thread Yucheng Zhang
On Sat, Jan 7, 2012 at 8:08 AM, Nicu Ionita nicu.ion...@acons.at wrote:
 It seemed to work pretty well, with some problems when configuring HP,
 because although libgmp was already installed, it was not recognized. I
 installed the newer version 5.0.2 (from sources) [4], did some tricks (cp
 /usr/lib/lib/libgmp* /usr/lib), then configure worked and HP was built and
 installed.

I think you should get the installed libgmp recognized, but not doing tricks
like this. It is no problem as a temporary solution, but you should always
try to make use of a package manager.

 Loading package integer-gmp ... command line: can't load .so/.DLL for: gmp
 (libgmp.so: cannot open shared object file: No such file or directory)

I have no experience with AWS, but it seems that you need to run a ldconfig
to rebuild the cache, since you installed libgmp just by copying into /usr/lib.

ldconfig -n /usr/bin

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


Re: [Haskell-cafe] Problems with libgmp on Amazon Linux

2012-01-06 Thread Yucheng Zhang
On Sat, Jan 7, 2012 at 1:04 PM, Yucheng Zhang yczhan...@gmail.com wrote:
 ldconfig -n /usr/bin

Sorry, it should be:

ldconfig -n /usr/lib

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