Re: [Haskell-cafe] ANN: signed-multiset-0.1

2012-04-25 Thread wren ng thornton

On 4/25/12 7:27 PM, Stefan Holdermans wrote:

Sjoerd,


[3] defines the union as h(u) = max(f(u), g(u)) where f, g and h are 
multiplicity functions.


Which is the same, as [3] is about multisets, not signed multisets.


Chapter 3 of [3] is about Hybrid Sets.


And there the union is defined by taking the *minimum* of multiplicities, which 
is even more strange.


FWIW, I've run into the minimum version of bags/multisets as well. It's 
a bit strange notionally, but mathematically it actually works out 
pretty well as I recall.



Do note that if we consider multisets to be sets with extra structure, 
then some minimisation is implicit in the maximization definition as 
well. That is, consider the definition in Syropoulos where a ("real") 
multiset is a tuple (X,p) of X a set and p an equivalence relation on X.


Given two multisets (X,p) and (Y,q), let (Z,r) be their max-union. Since 
we're thinking of these as sets with extra structure, we'd like for Z to 
be the union of X and Y. In order for multiplicities to work out right, 
that means we must require that X and Y be "maximally non-disjoint". 
That is, consider (W,r') where W is the intersection of X and Y, and r' 
is the restriction of r to W. We want that the multiplicities in (W,r') 
are the *minimum* of the multiplicities in (X,p) and (Y,q). That 
guarantees that elements are shared whenever possible, and hence that Z 
= X `union` Y is as small as possible while being consistent with the 
multiplicities on (X,p) and (Y,q).


--
Live well,
~wren

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


Re: [Haskell-cafe] JSON library suggestions?

2012-04-25 Thread Alvaro Gutierrez
On Wed, Apr 25, 2012 at 10:42 PM, Richard O'Keefe  wrote:

> Note that the conversion *IS* lossy in practice.
> If you send a JSON message to a Javascript program,
> or a Python program, or a Go program (if I am reading
> src/pkg/encoding/json/decode.go
> correctly) what you get will be a 64-bit float.
> The Jackson parser for Java uses Double for numbers with a '.' or 'e' by
> default,
> although it can be configured to use BigDecimal.
>
> If you want numbers outside the domain of finite 64-bit floats to travel
> unscathed through JSON, then you must control not only which languages are
> used at each end, but which versions of which libraries and how configured.
>
>
Right, for better or for worse, the absence of numeric semantics in the
JSON standard means that what a number means is up to the implementation(s)
involved, and the onus is on the user(s) to coordinate between them.


> I argued the other end of this in the mailing list for another language,
> saying that I wanted things that look like integers to be decoded as
> integers,
> and was stepped on hard.  Some people found their programs much simpler if
> they always got the same kind of Number whatever the input looked like (in
> Jackson, a Number might be returned as an instance of any of five classes).
>

My view is that the only reasonable approach is to decode JSON numbers into
arbitrarily-sized rationals, such that interpretation is arguably lossless
(modulo loss of precision, if e.g. 1.0 cannot be distinguished from 1).


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


Re: [Haskell-cafe] ANN: signed-multiset-0.1

2012-04-25 Thread wren ng thornton

On 4/25/12 5:39 AM, Stefan Holdermans wrote:

The union of two sets is typically defined as the smallest set that is a 
superset of both the operands;


Or, the smallest set containing all the elements of both/all operands.

The two definitions coincide for sets.

They diverge for bags/multisets: yours uses maximization whereas mine 
uses addition[1]. Notably, both operations are monoids with zero being 
the identity element. Thus it is sensible for zero to denote 
non-membership in both versions. Both are natural extensions of the case 
for sets; which is "more natural" is subject to debate and context. 
(I've always considered "bags" and "multisets" to be synonymous, though 
perhaps others mean them to distinguish these two different ideas of 
generalizing sets.)


They continue to diverge when multiplicities can be negative; here the 
use of zero becomes an issue. For the additive definition, zero is still 
okay for denoting non-membership because zero is the identity for 
addition on integers (as well as the identity for addition on naturals). 
This is a natural extension of the additive case for bags, we're just 
adding closure for subtraction. However, while zero is the identity for 
maximization on naturals, there is no identity for maximization on the 
integers. You'd have to use the integers plus negative infinity in order 
to have a monoid.



[1] Actually, maximization only works out if we assume that the 
arguments are "maximally non-disjoint" ---i.e., share elements whenever 
possible--- whereas addition only works out if we assume the arguments 
are disjoint. These are the two extreme cases, and therefore the most 
interesting, though it's possible to get any multiplicity between those 
extremes. Assuming sets to be disjoint is a common thing, however; 
whereas I don't know of any set-theoretic way of defining "maximally 
non-disjoint" to be anything meaningful.




I do not recall claiming maximisation to be "natural"; what's natural for one 
application, may not be for another.


I'm only using natural in the mathematical sense (i.e., as the "obvious" 
extension of something). And you did claim maximization was the 
obvious/appropriate way to extend the case for sets.


I'm fine with the claim that maximization is natural for bags/multisets. 
It's just that addition is natural there too. Sets are where lattice 
theory and ring theory meet; so there's no a priori reason to say that 
generalizations of sets belong more to one theory than the other. But 
the one thing both theories agree on is the importance of monoids.


The problem with the further extension from bags/multisets to signed 
multisets is that the difference between lattices and rings becomes a 
lot more apparent. You can make maximization work in a sensible way, and 
it's a desirable thing to have; you just can't make it work with zero 
because zero has no special significance to the maximization function on 
integers.



That said, my goal was never to upload a package that only leads to confusion 
and false expectations. As the common opinion seems to be that a maximising 
union is bad, I will drop it from the library and deprecate the package on 
Hackage.


Deprecating the package seems a bit excessive. Why not just extend the 
documentation to explain exactly what properties the two variants have 
and why different people might want one over the other? Why not just 
rename "union" (and "map") to something else, thereby giving neither 
variant the default status? Users can always define union = theUnionIWant.




[1] Wayne D. Blizard: Multiset Theory. Notre Dame Journal of Formal Logic 
30(1): 36-66 (1989)
[2] Wayne D. Blizard: Negative Membership. Notre Dame Journal of Formal Logic 
31(3): 346-368 (1990)
[3] Apostolos Syropoulos: Mathematics of Multisets. WMP 2000: 347-358


If you take a look at Syropoulos's definition 12 (the subhybridset 
definition of Loeb) you can see that there's something funny going on. 
In particular, the definition of (<<) cannot be correct because 
Syropoulos says:


