David Luposchainsky | 23 May 2013 21:39

2014 Applicative => Monad proposal

Hello libraries,

it's on! Time to tackle the Applicative-Monad issue, hopefully once and
for all. Over the last couple of weeks I've looked through previous
proposals, asked #haskell about their opinions, and compiled it all into
one file that sums up what I made of that. It's a bit long for an email
and uses markdown, so I'll just provide links at the end of this mail
instead of pasting it in here. In there, the whole thing and how to
approach it is explained in more detail. Here's an abstract of what it
the proposal consists of:

- Don't break compatibility
- Apply it gently

- Applicative m => Monad m
- Applicative into Prelude (and therefore into the Report)
- (Alternative m, Monad m) => MonadPlus m
- Promote `join` into the Monad typeclass

Let's make this happen! I'm going to give a ballpark discussion period
of four weeks, but since I can imagine this discussion could become
quite complex we shouldn't take it too serious. I'll summarize what's
been going on periodically though.

David

Links:

The proposal text on Github (link fixed, sorry for the deadlink yesterday):
https://github.com/quchen/articles/blob/master/applicative_monad.md
(Continue reading)

malcolm.wallace | 23 May 2013 14:26
Gravatar

Re: Making decisions

Fine in theory, but in practice when changes to the Prelude have been made previously, they have indeed
affected the haskell98 and haskell2010 packages that have subsequently shipped with ghc.

See for instance:

http://www.haskell.org/ghc/docs/7.6.2/html/users_guide/bugs-and-infelicities.html#haskell-standards-divergence

Num superclasses
The Num class does not have Show or Eq superclasses. You can make code that works with both
Haskell98/Haskell2010 and GHC by: [workaround described]
Bits superclasses
The Bits class does not have a Num superclasses. It therefore does not have default methods for the bit, testBit and popCount methods.
You can make code that works with both Haskell2010 and GHC by: [workaround described]
Regards,
    Malcolm

On 23 May, 2013,at 09:23 AM, Edward Kmett <ekmett <at> gmail.com> wrote:

Note, the haskell98 and haskell2010 packages would be unaffected by this proposal as it stands.

The (repeatedly raised in this thread) Applicative as a superclass of Monad situation on the other hand,
sadly does impact them.

-Edward

On Thu, May 23, 2013 at 4:19 AM, Henning Thielemann <lemming <at> henning-thielemann.de> wrote:

On Thu, 23 May 2013, Simon Peyton-Jones wrote:

 So there's a decision-making vacuum for the "GHC HQ" libraries.  If that's the case, then the best thing
(Continue reading)

Simon Peyton-Jones | 23 May 2013 09:48
Picon
Favicon
Gravatar

Making decisions

This "burning bridges" thread has really got us going!  

I'm a bit concerned, though, that we don't have an effective mechanism for resolving such debates.  If
everyone feels that they have a vote, perhaps, but only one among many, then one feels either mandated or
indeed willing to invest the extra cycles to summarise pros and cons based on feedback, crisply
articulate alternatives, and so on.   And, worse still, no one feels mandated to actually decide anything.  
That's fine when there's a clear consensus; not so fine when there isn't, as here.  Several people on the
"Burning bridges" thread have commented on the interminable nature of the debate.

Our general procedures for library changes are described here:
http://www.haskell.org/haskellwiki/Library_submissions.  For specialised libraries (eg MD5
checksum, or even containers) the situation is clear: the author or current maintainer decides.

But for the basic core libraries, whose influence is pervasive, matters are murkier.  Looking at
http://www.haskell.org/haskellwiki/Library_submissions#The_Core_Libraries we see that many are
maintained by "GHC HQ".  But the plain fact is that GHC HQ is not up to the task, especially now that Simon M has
moved on to Facebook.   To be absolutely explicit, I'm worried that decision making may get stuck because I
don't have the capacity to participate, lead, drive, propose, and ultimately make a decision.  So there's
a decision-making vacuum for the "GHC HQ" libraries.  If that's the case, then the best thing is for GHC HQ to
get out of the way!