i << j = (i <= j) && (i < 0 || 0 <= j)

But that's identical to just using (<=) in the first place! I think what 
Syropoulos/Loeb means to say instead is that:


i << j = (abs i <= abs j) && (i < 0 || 0 <= j)

In which case you actually get a partial order where zero does have 
significance. Though it's a rather peculiar ordering, so maybe they mean 
something else again.



Also, lest you think the rest of us are crazy, all the other authors 
I've seen use "union" to mean what Syropoulos calls "sum" (defn.7), and 
use some other terminology like "minimal-union" to mean what Syropoulos 
calls "union" (defn.9). E.g.,



http://www.cs.utexas.edu/~moore/acl2/workshop-2002/contrib/martin-alonso-hidalgo-ruiz/generic-multiset.pdf

Which came up when trying to locate the papers you mentioned.

--
Live well,
~wren

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.o

Re: [Haskell-cafe] JSON library suggestions?

2012-04-25 Thread Richard O'Keefe

On 25/04/2012, at 9:51 AM, Alvaro Gutierrez wrote:
> For that reason, most standard (fixed size/binary) numeric types like double 
> are a poor choice to contain numeric values specified in JSON; in particular, 
> the mismatch means that conversion can be lossy in both directions.

Note that the conversion *IS* lossy in practice.
If you send a JSON message to a Javascript program,
or a Python program, or a Go program (if I am reading 
src/pkg/encoding/json/decode.go
correctly) what you get will be a 64-bit float.
The Jackson parser for Java uses Double for numbers with a '.' or 'e' by 
default,
although it can be configured to use BigDecimal.

If you want numbers outside the domain of finite 64-bit floats to travel
unscathed through JSON, then you must control not only which languages are
used at each end, but which versions of which libraries and how configured.

I argued the other end of this in the mailing list for another language,
saying that I wanted things that look like integers to be decoded as integers,
and was stepped on hard.  Some people found their programs much simpler if
they always got the same kind of Number whatever the input looked like (in
Jackson, a Number might be returned as an instance of any of five classes).



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


[Haskell-cafe] Haskell Weekly News: Issue 224

2012-04-25 Thread Daniel Santa Cruz
Welcome to issue 224 of the HWN, an issue covering crowd-sourced bits
of information about Haskell from around the web. This issue covers the
week of April 15 to 21, 2012.

Announcements

Some of these announcements are a bit behind, for which I apologize.
Better late than never...

The long awaited version of cabal-install is out!
[1] http://goo.gl/LlO7s

Janis Voigtlander is looking for contributors for the May 2012
edition of the Haskell Comunities and Activities Report. If you have
anything Haskell related that you have been working on, make sure to
send Janis a note. The deadline is May 1st.
[2] http://goo.gl/AW3gR

Jeremy O'Donoghue announced the release of wxHaskell 0.90. "his
release represents a significant milestone for us as it includes
support for wxWidgets 2.9.x."
[3] http://goo.gl/vTYTp

Janis Voigtlander also issued a call for papers for the Haskell
Symposium 2012, Copenhagen, Denmark on 13th September, 2012, directly
after ICFP.
[4] http://goo.gl/fR2hB

Eric Kow released the 9th edition of the Parallel Haskell Digest.
[5] http://goo.gl/gBIhK

Quotes of the Week

   * TSC: The type families might have little type children

   * mm_freak: i'd love to have an embeddable Agda type checker and
   evaluator
 mm_freak: that would make a great scripting language for haskell
   programs

   * shachaf: You can't spell "-funsafe" without "fun" and "safe".

   * elliott: By the way, I find the inclusion of a package named
  "colour" in a section titled "Color" offensive :)

   * elliott: I don't think Haskell can ever hope to enter the
  enterprise if we can't model non-standard colourblind
  observers with it.

   * danharaj:oh hey this looks nice.
 Mathnerd314: every open-source math library under the sun glued
  together into a Python framework
 danharaj: nevermind o_o

   * elliott: What do we do with people who paste code blocks on IRC? We
  yell at them.

   * acowley: I am a bull in a math shop

   * elliott: I like how edwardk's answer to every question always goes
  "most abstract solution to the problem possible -->
  microoptimisation details".
 elliott: I swear I've seen him go from category theory to unboxed
  types and unsafeCoerce in a single line of IRC.

   * shachaf: It is a sobering thought that by the time Galois was my
  age, he had been dead for almost two months.

Top Reddit Stories

   * Why do Monads Matter? (or it's Monad tutorial season again)
 Domain: cdsmith.wordpress.com, Score: 64, Comments: 27
 On Reddit: [6] http://goo.gl/DCJYV
 Original: [7] http://goo.gl/8glhF

   * Ur/Web records: can we apply lessons from them to Haskell?
 Domain: blog.ezyang.com, Score: 53, Comments:
 On Reddit: [8] http://goo.gl/9m3Sw
 Original: [9] http://goo.gl/dNcET

   * Blank Canvas - a new Haskell graphics library based on HTML5 and 
 Domain: ittc.ku.edu, Score: 42, Comments: 10
 On Reddit: [10] http://goo.gl/H3SMB
 Original: [11] http://goo.gl/if7kG

   * Client Side Yesod, an FRP-inspired approach
 Domain: yesodweb.com, Score: 41, Comments: 44
 On Reddit: [12] http://goo.gl/gECTq
 Original: [13] http://goo.gl/Rn0LS

   * Understanding Haskell Kinds
 Domain: softwaresimply.blogspot.com, Score: 38, Comments: 18
 On Reddit: [14] http://goo.gl/XxiwQ
 Original: [15] http://goo.gl/xaqDM

   * Adding SIMD Support to Data Parallel Haskell
 Domain: ghc-simd.blogspot.co.uk, Score: 35, Comments: 8
 On Reddit: [16] http://goo.gl/R8M9L
 Original: [17] http://goo.gl/ZeJ7e

   * Working With HTML In Haskell
 Domain: adit.io, Score: 31, Comments: 24
 On Reddit: [18] http://goo.gl/4NMBc
 Original: [19] http://goo.gl/EOvM1

   * Descending the level ladder
 Domain: monoidal.blogspot.com, Score: 26, Comments: 13
 On Reddit: [20] http://goo.gl/9IYZL
 Original: [21] http://goo.gl/TJm0D

   * Why is Haskell so large?
 Domain: self.haskell, Score: 25, Comments: 29
 On Reddit: [22] http://goo.gl/KQnbj
 Original: [23] http://goo.gl/KQnbj

   * Parallel Haskell Digest 9: GSoC, STM, SIMD, and the Downfall of
Imperative Programming?
 Domain: well-typed.com, Score: 25, Comments: 1
 On Reddit: [24] http://goo.gl/Z5bF3
 Original: [25] http://goo.gl/eLnVs

   * blaze-html 0.5 released
 Domain: jaspervdj.be, Score: 25, Comments: 3
 On Reddit: [26] http://goo.gl/7XtMD
 Original: [27] http://goo.gl/RkbR7

   * Four Tips for New Haskell Programmers
 Domain: softwaresimply.blogspot.com, Score: 22, Comments: 72
 On Reddit: [28] http://goo.gl/GQ4O1
 Original: [29] http://goo.gl/Ye57L

   * Check for interest - an argument/option parser using type level strings
 Domain: self.haskell, Score: 22, Comments: 13
 On Reddit: [30] http://goo.gl/eOtE5
 Original: [31] http://goo.gl/eOtE5

   * New Cabal feature: cabal bench
 Domain

Re: [Haskell-cafe] Uploading a new hsc2hs

2012-04-25 Thread Thomas DuBuisson
On Wed, Apr 25, 2012 at 5:27 PM, Antoine Latter  wrote:
> On Wed, Apr 25, 2012 at 4:59 PM, Thomas DuBuisson
>  wrote:
>> Warning:
>>
>> I, not the maintainer of hsc2hs, will be uploading a trivial fix for
>> hsc2hs to hackage (new build deps).  Even after public attempts to
>> contact anyone in charge of hsc2hs (last January) there still has been
>> no word.  Speak now or forever hold your peace.
>>
>
> I don't think I've ever installed hsc2hs from Hackage as it ships with GHC.

Fair point, and Ian has been the one pushing patches to the repo
lately.  Ian - any objections to me bumping to version 0.68 and
uploading that to hackage?

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


Re: [Haskell-cafe] Uploading a new hsc2hs

2012-04-25 Thread Antoine Latter
On Wed, Apr 25, 2012 at 4:59 PM, Thomas DuBuisson
 wrote:
> Warning:
>
> I, not the maintainer of hsc2hs, will be uploading a trivial fix for
> hsc2hs to hackage (new build deps).  Even after public attempts to
> contact anyone in charge of hsc2hs (last January) there still has been
> no word.  Speak now or forever hold your peace.
>

I don't think I've ever installed hsc2hs from Hackage as it ships with GHC.

It looks like the version on Hackage was last updated in 2006 ... I'm
pretty sure there have been changes to hsc2hs since then.

Antoine

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


Re: [Haskell-cafe] ANN: signed-multiset-0.1

2012-04-25 Thread Stefan Holdermans
Sjoerd,

>>> [3] defines the union as h(u) = max(f(u), g(u)) where f, g and h are 
>>> multiplicity functions.
>> 
>> Which is the same, as [3] is about multisets, not signed multisets.
> 
> Chapter 3 of [3] is about Hybrid Sets.

And there the union is defined by taking the *minimum* of multiplicities, which 
is even more strange.

>>> [...] and this is also what your implementation does. (Map.unionWith max 
>>> does not do a max if the key is not in one of the maps, i.e. if one of the 
>>> multiplicities is 0.)
>> 
>> I am aware of that. Why are you explaining this?
> 
> Because we can't seem to get to an agreement. Usually this is because of a 
> misunderstanding, so I try be as clear as possible, so you can understand my 
> position, or point out my mistake.

I don't think you are mistaken. I think that

1. you're happy with the monoid over additiveUnion;
2. you're not happy with the definition of union.

I'm not a mathematician, but I can see value in how union is defined now: it 
nicely generalises familiar concepts and associated properties (!) from sets 
and bags, and there seems to be support for it in literature.

>> Let's agree to disagree. This is not constructive and, moreover, going 
>> nowhere.

> I'd prefer to keep arguing actually. ;-) But if you have something better to 
> do, I won't bother you anymore.

I do enjoy this kind of discussion, but I think neither one of us will be able 
to convince the other. I am totally okay with that. That is not to say that I 
cannot be convinced by new, more compelling arguments.

Cheers,

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


Re: [Haskell-cafe] ANN: signed-multiset-0.1

2012-04-25 Thread Sjoerd Visscher

On Apr 26, 2012, at 12:54 AM, Stefan Holdermans wrote:

> Sjoerd,
> 
> I am sorry, as I already wrote, I decided to deprecate the package.

That's too bad, I really love these kind of data structures. (That's why I keep 
ranting about it, sorry about that.)