Is that what others feel, or are you all happy?   My proposal would be to form a Library Tsars committee, that
* Takes ownership of the "GHC HQ" libraries
* Also owns any global library issues; ones that can't be resolved
    by a single maintainer

Like any maintainer the Library Tsars would be expected to follow the guidance on the wiki
http://www.haskell.org/haskellwiki/Library_submissions#Guidance_for_maintainers
(responsiveness, consultation, etc).  But they could actually decide things. 

(Continue reading)

Casey McCann | 22 May 2013 21:01

Votes for generalizing mapM &c.

On Wed, May 22, 2013 at 8:12 AM, Ian Lynagh <ian <at> well-typed.com> wrote:
> On Wed, May 22, 2013 at 11:49:29AM +0800, John Lato wrote:
>>
>> I suggest that we start a poll for a single, concrete proposal.  If the
>> poll forum is by email or similar, I further suggest that replies be
>> limited strictly to +1/-1.

Here are the current totals by my count, ignoring any 0s:

> * Generalise Prelude.mapM etc

+13 / -0

> * Remove Prelude.mapM etc

+1 / -11

> * Add more monomorphic variants to Prelude (e.g. whenJust)

+0 / -12

> * Nothing

+0 / -13

- C.
Merijn Verstraaten | 22 May 2013 17:44
Picon
Gravatar

Re: Burning bridges

+1 Generalize Prelude
-1 Remove from Prelude
-1 Add more monomorphic stuff
-1 Do nothing

On May 22, 2013, at 16:39 , libraries-request <at> haskell.org wrote:
> 
> Date: Wed, 22 May 2013 10:23:21 -0400
> From: Edward Kmett <ekmett <at> gmail.com>
> Subject: Re: Burning bridges
> To: Tom Murphy <amindfv <at> gmail.com>
> Cc: Ian Lynagh <ian <at> well-typed.com>,	"libraries <at> haskell.org"
> 	<libraries <at> haskell.org>
> Message-ID:
> 	<CAJumaK-veN80hcW1jV7Zfri-hzHt9iaDoPkU=Z+tVrJQfkT9pQ <at> mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
> 
> +1 Generalise Prelude.mapM etc
> -1 Remove Prelude.mapM etc
> -1 Add more monomorphic variants to Prelude (e.g. whenJust)
> -1 Nothing
> 
> 
> On Wed, May 22, 2013 at 9:24 AM, <amindfv <at> gmail.com> wrote:
> 
>> 
>> 
>> El May 22, 2013, a las 8:12 AM, Ian Lynagh <ian <at> well-typed.com> escribi?:
>> 
>>> On Wed, May 22, 2013 at 11:49:29AM +0800, John Lato wrote:
(Continue reading)

Mark Lentczner | 22 May 2013 07:12
Picon

Re: foldable flexible bridges (putting foldable+traversable in prelude) Re: Burning bridges

Ay yi yi!

A few thoughts on all of this:

1) Rather than guessing how much will or won't break - would some please just run this change (F/T in Prelude) over Hackage and do some analysis and stats? Sure, it doesn't represent all code - but it's a good start.

2) That there are so many Prelude replacements... and that none of them are worth it enough to induce people to add the two lines of code it takes to use 'em.... tells me that they don't have enough value.

3) Stability is very important to adoption of a language. People are very influenced by their first impressions of a system. We seem perilously close to "death by continuous little paper cuts" here: I saw the catch debacle snag tons of people and projects in tiny hiccups. If you were a newcomer to Haskell (experienced engineer or no) and you ran into this, I bet it was a turn off.

In generaly I'm against the constant evolution of Haskell. Revising the language every year (or even every two), and revising the core libraries and modules and Prelude piecemeal seem to me like recipes for avoiding success. Now that functional programming is gaining some notice in the wider engineering world, now would be the time to have the most stable, most "always just works", most reliable language of the lot. That probably means stability trumps warts. Not forever, but it means avoiding a constant stream of hiccups.

I think we'd be better served by "chunking" this stuff up over several years - and releasing it in well defined sets.

4) My reaction to the "monomorphism helps newbies" argument is always the same: Well then, let's just fix the error messages! 

- Mark
_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Mark Lentczner | 21 May 2013 18:15
Picon