> 
>> [3] defines the union as h(u) = max(f(u), g(u)) where f, g and h are 
>> multiplicity functions.
> 
> Which is the same, as [3] is about multisets, not signed multisets.

Chapter 3 of [3] is about Hybrid Sets.

> 
>> [...] and this is also what your implementation does. (Map.unionWith max 
>> does not do a max if the key is not in one of the maps, i.e. if one of the 
>> multiplicities is 0.)
> 
> I am aware of that. Why are you explaining this?

Because we can't seem to get to an agreement. Usually this is because of a 
misunderstanding, so I try be as clear as possible, so you can understand my 
position, or point out my mistake.

> 
>> I think if your union would follow the definition with max as in [3] and [4] 
>> it is not confusing. But then empty would not be the identity of that union 
>> (that would be the signed multiset with multiplicity negative infinity for 
>> all elements), so it would still not be a good choice for the Monoid 
>> instance.
> 
> Let's agree to disagree. This is not constructive and, moreover, going 
> nowhere.

I'd prefer to keep arguing actually. ;-) But if you have something better to 
do, I won't bother you anymore.

greetings,
Sjoerd

>>> [3] Apostolos Syropoulos: Mathematics of Multisets. WMP 2000: 347-358



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


[Haskell-cafe] Linear Diaphantine equation solver bug

2012-04-25 Thread John D. Ramsdell
I uploaded a new version of the ACU unifier in package cmu.  It
includes a Linear Diaphantine equation solver that now handles
inhomogeneous equations.  What's interesting  is the algorithm is
based on a paper by Contejean and Devie.  That paper includes a proof
of correctness of their algorithm.  Yet I found an example in which
following the steps in the order they gave, the algorithm produces
extra answers.  I had to switch the order of the steps in the
algorithm to get the right answer.  I wonder if anyone else knows of
this issue.  The example is given in the module documentation on
Hackage.

John

http://hackage.haskell.org/packages/archive/cmu/1.6/doc/html/Algebra-CommutativeMonoid-LinDiaphEq.html

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


Re: [Haskell-cafe] ANN: signed-multiset-0.1

2012-04-25 Thread Stefan Holdermans
Sjoerd,

I am sorry, as I already wrote, I decided to deprecate the package.

> [3] defines the union as h(u) = max(f(u), g(u)) where f, g and h are 
> multiplicity functions.

Which is the same, as [3] is about multisets, not signed multisets.

> [...] and this is also what your implementation does. (Map.unionWith max does 
> not do a max if the key is not in one of the maps, i.e. if one of the 
> multiplicities is 0.)

I am aware of that. Why are you explaining this?

> I think if your union would follow the definition with max as in [3] and [4] 
> it is not confusing. But then empty would not be the identity of that union 
> (that would be the signed multiset with multiplicity negative infinity for 
> all elements), so it would still not be a good choice for the Monoid instance.

Let's agree to disagree. This is not constructive and, moreover, going nowhere.

Cheers,

  Stefan


>> [3] Apostolos Syropoulos: Mathematics of Multisets. WMP 2000: 347-358

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


[Haskell-cafe] ANN: unfoldable-0.4.0

2012-04-25 Thread Sjoerd Visscher
I am pleased to announce the 5th version of the unfoldable package. (This is 
the first announcement, you didn't miss anything.)
http://hackage.haskell.org/package/unfoldable-0.4.0

Just as there's a Foldable class, there should also be an Unfoldable class. 
This package provides one:

  class Unfoldable t where
unfold :: Unfolder f => f a -> f (t a)

Writing instances of Unfoldable is similar to writing Traversable instances. 
For example, given a data type

  data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)

a suitable instance would be

  instance Unfoldable Tree where
unfold fa = choose
  [ pure Empty
  , Leaf <$> fa
  , Node <$> unfold fa <*> fa <*> unfold fa
  ]

The choose function comes from the Unfolder class:

  class Applicative f => Unfolder f where
choose :: [f x] -> f x

(If f is an Alternative instance, choose is simply Data.Foldable.asum.)

Different unfolders provide different ways of generating values, for example:
 - Random values
 - Enumeration of all values (depth-first or breadth-first)
 - Convert from a list
 - An implementation of QuickCheck's arbitrary should also be possible (still 
working on that)

Some examples can be found in the examples directory in the github repo:
https://github.com/sjoerdvisscher/unfoldable

Ideas and comments are welcome!

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


Re: [Haskell-cafe] ANN: signed-multiset-0.1

2012-04-25 Thread Sjoerd Visscher

On Apr 25, 2012, at 11:39 AM, Stefan Holdermans wrote:

> The union of two sets is typically defined as the smallest set that is a 
> superset of both the operands; this definition extends nicely for multisets 
> and hybrid sets [1,2,3].

[3] differs from [1] and [2] (and your implementation). [3] defines the union 
as h(u) = max(f(u), g(u)) where f, g and h are multiplicity functions. [4] does 
the same. But [2] says on page 352: "For binary union, take the maximum of 
nonzero multiplicities", and this is also what your implementation does. 
(Map.unionWith max does not do a max if the key is not in one of the maps, i.e. 
if one of the multiplicities is 0.)

> I do not recall claiming maximisation to be "natural"; what's natural for one 
> application, may not be for another. The library provides both union (based 
> on maximisation) and additive union, and furthermore gives Monoid instances 
> over both of them. Not having a preference for either one of them, I thought 
> that having both of them in the library made sense.
> 
> That said, my goal was never to upload a package that only leads to confusion 
> and false expectations. As the common opinion seems to be that a maximising 
> union is bad, I will drop it from the library and deprecate the package on 
> Hackage.


I think if your union would follow the definition with max as in [3] and [4] it 
is not confusing. But then empty would not be the identity of that union (that 
would be the signed multiset with multiplicity negative infinity for all 
elements), so it would still not be a good choice for the Monoid instance.

greetings,
Sjoerd

> [1] Wayne D. Blizard: Multiset Theory. Notre Dame Journal of Formal Logic 
> 30(1): 36-66 (1989)
> [2] Wayne D. Blizard: Negative Membership. Notre Dame Journal of Formal Logic 
> 31(3): 346-368 (1990)
> [3] Apostolos Syropoulos: Mathematics of Multisets. WMP 2000: 347-358
[4] A Cavalcanti: Theoretical Aspects of Computing


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


[Haskell-cafe] Uploading a new hsc2hs

2012-04-25 Thread Thomas DuBuisson
Warning:

I, not the maintainer of hsc2hs, will be uploading a trivial fix for
hsc2hs to hackage (new build deps).  Even after public attempts to
contact anyone in charge of hsc2hs (last January) there still has been
no word.  Speak now or forever hold your peace.