HP 2013.2 - RC3 installers for OS X

The Mac OS X RC3 installers are up:

Only difference in these from RC2 is that the missing documentation for network, random, and primitive has been restored.

These will be the final, barring any catastrophic issue.

— Mark

15dd8762c9800308cb7cfdd16ea1a8e74988e06a  Haskell Platform 2013.2.0.0 32bit rc3.signed.pkg
89e6fb747816af69acabc5c04cee103257855614  Haskell Platform 2013.2.0.0 64bit rc3.signed.pkg

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Casey McCann | 21 May 2013 16:33

Re: Burning bridges

On Tue, May 21, 2013 at 2:57 AM, Edward Kmett <ekmett <at> gmail.com> wrote:
> Type inference has been raised as a factor, but I respectfully disagree that
> is is a problem in practice with (the bulk of) this proposal. A case may
> definitely be made that perhaps a few of the combinators, e.g. concat and
> concatMap should remain monomorphic, but by and large I feel it would
> dramatically reduce import confusion to only have base only contain one
> version of each combinator that it exports.

I would be interested to see a real example of existing code of
anywhere near production quality that would break due to type
inference issues.

For breakage to happen, the combinators must be used in such a way
that [] cannot be inferred by other means and an appropriate
Foldable/Traversable constraint cannot simply be inferred instead.
Neither class provides a means for constructing values of an instance
type ex nihilo and lacking anything like an Unfoldable class the "show
. read" situation is unlikely. Anything applied to a list will be
inferred in the usual manner. Definitions with no type signature,
subject to the DMR, and not used in the module that defines them
should be excluded by "anywhere near production quality".

Short of folding a list which was constructed entirely by way of
MonadPlus or similar I can't see where problems would arise. Am I
missing something here?

Beyond that, the argument that having redundant, less-polymorphic
versions of standard combinators is helping beginners has not become
any less ridiculous since the first time I heard it. These beginners
still have to cope with typos that lead to GHC suggesting nonsense
such as writing a Num instance for "[Char] -> a2", while on the other
hand unnecessary duplication and redundancy absolutely cause problems.
On more than one occasion I've explained to a beginner confused by the
difference between map and fmap that the sole reason they differ is to
avoid confusing beginners. Doubleplus ungood, my friends.

> Moreover, if Applicative can ever be made a superclass of Monad, half of the
> combinators in can Data.Traversable melt away and so can several of the ones
> in Data.Foldable, reducing the footprint further.

Which would be a fantastic improvement in multiple ways.

> I tend to disagree with Ian that mapM, etc. should simply be removed from
> the Prelude completely. Foldable and Traversable -- unlike almost everything
> being debated to death in the base split -- aren't things that require heavy
> machinery. There are no exceptions in them, nothing that is difficult to
> implement across platforms or compilers. The sum total of language support
> for them is the DeriveFoldable and DeriveTraversable extensions. They are
> also quite ingrained in the 'culture' of Haskell.

Those combinators (or the unnecessarily monomorphic counterparts
thereof) are also often used unqualified in code such as nearly all of
it, found in packages such as nearly all of them.

If we're going to remove mapM &c. from Prelude and thereby break
everything everywhere, we should at least do something useful along
with it, like replace the entire hierarchy of numeric classes.

> I for one would hate to lose them from the vocabulary of the Prelude.

I would hate to see the common vocabulary of Haskell code reduced.
Let's not invite the Tower of Babel scenario (any more than we already
do) where everyone has their own preferred set of libraries for common
tasks with no useful, mutually intelligible intersection between them.

For all its problems, the current Prelude at least provides a decent
foundation for accomplishing common tasks.

- C.
Carter Schonwald | 21 May 2013 09:25
Picon
Gravatar

Re: Burning bridges

well said, 


On Tue, May 21, 2013 at 2:57 AM, Edward Kmett <ekmett <at> gmail.com> wrote:
I raised the issue mostly to remind everyone that it still existed and that the status quo is quite awkward. I was going to let this rest, but as it seems to still be stirring up a passionate response, I felt it necessary to reply again.

I do strongly believe that bringing Foldable and Traversable into the Prelude and replacing the monomorphic variants would actually be a fairly painless change. 