Cheers,
Thomas


P.S. I still think c2hs is the right philosophy even if it's too verbose.

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


Re: [Haskell-cafe] Correspondence between libraries and modules

2012-04-25 Thread Gregg Lebovitz



On 4/24/2012 11:49 PM, wren ng thornton wrote:

On 4/24/12 9:59 AM, Gregg Lebovitz wrote:

The question of how to support rapid innovation and stable
deployment is not an us versus them problem. It is one of staging 
releases. The
Linux kernel is a really good example. The Linux development team 
innovates
faster than the community can absorb it. The same was true of the GNU 
team.

Distributions addressed the gap by staging releases.


In that case, what you are interested in is not Hackage (the too-fast 
torrent of development) but rather the Haskell Platform (a policed set 
of stable/core libraries with staged releases).


No, that was not what I was thinking because a stable policed set of 
core libraries is at the opposite end of the spectrum from how you 
describe Hackage. What I am suggesting is a way of creating an upstream 
that feeds increasingly stable code into an ever increasing set of 
stable and useful components. Using the current open system model, the 
core compiler team for gcc releases the compiler and a set of libstdc 
and libstdc++ libraries. The GNU folks release more useful libraries, 
and then projects like GNOME build on the other components. Right now we 
have Hackage that moves to fast and the Haskell core that rightfully 
moves more slowly.


Maybe the answer is to add a rating system to Hackage and mark packages 
as experimental, unsupported, and supported, or use a 5 star rating 
system like the app store. Later on when we have appropriate testing 
tools, we can include a rating from the automated tests.




I forget who the best person to contact is these days if you want to 
get involved with helping the HP, but I'm sure someone on the list 
will say shortly :)




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


Re: [Haskell-cafe] Printing call site for partial functions

2012-04-25 Thread Ozgur Akgun
Hi,

On 25 April 2012 16:36, Michael Snoyman  wrote:

>Prelude.head: empty list
>

Recent versions of GHC actually generate a very helpful stack trace, if the
program is compiled with profiling turned on and run with -xc.

See: http://community.haskell.org/~simonmar/slides/HIW11.pdf(Ironically
titled "Prelude.head: empty list")

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


Re: [Haskell-cafe] Printing call site for partial functions

2012-04-25 Thread Evan Laforge
> And then have the compiler automatically include (optional) package
> name, module name, and line number where `headContext` was called. How
> about we borrow a bit from rewrite rules, and have a pragma such as:
>
>    {-# WITH_CONTEXT head headContext #-}

This seems similar to the SRCLOC_ANNOTATE pragma supported by jhc.

I'd love to have this feature.  I'd just like to point out it's not
just useful for partial functions like 'head', but also for logging
and "expected" exceptions like Left.  It's also extremely useful for
tests, when I get "check failed: 3 /= 4" it's really important to see
filename and line number.

There are various hacks out there to get this, but they all involve
annotating the call sites with some magic, either an 'assert' (and
then runtime overhead on every function that uses it) or a TH splice
(and then you have to turn TH on in every module).  I have literally
thousands of lines of tests that would all need an extra boilerplate
argument.

I implemented a preprocessor that is effectively like SRCLOC_ANNOTATE
and it works ok for me, but it's not a good general solution because
it's hardcoded to certain symbols and slows down compilation too much.
 And being specific to my app of course it wouldn't help in your case
:)

But it won't happen unless one of us few people who care about it just
goes and implements it.  I don't think it's much of a priority with
others.

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


[Haskell-cafe] Printing call site for partial functions

2012-04-25 Thread Michael Snoyman
I had a bug in a site of mine[1] for a few weeks, where it would just print:

Prelude.head: empty list

It took a long time to track down the problem, as it came from some
other library I was depending on. Eventually I tracked it down,
reported it, and the problem was fixed the next day. The weak link in
this chain was identifying what package was to blame.

I noticed the other day that the docs for undefined[2] state:

> It is expected that compilers will recognize this and insert error messages 
> which are more appropriate to the context in which undefined appears.

I'm not sure if the current output of `Prelude.undefined` is meant to
fit the criterion of "appropriate to the context", but in my opinion
it does not. I'd like to propose a bit of a strawman to improve the
situation for not just `undefined`, but any arbitrary partial function
(including `head`). What we really want is to define some function
like:

headContext :: String -> [a] -> a
headContext context [] = error $ "Prelude.head: empty list (" ++
context ++ ")"
headContext _ (x:_) = x

And then have the compiler automatically include (optional) package
name, module name, and line number where `headContext` was called. How
about we borrow a bit from rewrite rules, and have a pragma such as:

{-# WITH_CONTEXT head headContext #-}

If the compiler supports the feature, and is able to provide context
in the given location, it will call `headContext` with an appropriate
`String`. Otherwise, normal `head` would be called.

I'm sure there are many better ways to approach the problem, and I
can't speak to the complexity of implementation within GHC. I *can*
say, however, that this would have saved me a lot of time in the
example I gave above, and I'd bet many Haskellers have similar
stories. This could be a huge debugging win across the board.

Michael

[1] It was actually yesodweb.com, and resulted in empty Javascript
files being generated, thus disabling some features of the site.
[2] 
http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/Prelude.html#v:undefined

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


Re: [Haskell-cafe] "desactivate" my Show instance implementations temporarily

2012-04-25 Thread Eric Kow
On 23 Apr 2012, at 17:49, Evan Laforge wrote:
> I use a custom Pretty class along with HughesPJ, ala ghc's Outputable.
> It means I can omit data or print it out in a more readable form
> (even just rounding floats to %.03f can help a lot), and also get nice
> layout and wrapping.


I think I do something similar, although not hooking it up with a proper pretty 
printing library (that manages indentation etc), but which just stupid builds 
strings à  la Show.

http://hackage.haskell.org/packages/archive/GenI/latest/doc/html/NLP-GenI-Pretty.html

I wish I knew about a Commonly Agreed Idiom (or library) for just recursively 
creating human-friendly text, but I suspect I only say this because I don't 
have a clear picture what I'm really wishing for.  Does everybody just use 
HughesPJ?

I'll also mention that it took me a while to untangle all the various notions 
of showing things in my code.  Now it's

* Show: Haskell
* GraphvizShow: dot
* GeniShow: outputting structures in my custom text format
* Pretty: for talking to humans

Embarrassing to say that until recently my code was a random mismash of uses 
and unclear thinking.  For example, it hadn't occurred to me that I shouldn't 
define GeniShow in terms of other things (but vice versa) because I don't want 
to accidentally change my file format just because I was trying to make 
something prettier.  Oops.

-- 
Eric Kow 



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Multi-site haddock documentation with proper links?

2012-04-25 Thread Brent Yorgey
It is possible.  I have done it for 
  
  http://projects.haskell.org/diagrams/doc/index.html

But it is not fun, and it took me several days of work (spread over
two weeks) to figure out the proper magic incantations to get
everything to work properly.  I really ought to write up a blog post
with instructions; I'll try to do that soon.

-Brent

On Tue, Apr 24, 2012 at 08:34:53PM -0400, Ryan Newton wrote:
> Hello cafe,
> 
> For various reasons, some packages don't build documentation on hackage:
> 
>http://hackage.haskell.org/package/accelerate
> 
> Therefore I want to locally install documentation for a set of packages
> like this and host them on a separate website.  I want all of these ~ten
> packages' haddock documentation to be properly interlinked with eachother,
> but also to link to Hackage for types and classes defined in other modules.
> 
> Is this possible?  Hackage haddocks are all interlinked, but that is simply
> because hackage is one giant local install, right?
> 
> If it's not possible (and it seems not) do any haddock devs have pointers
> on how to implement this?
> 
> Thanks,
>   -Ryan
> 
> P.S.  Someone recommended to me the following simple hack -- just use sed
> to rewrite the links after haddock generates the html.  I think I'll do
> that for the time being unless someone has a better suggestion.

> ___
> 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] atomicModifyMutVar and casMutVar

2012-04-25 Thread Thomas Bereknyei
I have seen some push to take advantage of the new primop casMutVar, yet I
see that atomicModifyMutVar hasn't been used yet either. For example,
modifySTRef is just a read followed by a write. I've been unable to create
a version that does not allocate with something as simple as modifySTRef
ref (+1).