During the transition some people would be forced to manage explicit import lists for their packages. We've paid for this with 'catch', the 'Num' transition, 'Bits', etc. and we're pretty good at managing this sort of change by now.

Type inference has been raised as a factor, but I respectfully disagree that is is a problem in practice with (the bulk of) this proposal. A case may definitely be made that perhaps a few of the combinators, e.g. concat and concatMap should remain monomorphic, but by and large I feel it would dramatically reduce import confusion to only have base only contain one version of each combinator that it exports.

The combinators in Data.Foldable and Data.Traversable simply subsume all of the other redundant versions of them that occur in base. 

Sure there are reasons why other libraries have chosen to replicate large portions of the API from Base for particular data types with particular constraints, but those are just that -- other libraries.

Moreover, if Applicative can ever be made a superclass of Monad, half of the combinators in can Data.Traversable melt away and so can several of the ones in Data.Foldable, reducing the footprint further.

I tend to disagree with Ian that mapM, etc. should simply be removed from the Prelude completely. Foldable and Traversable -- unlike almost everything being debated to death in the base split -- aren't things that require heavy machinery. There are no exceptions in them, nothing that is difficult to implement across platforms or compilers. The sum total of language support for them is the DeriveFoldable and DeriveTraversable extensions. They are also quite ingrained in the 'culture' of Haskell. 

I for one would hate to lose them from the vocabulary of the Prelude.

-Edward


On Tue, May 21, 2013 at 2:22 AM, Simon Peyton-Jones <simonpj <at> microsoft.com> wrote:
| I'm generally a staunch advocate of backward compatibility. However,
| these issues are ones where we've known the right answer for a long time
| (unlike refactoring the numeric type class hierarchy), and we've simply
| been unwilling to burn bridges in order to do the right thing. I love
| Haskell, and I respect the haskell' committee, but I think it's time to
| just burn it all down.
...
| With all that has changed in the last 15 years, I think it's high time
| to fork Haskell, tear off all the bandaids, and begin afresh.

I'm not sure what you are proposing, concrete, by "fork Haskell".

I think you are simply proposing some non-backward compatible library changes. Correct? And yes, it seems reasonable to do that every now and again. Indeed there's an active thread on splitting the base package http://hackage.haskell.org/trac/ghc/wiki/SplitBase, partly to make it easier to build a backward-compatible shim package.  So how non-backward-compatible would it all be?

I assume you guys have talked this to death, but is there no way to move on, while leaving a backward-compatible API?

Simon



_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Gabriel Gonzalez | 21 May 2013 07:41
Picon
Gravatar

Apologies

I want to apologize to wren (and everybody else).  I was tired and 
overreacted when the discussion started veering into making more 
breaking changes.

I don't mind the Foldable changes too much.  My main concerns are:

* loss of monomorphism makes teaching more difficult
* They can be generalized in other useful ways

However, I don't consider those concerns show-stoppers.
Carter Schonwald | 21 May 2013 07:06
Picon
Gravatar

foldable flexible bridges (putting foldable+traversable in prelude) Re: Burning bridges

lets see what concerns there are

1) will any code break? Nope! In fact, it's trivial to provide a shim that only exposes the list monomorphic versions. 

2) does the change make learning the language more challenging? No. In fact, i've encountered *many* more smart people getting confused as to why the map / fold etc in prelude are all list specific than i've seen people struggle with type classes. The various list specific versions of the foldable codes actually **confuses** smart software folks who are starting to learn haskell for fun. 

I can't explain to a smart engineer *any* reason why minimum :: Ord a => [a] -> a
exists in prelude. I *can* explain why something like minimum :: (Foldable t, Ord a) => t a -> a   would be useful and deserving of being in the standard prelue. 

 I've actually had to explain to a smart python engineering friend who's learning haskell this very problem. (that the list only versions are there for no deep reason aside from some pedagogical approach from over a decade ago that is no longer used) 

tl;dr  no code will break, there will be less inessential nonuniformity that doesn't aid in engineering or learning with haskell, so a win in every direction.

 lets make things happen.

-Carter

On Mon, May 20, 2013 at 11:04 PM, <amindfv <at> gmail.com> wrote:
Whoa! I don't think that replacing list-monomorphic functions in the prelude with more-general ones is going to cause the community to split down the middle!

Most of the changes we're talking about won't even break any legacy code! Of course, some typeclass-rearranging will break things, but not the prelude replacements that we've been discussing. The biggest impact is that existing teaching texts may have old information about the type signatures of standard functions.

As much as I *love* imagining the Haskell community in a bridge-burning, rival GHC HQ deathmatch (Simon vs. Simon! Edward vs. Edward!), I really think this change won't attract the interest of any tabloids.

That said, I definitely agree that it should take more than a few +1s to move this forward. I'd suggest a relative-consensus on the libraries list, then a "Here's our plan; are we crazy?" email on haskell-cafe.

Tom


El May 20, 2013, a las 6:59 PM, Felipe Almeida Lessa <felipe.lessa <at> gmail.com> escribió:

> IMHO, the problem is that the community isn't large enough to be able
> to suffer a split.  Case in point: how are we going to have two GHC
> HQs?
>
> If we're going to burn bridges, perhaps we should follow a
> Python-3-esque path of releasing a major upgrade together with:
>
>  - A refactoring tool to aid with the transition.
>
>  - A deadline of, say, 2-3 years during which the latest GHC for
> current Haskell would receive bugfixes while GHC 8 moves along as
> usual.
>
> Cheers,
>
> On Mon, May 20, 2013 at 7:49 PM, wren ng thornton <wren <at> freegeek.org> wrote:
>> On 5/19/13 7:25 PM, Anthony Cowley wrote:
>>>
>>> I think this issue may be too big to rely on mailing list +1s. Is there
>>> any precedent for having a web-based poll of some sort? We often get more
>>> engagement in debates on IRC and /r/haskell than the mailing list, so let's
>>> not let the choice of forum drive the result.
>>
>>
>> Indeed.
>>
>> Personally, I'm all for blessing Foldable/Traversable as "built-in" and
>> getting rid of the monomorphic legacy. But then, I'm also all for making
>> Applicative a superclass of Monad, not having all the mtl modules re-export
>> everything from Control.Monad, etc. However, all of these issues have a long
>> history of discord, and that discord cannot be resolved on this list IMO.
>>
>> I'm generally a staunch advocate of backward compatibility. However, these
>> issues are ones where we've known the right answer for a long time (unlike
>> refactoring the numeric type class hierarchy), and we've simply been
>> unwilling to burn bridges in order to do the right thing. I love Haskell,
>> and I respect the haskell' committee, but I think it's time to just burn it
>> all down.
>>
>> Let us not forget the original reasons for many of these warts. Some of them
>> stem from ignorance or oversight (superclasses of Monad); others stem from
>> the desire to help newcomers (monomorphism); and others stem from
>> circularities in the language definition (the existence of the Prelude). As
>> Haskell has developed, we have learned more ---therefore we should not
>> embrace prior ignorance---, our standard idioms have evolved ---therefore
>> clinging to list-monomorphism *causes* confusion rather than alleviating
>> it---, and we've tried to remove much of the circularity involved in
>> desugaring the various built-in notations for lists, arithmetic sequences,
>> do-notation, etc.
>>
>> With all that has changed in the last 15 years, I think it's high time to
>> fork Haskell, tear off all the bandaids, and begin afresh. This won't solve
>> all the problems, of course. We will still despair of the numeric hierarchy;
>> we will still despair of the partial functions demanded by the Haskell spec;
>> we will still worry about how to resolve things like MPTCs, type families,
>> and all that. But at least we can finally put these particular ghosts to
>> rest. Alas, to fork the language is to split the community. And while I
>> advocate such drastic measures, they are measures which cannot be resolved
>> either on this list or by the (intentionally conservative) haskell'
>> committee.
>>
>> --
>> Live well,
>> ~wren
>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries <at> haskell.org
>> http://www.haskell.org/mailman/listinfo/libraries
>
>
>
> --
> Felipe.
>
> _______________________________________________
> Libraries mailing list
> Libraries <at> haskell.org
> http://www.haskell.org/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries

Gmane