There is a package Data.Ref.Unboxed that allows ST to use an unboxed
STURef, but even though I can see the Core using Int#, any use of
modifySTURef, or any version I've been able to make will excessively
box/rebox.  Should I instead be using something like modifySTURef ref
(GHC.Prim.+#) or can this be automatically done by the compiler?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Multi-site haddock documentation with proper links?

2012-04-25 Thread Ryan Newton
One more update:

"cabal haddock" exposes a --html-location flag which is useful:


http://www.haskell.org/cabal/users-guide/installing-packages.html#setup-haddock

Another way of invoking haddock is through "cabal install".  It looks like
"cabal install --enable-documentation" and "cabal install --haddock" are
not documented here, but they work:


http://www.haskell.org/cabal/users-guide/installing-packages.html#paths-in-the-simple-build-system

With cabal 0.14.0 and haddock 2.10.0, they work even when installing
multiple packages at once using trailing slashes ("cabal install foo/ bar/
baz/").

We can then achieve the effect of "haddock --html-location=URL" with
the --haddock-html-location=URL flag to "cabal install".  (There is also an
"--htmldir" flag available but its effect is somewhat confusing.  As far as
I can tell it seems to affect where the ".haddock" files are put, not where
the .html in installed or where the links point to. )

So that's it.  The result is that it's easy to build ONE package's
documentation and host it on a different server but with all links to other
modules pointing to hackage.  Regarding the original goal it looks like a
"sed" style hack will still be required to allow a set of sibling packages
to point to one another.

  -Ryan

On Tue, Apr 24, 2012 at 8:51 PM, Ryan Newton  wrote:

> This is sort of related to ticket #130:
>
>http://trac.haskell.org/haddock/ticket/130
>
> And this one seems to hint at a solution to the problem in the more
> extensive syntax for --read-interface.
>
>   http://hackage.haskell.org/trac/ghc/ticket/3810
>
> (My local haddock-2.10.0 --help doesn't mention this.  But I'll give it a
> whirl.)
>
>
>
> On Tue, Apr 24, 2012 at 8:34 PM, Ryan Newton  wrote:
>
>> Hello cafe,
>>
>> For various reasons, some packages don't build documentation on hackage:
>>
>>http://hackage.haskell.org/package/accelerate
>>
>> Therefore I want to locally install documentation for a set of packages
>> like this and host them on a separate website.  I want all of these ~ten
>> packages' haddock documentation to be properly interlinked with eachother,
>> but also to link to Hackage for types and classes defined in other modules.
>>
>> Is this possible?  Hackage haddocks are all interlinked, but that is
>> simply because hackage is one giant local install, right?
>>
>> If it's not possible (and it seems not) do any haddock devs have pointers
>> on how to implement this?
>>
>> Thanks,
>>   -Ryan
>>
>> P.S.  Someone recommended to me the following simple hack -- just use sed
>> to rewrite the links after haddock generates the html.  I think I'll do
>> that for the time being unless someone has a better suggestion.
>>
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: signed-multiset-0.1

2012-04-25 Thread Stefan Holdermans
Wren, Sjoerd,

>>> This is not just about map, but it also a problem for the Monoid instance. 
>>> You are basically adding an extra identity element, 0, to the max monoid, 
>>> which works but is weird.

>> Still that's how union is typically defined for hybrid sets. It's what 
>> happens if want union and empty to behave as generalisations of these 
>> concepts for ordinary (multi)sets.

> Why? Whenever I've dealt with bags, the appropriate way to handle collision 
> on union has been to use addition--- not maximization. Ditto for all the 
> other set ops. Addition seems far more natural as the extension from basic 
> sets. The fact that you have negative multiplicities only underscores the 
> naturality of addition[1]. Why do you think max is natural?

The union of two sets is typically defined as the smallest set that is a 
superset of both the operands; this definition extends nicely for multisets and 
hybrid sets [1,2,3].

I do not recall claiming maximisation to be "natural"; what's natural for one 
application, may not be for another. The library provides both union (based on 
maximisation) and additive union, and furthermore gives Monoid instances over 
both of them. Not having a preference for either one of them, I thought that 
having both of them in the library made sense.

That said, my goal was never to upload a package that only leads to confusion 
and false expectations. As the common opinion seems to be that a maximising 
union is bad, I will drop it from the library and deprecate the package on 
Hackage.

Thanks for your feedback,

  Stefan

[1] Wayne D. Blizard: Multiset Theory. Notre Dame Journal of Formal Logic 
30(1): 36-66 (1989)
[2] Wayne D. Blizard: Negative Membership. Notre Dame Journal of Formal Logic 
31(3): 346-368 (1990)
[3] Apostolos Syropoulos: Mathematics of Multisets. WMP 2000: 347-358
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] JSON library suggestions?

2012-04-25 Thread Vincent Hanquez

On 04/24/2012 09:46 PM, Jeff Shaw wrote:

Hello,
Up until now I've been using Aeson, but I've found that its number type isn't 
going to work for me. I need to use decimal numbers while avoiding conversions 
from and to Double, which Aeson doesn't allow. There are quite a few more JSON 
libraries for Haskell, which all appear to use Rational for numbers, so I'm 
wondering if anyone can recommend one.


Hi,

Not sure that's helpful to you since it's a C binding solution, but i haven't 
found anything that i could use related to JSON in Haskell since i wanted:


- event based parsing.
- DoS protection.
- integer and float represented as array of bytes.
- and last but not least break neck speed.

so i ended up binding my own C embedded library [1]. I could clean up my ugly 
bindings and publish it somewhere if it's useful.
I do have a plan, someday, to experiment with a rewrite in haskell using the 
exact same technique but the will and time to do so have lacked so far.


[1] https://github.com/vincenthz/libjson

--
Vincent

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


Re: [Haskell-cafe] static linking with ghc?

2012-04-25 Thread Ketil Malde
Johannes Waldmann  writes:

> A similar thing is mentioned here (see Caveat)
> http://www.haskell.org/haskellwiki/Web/Literature/Static_linking

Another caveat is that shared linking isn't very useful on Linux, since
the C library loads various stuff dynamically anyway.  It'd be great to
be able to link to a different C library (maybe something from the
BSDs?).

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

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