Re: [Haskell-community] Civility notes (was "Traversable instances for (, , ) a b")

2017-04-30 Thread Tony Morris


On 28/04/17 19:49, lennart spitzner wrote:
> the case of hiding behind "it was a dumb joke" followed by what in my
>eyes reads like a dishonest apology. But I am not certain and perhaps
>unfair.
>
>We will not accept retroactively hiding behind
>'it was a joke'."
>
>
> (Sorry, Tony, 

Thank you for your incredibly genuine apology. Please leave me out of
this discussion.



signature.asc
Description: OpenPGP digital signature
___
Haskell-community mailing list
Haskell-community@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-community


[Haskell] GHC is a monopoly compiler

2016-09-26 Thread Tony Day
I would argue that the adventure that is GHC is a natural monopoly - an
example of collaboration trumping competition.  Certainly the results speak
for themselves, and I personally find it the most satisfying, the only sane
way to practice the craft of coding.  So, as an enthusiastic user of a
monopolistic service (the best power to weight ratio I could find to
misquote Kmett), I would like to suggest to the community that we have a
respectful discussion on the implications of natural monopolies.

Monopolies have their problems.  They create power imbalances that need
active management to control.  A community should be particularly wary of
monopolies attempting to vertically integrate up the production chain into
areas where a monopoly makes less sense.  I would call the whole cabal
versus stack drama a text-book case of over-reach. Everyone agrees stack
operates at a higher level of abstraction then cabal, on top of it is
accurate.  Cabal shouldn't even be allowed to compete above it's current
abstraction point.

Haddock is another example of being blessed by ghc.  It hits a corner-case
of perfection for the "I'm a hackage library" monopoly.  But the outside
world of documentation, editing, rendering and conversion is invisible to
this monopolistic use case. We are forced to learn and use haddock, and,
for those of us with documentation needs outside hackage, the resultant
workflow is cruel and unusual.

GHC is a great compiler, but should actively be discouraged from
monopolizing the associated tooling and documentation chains.  There is
evidence of healthy open-source competition and significant gains to be
had, and Haskell runs the risk of missing out.
___
Haskell mailing list
Haskell@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell


Re: Breaking Changes and Long Term Support Haskell

2015-10-21 Thread Tony Morris
Thanks Dan and others on CLC for your hard work and endurance.


On 22/10/15 07:48, Simon Peyton Jones wrote:
> While we are here, let me say
> 
>   A BIG THANK YOU TO THE CORE LIBRARIES COMMITTEE
> 
> Library design has a lot of detail, and a lot of competing priorities.  I am 
> personally very grateful to the CLC for the work they put into this. Like 
> many crucial tasks it's one that often seems to attract more complaints than 
> thanks, but they are doing us all a huge service, and at significant cost in 
> terms of their most precious and inelastic commodity: their personal time.
> 
> Remember, as Dan says, before the CLC we no process whatsoever for library 
> evolution... various people made various patches, and there was no way of 
> getting anything substantial done.  So we are far far further on than before.
> 
> Still not perfect, as my last post said. But still: THANK YOU.
> 
> Simon
> 
> | -Original Message-
> | From: Dan Doel [mailto:dan.d...@gmail.com]
> | Sent: 21 October 2015 22:23
> | To: Geoffrey Mainland
> | Cc: Simon Peyton Jones; Augustsson, Lennart; Henrik Nilsson; haskell-
> | pr...@haskell.org List; Haskell Libraries
> | Subject: Re: Breaking Changes and Long Term Support Haskell
> | 
> | Hello,
> | 
> | I'm Dan Doel. I'm on the core libraries committee (though I'm speaking
> | only for myself). As I recall, one of the reasons I got tapped for it
> | was due to my having some historical knowledge about Haskell; not
> | because I was there, but because I've gone back and looked at some old
> | reports and whatnot (and sometimes think they're better than what we
> | have now).
> | 
> | But, I was around (of course) when the core libraries committee
> | started up, so perhaps I can play the role of historian for this as
> | well.
> | 
> | The reason the committee exists is because a couple years ago, people
> | brought up the ideas that were finally realized in the
> | Applicative-Monad proposal and the Foldable-Traversable proposal. A
> | lot of people weighed in saying they thought they were a good idea,
> | and significantly fewer people weighed in saying they thought that it
> | shouldn't happen for various reasons---roughly the same things that
> | people are still bringing up about these proposals.
> | 
> | This wasn't the first time that happened, either. I think it was
> | widely agreed among most users that Functor should be a superclass of
> | Monad since I started learning Haskell around 10 years ago. And once
> | Applicative was introduced, it was agreed that that should go in the
> | middle of the two. But it appeared that it would never happen, despite
> | a significant majority thinking it should, because no one wanted to do
> | anything without pretty much unanimous consent.
> | 
> | So, one question that got raised is: why should this majority of
> | people even use Haskell/GHC anymore? Why shouldn't they start using
> | some other language that will let them change 15-year-old mistakes, or
> | adapt to ideas that weren't even available at that time (but are still
> | fairly old and established, all things considered). And the answer was
> | that there should be some body empowered to decide to move forward
> | with these ideas, even if there is some dissent. And frankly, it
> | wasn't going to be the prime committee, because it hadn't shown any
> | activity in something like 3 years at the time, and even when it was
> | active, it didn't make anywhere near the sort of changes that were
> | being discussed.
> | 
> | And the kicker to me is, many things that people are complaining about
> | again (e.g. the FTP) were the very things that the committee was
> | established to execute. I don't think we had a formal vote on that
> | proposal, because we didn't need to. Our existence was in part to
> | execute that proposal (and AMP). And then a year ago, when it was
> | finally time to release the changes, there was another ruckus. And we
> | still didn't have a CLC vote on the matter. What we did was conduct a
> | community poll, and then SPJ reviewed the submissions. But I don't
> | mean to pass the buck to him, because I'm pretty sure he was worried
> | that we were crazy, and overstepping our bounds. Just, the results of
> | the survey were sufficient for him to not overrule us.
> | 
> | So my point is this: there seems to be some sentiment that the core
> | libraries committee is unsound, and making bad decisions. But the
> | complaints are mostly not even about actual decisions we made (aside
> | from maybe Lennart Augustsson's, where he is unhappy with details of
> | the FTP that you can blame on us, but were designed to break the least
> | code, instead of being the most elegant; if we had pleased him more,
> | we would have pleased others less). They are about the reasons for
> | founding the committee in the first place. You can blame us, if you
> | like, because I think it's certain that we would have approved them if
> | we had formally voted. We just 

Re: Monad of no `return` Proposal (MRP): Moving `return` out of `Monad`

2015-10-05 Thread Tony Morris
I have used Haskell for teaching for years.

Until recently, I taught the hierarchy using a semigroup model.

Functor <- Apply <- Applicative
Apply <- Bind <- Monad

https://github.com/NICTA/course/tree/ee8d1a294137c157c13740ac99a23a5dd5870b4a/src/Course

I did this because it means curious students don't need to receive an
explanation of the historical accidents of Haskell had I modelled it in
accordance with Haskell pre-AMP. Doing so has caused confusion (I tried
it, many years ago).

Since AMP implementation, I have changed the hierarchy to be the same as
Haskell proper, since the benefit has become worth doing.

https://github.com/NICTA/course/issues/164

I am in favour of breaking changes as hard as you can, if it achieves a
progressive benefit, even a small one, which this does. It also achieves
an incidental benefit in the context of teaching.

As it stands for industry use, I remove Prelude and model all this
properly anyway. It is a significant effort, but way worth it e.g. do
not require return to use do-notation. The penalty for having to do this
is often under-estimated. "Breaking changes" is over-stated.

Patience. I am waiting.

On 05/10/15 19:30, Malcolm Wallace wrote:
> On other social media forums, I am seeing educators who use Haskell as a 
> vehicle for their main work, but would not consider themselves Haskell 
> researchers, and certainly do not have the time to follow Haskell mailing 
> lists, who are beginning to say that these kinds of annoying breakages to the 
> language, affecting their research and teaching materials, are beginning to 
> disincline them to continue using Haskell.  They are feeling like they would 
> be less well disposed to reviewing papers that use Haskell, and less well 
> disposed to collaborating on writing papers that involve Haskell.
> 
> Please can the Haskell Prime Committee take into account the views of such 
> "peripheral" users of the language, who after all, form some measure of its 
> recent "success".  Haskell is a real-world tool for many people, and breakage 
> of their code, and their sources of information about Haskell, is a powerful 
> disincentive to continue with it.
> 
> Regards,
>Malcolm
> 
> 
>> On 5 Oct 2015, at 10:05, Malcolm Wallace wrote:
>>
>>> I am also a strong -1 on small changes that break huge numbers of things 
>>> for somewhat trivial benefits.
>>>
>>> Regards,
>>>   Malcolm
>>>
>>> On 2 Oct 2015, at 11:09, Henrik Nilsson wrote:
>>>
 Hi all,

 I have discussed the monad of no return proposal with
 my colleague Graham Hutton: a long-standing member of
 the Haskell community, well-known researcher, some 20
 years of experience of teaching Haskell to
 undergraduate students, and author of one of the most
 successful introductory Haskell textbooks there are.

 The upshot of this e-mail is a strong collective -2
 from us both on particular proposal, and a general call
 for much more caution when it comes to breaking changes
 that are not critically important.

 First, on a general note, there has recently been a
 flurry of breaking changes to the (de facto) Haskell
 standards. In many cases for very good reasons, but
 sometimes it seems more in a quest for perfection
 without due consideration for the consequences. It used
 to be the case that breaking changes were very rare
 indeed. And for good reason.

 Right now, the main "measure of breakage" in the
 on-line discussions seems to be how many packages that
 break in Hackage. Which of course makes sense: the
 Hackage repository is very important and such a measure
 is objective, as far as it goes.

 But we should not forget that breakage can go far
 beyond Hackage. For starters, there is *lots* of code
 that is not in Hackage, yet critically important to its
 users, however many or few they are. There are more
 than hundreds of thousands of copies of books out there
 where that may break in that examples may no longer
 work. And they cannot be changed. There are countless
 research papers that may break in the same way. Every
 single institution that use Haskell in their teaching
 may have to update their teaching materials (slides,
 code, lab instructions) for every module that teaches
 or uses Haskell. And last but not the least, what
 countless of programmers and students have learned
 about Haskell over decades, most of whom are *not*
 power users who can take these changes in their stride,
 may also break.

 Now, of course a language has to evolve, and sometimes
 breaking backwards compatibility is more or less
 essential for the long-term benefit of the language.
 But we should not let perfection be the enemy of the
 good.

 As to this particular proposal, the monad of no return,
 it does not seem essential to us, but mostly motivated
 by a quest for 

Re: Monad of no `return` Proposal (MRP): Moving `return` out of `Monad`

2015-10-05 Thread Tony Morris
"Broken" here is hyperbole for "can be significantly improved for very
little penalty."


On 05/10/15 23:16, Brandon Allbery wrote:
> 
> On Mon, Oct 5, 2015 at 8:16 AM, Alexander Berntsen  > wrote:
> 
> On 05/10/15 11:59, Simon Thompson wrote:
> > There’s an old fashioned maxim that sums this up in a pithy way:
> > “if it ain’t broke, don’t fix it”.
> But... it *is* broken.
> 
> 
> Somehow, we managed to use Monad before this. That does not sound "broken".
> 
> -- 
> brandon s allbery kf8nh   sine nomine associates
> allber...@gmail.com 
>  ballb...@sinenomine.net 
> unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
> 
> 
> ___
> Haskell-prime mailing list
> Haskell-prime@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
> 
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime


Re: [Haskell-cafe] Using lenses

2013-10-03 Thread Tony Morris
Lenses for nested sum types e.g. Either.
 On 03/10/2013 6:08 PM, Simon Peyton-Jones simo...@microsoft.com wrote:

  (I sent this to ‘libraries’ but Kim-Ee suggested adding Café, where so
 many smart people hang out.)

 ** **

 Friends

 ** **

 Some of you will know that I’ve promised to give a talk about Edward’s
 lens library http://hackage.haskell.org/package/lens at the Haskell
 Exchange http://skillsmatter.com/event/scala/haskell-exchange in London
 next Wednesday (9th).  I did this to give everyone (including me) a break
 from GHC hackery, and also to force me to learn about this lens voodoo that
 everyone is twittering about.  Edward generously gave me quite a bit of
 one-to-one attention last week (my hair is still standing on end), but this
 message is to ask your help too.


 *Specifically, I’d like to give some compelling use-cases*.   If you are
 using the lens library yourself, could you spare a few minutes to tell me
 how you are using it?  I expect to cover Lens and Traversal but not Prism.
 

 ** **

 The use-case everyone starts with is nested records, but I’d like to go
 beyond that.  The next levels seem to be:

 **· **Lenses as views of data that isn’t “really there” e.g.
 regarding a record with rectangular coordinates as having polar coordinates
 too.

 **· **Lenses and Traversals that focus on elements of finite maps
 (Control.Lens.At)

 ** **

 What else? I’m sure you are using them in all sorts of cool ways that I
 would never think of, and I’d love to know.

 ** **

 Please don’t tell me anything secret!  To give everyone the benefit I may
 just concatenate all the replies and send to you all, so please say if you
 don’t want me to do that with yours. 

 ** **

 And don’t burn too many cycles on this...I don’t want to waste your time,
 and I can always get back to you if I can’t understand what you say.
 Sooner is better than later...Weds is coming.

 ** **

 Simon “Edward’s prophet” PJ

 ** **

 ___
 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] Traversals of monomorphic containers

2013-09-03 Thread Tony Morris
These questions are exactly what Control.Lens answers.
 On 04/09/2013 12:50 PM, Mario Blažević blama...@acanac.net wrote:

 On 09/02/13 06:53, Nicolas Trangez wrote:

 # Redirected to haskell-cafe

 On Sun, 2013-09-01 at 14:58 +0400, Artyom Kazak wrote:

 Would this be an appropriate place to propose adding mapM_ (and then
 possibly mapM) to bytestring library?

 Was it suggested before? If yes, why was it rejected?


 This got me wondering: there are several type-classes useful for
 polymorphic container types, e.g. Functor, Foldable  Traversable which
 all apply to some type of kind (* - *).

 Are there related things for monomorphic containers, like ByteString,
 Text or some newtype'd Vector with fixed element type, e.g.

 class MFunctor f a where
  mfmap :: (a - a) - f - f

 instance MFunctor ByteString Word8 where
  mfmap = ByteString.map



 I'm not aware of this particular class, but I have considered it.
 In the end I've chosen to generalize the class to FactorialMonoid instead:

 class Monoid m = FactorialMonoid m where
...
foldMap :: Monoid n = (m → n) → m → n

 ByteString and Text are instances of the class, and so are lists,
 maps, and other containers, and Sum and Product as well.


 http://hackage.haskell.org/**packages/archive/monoid-**
 subclasses/0.3.2/doc/html/**Data-Monoid-Factorial.htmlhttp://hackage.haskell.org/packages/archive/monoid-subclasses/0.3.2/doc/html/Data-Monoid-Factorial.html




 or (maybe even better)

 class MFunctor f where
  type Elem
  mfmap :: (Elem - Elem) - f - f

 instance MFunctor ByteString where
  type Elem = Word8
  mfmap = ByteString.map

 and similar for other classes.

 Nicolas


 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe



 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://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] mapFst and mapSnd

2013-05-31 Thread Tony Morris
class BinaryFunctor f where
  bimap :: (a - c) - (b - d) - f a b - f c d

mapFst = (`bimap id`)
mapSnd = bimap id
 On 31/05/2013 12:16 PM, Shachaf Ben-Kiki shac...@gmail.com wrote:

 On Thu, May 30, 2013 at 7:12 PM, Shachaf Ben-Kiki shac...@gmail.com
 wrote:
  One generalization of them is to lenses. For example `lens` has
  both, _1, _2, such that mapPair = over both, mapFst = over
  _1, etc., but you can also get fst = view _1, set _2 = \y' (x,_)
  - (x,y'), and so on. (Since both refers to two elements, you end
  up with view both = \(x,y) - mappend x y.) The types you end up
  with are simple generalizations of mapFoo, with just an extra Functor
  or Applicative (think mapMFoo):
 
  both :: Applicative f = (a - f b) - (a,a) - f (b,b)
  both f (x,y) = (,) $ f x * g y
 
  _2 :: Functor f = (a - f b) - (e,a) - f (e,b)
  _2 f (x,y) = (,) x $ f y
 
  With an appropriate choice of f you can get many useful functions.
 

 I spoke too quickly -- your mapPair is something different. Indeed
 bimap (or (***), if you prefer base) is the place to find it -- lenses
 don't really fit here. My both is for mapping one function over both
 elements.

 Shachaf

 ___
 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] LambdaJam 2013

2013-03-04 Thread Tony Morris
Hey haskell guys,
LambdaJam 2013 is a functional programming conference to be held in
Brisbane in early May.

Call for submissions ends this Friday 08 March. If you are planning to
make a submission, please make sure you do soon!

If you are stuck somehow, I'd love to be able to help you get to the
goal. So feel free to send me an email or I am on IRC (dibblego),
lurking around the #haskell channel or privmsg if you like. Personally,
I would love see more haskell submissions :)

LambdaJam2013 call for papers:
http://www.yowconference.com.au/lambdajam/Call.html

-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] CoArbitrary

2013-02-10 Thread Tony Morris
On 09/02/13 15:08, Roman Cheplyaka wrote:
 I don't think the question was about generating functions...
 FWIW, both QuickCheck and SmallCheck generate functions. There was also
 an interesting paper at the last ICFP by Koen related to this.

 But I think Tony is looking for some kind of a pattern here...

 Roman

 * Stephen Tetley stephen.tet...@gmail.com [2013-02-09 10:50:45+]
 I think GAST - the Clean equivalent of Quickcheck - generates
 functions. There are certainly quite a few papers by members of the
 Clean team documenting how they generate them.

 On 9 February 2013 07:07, Tony Morris tonymor...@gmail.com wrote:
 [...]
 I hope I have phrased this in a way to make the point. I found it a bit
 difficult to articulate and I do wonder (hope!) that others encounter
 similar scenarios. Thanks for any tips!
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
Yeah I am looking for a possible pattern. I am struggling to explain the
problem. Perhaps some code will help.

This code compiles, however the function problem is the one I am
looking for. There are two data structures here:
1) Op, which is a functor
2) FreeOp, which is a monad that arises from the Op functor (i.e. an
instance of the free monad)

There are some functions for demonstration:
1) productOp -- An example of zipping two FreeOp instances, just to show
that you can (though, this is trivial by the monad)
2) booleanOp -- Produces a FreeOp Bool by using the IntOp constructor for Op
3) coproductOp -- An example of splitting out two FreeOp instances, to
show this is possible too.

* The question is, what about a function FreeOp b - FreeOp (a - b)?
* Can I constrain the 'a' type variable somehow to come up with
something similar to CoArbitrary (QuickCheck)?
* Can I generalise this idea i.e. not just FreeOp? Or for CoArbitrary,
not just for Gen?
* Is there a pattern here that is currently not part of my mental tool
kit? I am struggling to see it; maybe just it's not there.

As always, thanks for any pointers!

Begin code...


data Op a =
  DoubleOp (Double - a)
  | IntOp (Int - a)

data FreeOp a =
  Suspend (Op (FreeOp a))
  | Point a

 examples

productOp ::
  FreeOp a
  - FreeOp b
  - FreeOp (a, b)
productOp a b =
  do a' - a
 b' - b
 return (a', b')

boolOp ::
  FreeOp Bool
boolOp =
  Suspend (fmap Point (IntOp even))

coproductOp ::
  FreeOp a
  - FreeOp b
  - FreeOp (Either a b)
coproductOp a b =
  boolOp = \p - if p then fmap Left a else fmap Right b

 The Problem

problem ::
  -- ? c =
  -- ? other arguments
  FreeOp b
  - FreeOp (a - b)
problem =
  error what constraints on 'a' to allow an implementation of this
function that uses the argument?
  -- fmap const -- type-checks, but ignores the argument, unlike e.g.
QuickCheck which uses CoArbitrary to perturb that result with the
argument.

 support libraries

instance Functor Op where
  fmap f (DoubleOp g) =
DoubleOp (f . g)
  fmap f (IntOp g) =
IntOp (f . g)

instance Functor FreeOp where
  fmap f =
(=) (return . f)

instance Monad FreeOp where
  return =
Point
  Suspend o = f =
Suspend (fmap (= f) o)
  Point a = f =
f a


-- 
Tony Morris
http://tmorris.net/


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


[Haskell-cafe] CoArbitrary

2013-02-08 Thread Tony Morris
Hello,
In the QuickCheck library, there is a type-class called CoArbitrary. It
is defined like so:

class CoArbitrary a where
  coarbitrary :: a - Gen b - Gen b -- Gen is a monad

Its purpose is to allow generation of functions. In other words, for
taking Gen x - Gen (a - x), which could be done rather degenerately
(fmap const) but QuickCheck constrains with (CoArbitrary a) to perturb
the resulting value instead of ignoring (const) it.

It has always puzzled me in the general sense of thinking about the
scenario: f x - f (a - x) and whether the CoArbitrary is a
good/general solution, perhaps for the specific case of f=Gen or maybe
even more generally.

-- approximate
(a - f x - f x) -- e.g. CoArbitrary to perturb the result
- f x -- e.g. Gen x
- f (a - x) -- e.g. Gen (a - x)

So I often wonder about what might be a better (and perhaps more
general) constraint to produce functions f x - f (a - x) for a given
Monad f. I was wondering if there is an existing abstraction (or paper)
that might point me in that direction. It is a problem that I encounter
on occasion in general programming and I am using Arbitrary/CoArbitrary
as an example to help make my point, but I am dissatisfied (for reasons
that I am unsure about) with the solution provided by CoArbitrary.

What about other monads? For example, what is a general constraint to be
placed to permit a function Maybe x - Maybe (a - x) that does not
simply const away the argument.

I hope I have phrased this in a way to make the point. I found it a bit
difficult to articulate and I do wonder (hope!) that others encounter
similar scenarios. Thanks for any tips!

-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Control.bimap?

2012-12-12 Thread Tony Morris
Check out Control.Lens on hackage.

On 13/12/12 07:54, Gregory Guthrie wrote:

 I found a nice idiom for a graph algorithm where the pairs of nodes
 representing links could be merged into node lists by something like:

 ns = nub $ map fst  g--head nodes

 ne = nub $ map snd g   -- tail nodes

  

 And found a nicer approach:

(ns,ne) = (nub***nub) unzip g

 Or perhaps:

(ns.ne) = bimap nub nub $ unzip g-- from Control.Bifunctor

  

 The SO reference I saw described bimap as a way to map a function over
 a pair, and it seemed like a great match, but I cannot find the bimap
 function, and cabal reports no package Control.Bifunctor.

 ??

 ---



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


-- 
Tony Morris
http://tmorris.net/

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


Re: [Haskell-cafe] Segment Tree based Set

2012-10-29 Thread Tony Morris
It is not a Set, but a Map. Of course, I could use it to implement the
function I need with something like: type SSet a = STree [()] a, but
then I'd have to unnecessarily go beyond Haskell98.

Hoping there might be an interval tree or segment tree specifically for
this task.

On 29/10/12 18:36, Roman Cheplyaka wrote:
 If you searched hackage, you'd find
 http://hackage.haskell.org/package/SegmentTree

 Roman

 * Tony Morris tonymor...@gmail.com [2012-10-29 15:38:07+1000]
 Er, oops.

 ...can be implemented as:
 \a rs - let s = Set.fromList (rs = \(a, b) - [a..b]) in a `member` s

 Something like that!

 On Mon, Oct 29, 2012 at 2:48 PM, Tony Morris tonymor...@gmail.com wrote:

 Hi,
 I was wondering if anyone knows of a package implementing a fast lookup
 for an element in ranges.

 For example, this operation:
 Ord a = a - [(a, a)] - Bool

 ...can be implemented:
 \a rs - let s = Set.fromList rs in a `member` s

 This is not particularly efficient. A segment tree seems like a more
 appropriate data structure to store the ranges. Does such a library exist?


-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] Segment Tree based Set

2012-10-29 Thread Tony Morris
Yeah that looks useful indeed. I am surprised there isn't a DIET on hackage.

On Tue, Oct 30, 2012 at 3:55 AM, Stephen Tetley stephen.tet...@gmail.comwrote:

 Are Martin Erwig's diets anything close?

 http://web.engr.oregonstate.edu/~erwig/diet/

 On 29 October 2012 04:48, Tony Morris tonymor...@gmail.com wrote:
  Hi,
  I was wondering if anyone knows of a package implementing a fast lookup
  for an element in ranges.
 
  For example, this operation:
  Ord a = a - [(a, a)] - Bool
 

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


[Haskell-cafe] Segment Tree based Set

2012-10-28 Thread Tony Morris
Hi,
I was wondering if anyone knows of a package implementing a fast lookup
for an element in ranges.

For example, this operation:
Ord a = a - [(a, a)] - Bool

...can be implemented:
\a rs - let s = Set.fromList rs in a `member` s

This is not particularly efficient. A segment tree seems like a more
appropriate data structure to store the ranges. Does such a library exist?

-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] Segment Tree based Set

2012-10-28 Thread Tony Morris
Er, oops.

...can be implemented as:
\a rs - let s = Set.fromList (rs = \(a, b) - [a..b]) in a `member` s

Something like that!

On Mon, Oct 29, 2012 at 2:48 PM, Tony Morris tonymor...@gmail.com wrote:

 Hi,
 I was wondering if anyone knows of a package implementing a fast lookup
 for an element in ranges.

 For example, this operation:
 Ord a = a - [(a, a)] - Bool

 ...can be implemented:
 \a rs - let s = Set.fromList rs in a `member` s

 This is not particularly efficient. A segment tree seems like a more
 appropriate data structure to store the ranges. Does such a library exist?

 --
 Tony Morris
 http://tmorris.net/





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


Re: [Haskell-cafe] foldr (.) id

2012-10-26 Thread Tony Morris
It's the Endo monoid.

? :t ala Endo foldMap -- see newtype package
ala Endo foldMap :: Foldable t = t (a - a) - a - a
? ala Endo foldMap [(+1), (*2)] 8
17
? :i ala
ala ::
  (Newtype n o, Newtype n' o') =
  (o - n) - ((o - n) - b - n') - b - o'
  -- Defined in Control.Newtype


On 27/10/12 04:41, Greg Fitzgerald wrote:
 Hi Haskellers,

 I've recently found myself using the expression: foldr (.) id to compose
 a list (or Foldable) of functions.  It's especially useful when I need to
 map a function over the list before composing.  Does this function, or the
 more general foldr fmap id, defined in a library anywhere?  I googled and
 hoogled, but no luck so far.

 Thanks,
 Greg



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


-- 
Tony Morris
http://tmorris.net/


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


Re: In opposition of Functor as super-class of Monad

2012-10-25 Thread Tony Morris
I should have been clearer sorry. I should hope not that Functor -
Applicative - Monad.

Perhaps I do not understand the purpose of this thread, but fixing the
hierarchy in this way is a mistake of similar magnitude to the original
position -- one that I would cringe at seeing repeated. That is why I
thought such a discussion was on-topic.


On 25/10/12 10:12, Ben Franksen wrote:
 Tony Morris wrote:
 I should hope not. The identity element (return, coreturn, mempty, pure,
 Category.id) is almost never needed.

 * http://hackage.haskell.org/package/semigroupoids
 * https://gist.github.com/3871764
 Off-topic. Feel free to start a new thread named The bombastic one-and-true 
 class hierarchy I always wanted to have. These proposals have their merits, 
 and I greatly respect the category theoretic knowledge that went into them 
 -- but this is another discussion. This thread refers to a rather modest 
 correction in the standard libraries, not a complete re-design. The idea is 
 to fix something that is widely accepted as an unfortunate ommision (in 
 fact, Oleg's comment is one of the very few that question the idea of adding 
 super class constraints to Monad in principle).

 BTW, it is unclear what your I hope not refers to, since in both of the 
 hierarchies you linked to Applicative *is* a super class of Monad.

 Cheers

 On 25/10/12 04:49, Ben Franksen wrote:
 First, let me make it clear that nowadays we are of course (I hope!) 
 talking 
 about making not only Functor, but Applicative a super-class of Monad (so 
 Functor becomes a super-class by transitivity).

 Petr P wrote:
 The main objections were that it would break existing code and that it
 would lead to code duplication. The former is serious, [...]

 To address the first objection:
 I don't buy this it breaks lots of code argument. Adding the missing 
 instances is a complete no-brainer; as you wrote:

 instance Applicative ... where
 pure   = return
 (*)  = ap
 instance Functor ... where
 fmap   = liftM
 I do not think it is unreasonable to expect people to add such a simple 
 and 
 practically automatic fix to some old programs in the interest of 
 cleaning 
 up an old wart (and almost everyone agrees that this would be a good 
 thing, 
 in principle).

 BTW, I guess most programs already contain the Functor instances (but 
 maybe 
 not Applicative, as it is newer).

 I agree with Petr Pudlak that code duplication is not an issue, see 
 above. 
 And yes, these automatic instances may have stronger super-class 
 constraints than strictly necessary. So what? The program didn't need the 
 Functor (or Applicative) instance anyway (or it already would have 
 defined 
 it, in which case no change would be needed at all).

 Default superclass instances strike me as a complicated proposal for 
 solving trivial problems. The switch in Control.Exception (from data 
 Exception to class Exception) was much more disrupting, adapting programs 
 meant lots of changes everywhere exceptions are handled, not just adding 
 some trivial instances. Still people managed the transition.

 Cheers



-- 
Tony Morris
http://tmorris.net/



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


Re: In opposition of Functor as super-class of Monad

2012-10-25 Thread Tony Morris
OK, sorry about the noise!

On 26/10/12 09:41, Edward Kmett wrote:
 Tony, I think you misparsed the proposal. 

 The ...'s were for specific monads indicating the additional work required 
 for each Monad.

 I think the only real proposal on the table is the obvious one of adding 
 Applicative as a superclass of monad.

 From there there are a couple of incremental improvements that could be 
 made like adding the unimplemented superclass defaults or adding the 
 equivalent of DefaultSignatures to the language spec to reduce the burden on 
 Monad implementors.

 In practice I think either of those extensions would be premature to add to 
 the language specification at this time.

 I would be 100% behind adding the Applicative constraint as a superclass of 
 Monad and even perhaps of some bikeshedding, like exporting Applicative from 
 the Prelude, because otherwise you can't define a Monad without an import, 
 while you can now.

 I would be strongly against requiring superclass defaults or 
 DefaultSignatures in the haskell standard, however. The former is a largely 
 untested point in the design space and the latter has issues where it tightly 
 couples classes with their dependencies, leading to unbreakable cycles 
 between classes that all have to be defined together and poor engineering 
 practices.

 Best,
 --Edward


 On Oct 25, 2012, at 5:46 PM, Tony Morris tonymor...@gmail.com wrote:

 I should have been clearer sorry. I should hope not that Functor -
 Applicative - Monad.

 Perhaps I do not understand the purpose of this thread, but fixing the
 hierarchy in this way is a mistake of similar magnitude to the original
 position -- one that I would cringe at seeing repeated. That is why I
 thought such a discussion was on-topic.


 On 25/10/12 10:12, Ben Franksen wrote:
 Tony Morris wrote:
 I should hope not. The identity element (return, coreturn, mempty, pure,
 Category.id) is almost never needed.

 * http://hackage.haskell.org/package/semigroupoids
 * https://gist.github.com/3871764
 Off-topic. Feel free to start a new thread named The bombastic 
 one-and-true 
 class hierarchy I always wanted to have. These proposals have their 
 merits, 
 and I greatly respect the category theoretic knowledge that went into them 
 -- but this is another discussion. This thread refers to a rather modest 
 correction in the standard libraries, not a complete re-design. The idea is 
 to fix something that is widely accepted as an unfortunate ommision (in 
 fact, Oleg's comment is one of the very few that question the idea of 
 adding 
 super class constraints to Monad in principle).

 BTW, it is unclear what your I hope not refers to, since in both of the 
 hierarchies you linked to Applicative *is* a super class of Monad.

 Cheers

 On 25/10/12 04:49, Ben Franksen wrote:
 First, let me make it clear that nowadays we are of course (I hope!)
 talking 
 about making not only Functor, but Applicative a super-class of Monad (so 
 Functor becomes a super-class by transitivity).

 Petr P wrote:
 The main objections were that it would break existing code and that it
 would lead to code duplication. The former is serious, [...]

 To address the first objection:
 I don't buy this it breaks lots of code argument. Adding the missing 
 instances is a complete no-brainer; as you wrote:

 instance Applicative ... where
pure   = return
(*)  = ap
 instance Functor ... where
fmap   = liftM
 I do not think it is unreasonable to expect people to add such a simple
 and 
 practically automatic fix to some old programs in the interest of
 cleaning 
 up an old wart (and almost everyone agrees that this would be a good
 thing, 
 in principle).

 BTW, I guess most programs already contain the Functor instances (but
 maybe 
 not Applicative, as it is newer).

 I agree with Petr Pudlak that code duplication is not an issue, see
 above. 
 And yes, these automatic instances may have stronger super-class 
 constraints than strictly necessary. So what? The program didn't need the 
 Functor (or Applicative) instance anyway (or it already would have
 defined 
 it, in which case no change would be needed at all).

 Default superclass instances strike me as a complicated proposal for 
 solving trivial problems. The switch in Control.Exception (from data 
 Exception to class Exception) was much more disrupting, adapting programs 
 meant lots of changes everywhere exceptions are handled, not just adding 
 some trivial instances. Still people managed the transition.

 Cheers

 -- 
 Tony Morris
 http://tmorris.net/



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


-- 
Tony Morris
http://tmorris.net/



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


Re: In opposition of Functor as super-class of Monad

2012-10-24 Thread Tony Morris
I should hope not. The identity element (return, coreturn, mempty, pure,
Category.id) is almost never needed.

* http://hackage.haskell.org/package/semigroupoids
* https://gist.github.com/3871764



On 25/10/12 04:49, Ben Franksen wrote:
 First, let me make it clear that nowadays we are of course (I hope!) talking 
 about making not only Functor, but Applicative a super-class of Monad (so 
 Functor becomes a super-class by transitivity).

 Petr P wrote:
 The main objections were that it would break existing code and that it
 would lead to code duplication. The former is serious, [...]

 To address the first objection:
 I don't buy this it breaks lots of code argument. Adding the missing 
 instances is a complete no-brainer; as you wrote:

 instance Applicative ... where
 pure   = return
 (*)  = ap
 instance Functor ... where
 fmap   = liftM
 I do not think it is unreasonable to expect people to add such a simple and 
 practically automatic fix to some old programs in the interest of cleaning 
 up an old wart (and almost everyone agrees that this would be a good thing, 
 in principle).

 BTW, I guess most programs already contain the Functor instances (but maybe 
 not Applicative, as it is newer).

 I agree with Petr Pudlak that code duplication is not an issue, see above. 
 And yes, these automatic instances may have stronger super-class 
 constraints than strictly necessary. So what? The program didn't need the 
 Functor (or Applicative) instance anyway (or it already would have defined 
 it, in which case no change would be needed at all).

 Default superclass instances strike me as a complicated proposal for 
 solving trivial problems. The switch in Control.Exception (from data 
 Exception to class Exception) was much more disrupting, adapting programs 
 meant lots of changes everywhere exceptions are handled, not just adding 
 some trivial instances. Still people managed the transition.

 Cheers


-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-10-24 Thread Tony Morris
As a side note, I think a direct superclass of Functor for Monad is not
a good idea, just sayin'

class Functor f where
  fmap :: (a - b) - f a - f b

class Functor f = Apply f where
  (*) :: f (a - b) - f a - f b

class Apply f = Bind f where
  (=) :: (a - f b) - f a - f b

class Apply f = Applicative f where
  unit :: a - f a

class (Applicative f, Bind f) = Monad f where

Same goes for Comonad (e.g. [] has (=) but not counit)
... and again for Monoid, Category, I could go on...


On 17/10/12 04:14, David Thomas wrote:
 I think the version below (with a Functor or Applicative superclass)
 is clearly the right answer if we were putting the prelude together
 from a clean slate.  You can implement whichever is easiest for the
 particular monad, use whichever is most appropriate to the context
 (and add optimized versions if you prove to need them).  I see no
 advantage in any other specific proposal, except the enormous
 advantage held by the status quo that it is already written, already
 documented, already distributed, and already coded to.

 Regarding mathematical purity of the solutions, this is in every
 way isomorphic to a monad, but we aren't calling it a monad because we
 are describing it a little differently than the most common way to
 describe a monad in category theory strikes me as *less*
 mathematically grounded than we are calling this a monad because it
 is in every way isomorphic to a monad.

 On Tue, Oct 16, 2012 at 7:03 AM, AUGER Cédric sedri...@gmail.com wrote:
 So I think that an implicit question was why wouldn't we have:

 class Monad m where
   return :: a - m a
   kleisli :: (a - m b) - (b - m c) - (a - m c)
   bind = \ x f - ((const x) = f) ()
   join = id=id :: (m (m a) - m a)
 ___
 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


-- 
Tony Morris
http://tmorris.net/



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


[Haskell-cafe] Flipping type constructors

2012-08-13 Thread Tony Morris
I have a data-type that is similar to EitherT, however, I have ordered
the type variables like so:

data EitherT (f :: * - *) (a :: *) (b :: *) = ...

This allows me to declare some desirable instances:

instance Functor f = Bifunctor (EitherT f)
instance Foldable f = Bifoldable (EitherT f)
instance Traversable f = Bitraversable (EitherT f)

However, I am unable to declare a MonadTrans instance:

instance MonadTrans (EitherT a) -- kind error

I looked at Control.Compose.Flip to resolve this, but it does not appear
to be kind-polymorphic.
http://hackage.haskell.org/packages/archive/TypeCompose/0.9.1/doc/html/src/Control-Compose.html#Flip

I was wondering if there are any well-developed techniques to deal with
this? Of course, I could just write my own Flip with the appropriate
kinds and be done with it. Maybe there is a more suitable way?


-- 
Tony Morris
http://tmorris.net/



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


Re: Occasional segfault in GHCi w/ 7.4.1-rc1 and 64bit OS X

2012-07-17 Thread Tony Hannan
Thanks. Building from source fixed it.

On Mon, Jul 16, 2012 at 7:46 PM, Austin Seipp mad@gmail.com wrote:

 I actually made builds of GHC 7.4.1 with Snow Leopard that fixed this
 issue back when I had it:

 http://code.haskell.org/~thoughtpolice/ghc-741-osx-sl/

 I must have forgotten to email the list. I have since upgraded to Lion
 however. The builds are 64bit only as well. But that should be an easy
 means of getting bootstrapped.

 Apologies for dropping off on this one.

 On Mon, Jul 16, 2012 at 5:21 PM, Nathan Howell
 nathan.d.how...@gmail.com wrote:
  On Mon, Jul 16, 2012 at 12:26 PM, Tony Hannan tonyhann...@gmail.com
 wrote:
  I'm still seeing this problem in 7.4.2. Is there a workaround?
  I'm also on Snow Leopard and using 64-bit version.
 
  If you grabbed the installer from
  http://www.haskell.org/ghc/download_ghc_7_4_2 you'll need to build
  your own locally... the notes on the website say it's for 10.7/Lion
  and while it seems to work just fine on Lion it crashes frequently
  enough to be unusable on Snow Leopard. This gave me a bit of grief as
  well.
 
  -n
 
  ___
  Glasgow-haskell-users mailing list
  Glasgow-haskell-users@haskell.org
  http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



 --
 Regards,
 Austin

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Occasional segfault in GHCi w/ 7.4.1-rc1 and 64bit OS X

2012-07-16 Thread Tony Hannan
I'm still seeing this problem in 7.4.2. Is there a workaround?
I'm also on Snow Leopard and using 64-bit version.

Thanks,
Tony


On Sun, Dec 25, 2011 at 12:35 AM, austin seipp a...@hacks.yi.org wrote:

 Hello GHC hackers,

 I have been trying the recent 7.4.1-rc1 release on my OSX Snow Leopard
 machine. I am using the 64bit OSX .tar.bz. I used virthualenv/hsenv to
 set up a virtual environment to test packages with the RC, but I
 discovered that GHCi seems to segfault somewhat randomly when invoked.

 I cannot reproduce this problem with 7.0.4 (64bit,) 7.2.2 (64bit,) or
 7.5.20111223 (also 64bit.) I have invoked GHCi probably a hundred
 times each, and have never had it crash. I can crash the RC fairly
 reliably however.

 I looked at the shell scripts that invoke GHC and ran GDB with the
 proper arguments. I got a backtrace like so:

 $ gdb /Users/a/vh-741-rc1_2/.hsenv/ghc/lib/ghc-7.4.0.20111219/ghc
 GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC
 2011)
 Copyright 2004 Free Software Foundation, Inc.
 GDB is free software, covered by the GNU General Public License, and you
 are
 welcome to change it and/or distribute copies of it under certain
 conditions.
 Type show copying to see the conditions.
 There is absolutely no warranty for GDB.  Type show warranty for details.
 This GDB was configured as x86_64-apple-darwin...Reading symbols for
 shared libraries  done

 warning: Could not find object file
 /Users/ian/zz64/ghc-7.4.0.20111219/rts/dist/build/libHSrts_thr.a(ffi64.o)
 - no debug information available for ../src/x86/ffi64.c.


 warning: Could not find object file

 /Users/ian/zz64/ghc-7.4.0.20111219/rts/dist/build/libHSrts_thr.a(prep_cif.o)
 - no debug information available for ../src/prep_cif.c.


 warning: Could not find object file
 /Users/ian/zz64/ghc-7.4.0.20111219/rts/dist/build/libHSrts_thr.a(types.o)
 - no debug information available for ../src/types.c.

 (gdb) r -B/Users/a/vh-741-rc1_2/.hsenv/ghc/lib/ghc-7.4.0.20111219
 --interactive
 Starting program:
 /Users/a/vh-741-rc1_2/.hsenv/ghc/lib/ghc-7.4.0.20111219/ghc
 -B/Users/a/vh-741-rc1_2/.hsenv/ghc/lib/ghc-7.4.0.20111219
 --interactive
 Reading symbols for shared libraries + done
 GHCi, version 7.4.0.20111219: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.

 Program received signal EXC_BAD_ACCESS, Could not access memory.
 Reason: KERN_INVALID_ADDRESS at address: 0xae21cf68
 0x0001ae2060da in evacuate1 ()
 (gdb) bt
 #0  0x0001ae2060da in evacuate1 ()
 #1  0x0001ae20b868 in scavenge_block1 ()
 Previous frame inner to this frame (gdb could not unwind past this frame)
 (gdb)

 So it looks like a GC bug at first glance, but I haven't done rigorous
 investigation.

 Again this doesn't happen every time - probably 1/3 the time it
 crashes, the other 2/3 the time it seems to work fine. This naturally
 also affects `runghc`.

 Is this a known issue? Or should I file a bug and investigate further?
 Perhaps something forgot to get something merged into the 7.4 branch?


 --
 Regards,
 Austin

 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] Martin Odersky on What's wrong with Monads

2012-06-24 Thread Tony Morris
Odersky is repeatedly wrong on this subject and specifically for the
claim that you quote, the only response is simply not true.

On 24/06/12 15:31, Jonathan Geddes wrote:
 Cafe,

 I was watching a panel on languages[0] recently and Martin Odersky (the
 creator of Scala) said something about Monads:

 What's wrong with Monads is that if you go into a Monad you have to change
 your whole syntax from scratch. Every single line of your program changes
 if you get it in or out of a Monad. They're not polymorphic so it's really
 the old days of Pascal. A monomorphic type system that says 'well that's
 all I do' ... there's no way to abstract over things.  [0, 53:45]

 Thoughts?

 --J Arthur

 [0] - http://css.dzone.com/articles/you-can-write-large-programs



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


-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Perth Functional Programmers meetup group launched

2012-06-13 Thread Tony Morris
Hi Todd,
I am over the other side. I help organise the Brisbane Functional
Programming Group.
http://bfpg.org/

Although we discuss FP in general, we have a pretty strong emphasis on
Haskell. Let me know how it goes or if we can help out in any way!


On 14/06/12 00:46, Todd Owen wrote:
 We are pleased to announce that a functional programming user group has
 recently been formed in Perth, Australia.

 Being a small community, we aim to keep the group as inclusive as possible,
 and welcome new members from all levels of experience and language
 backgrounds. (That said, Haskellers currently account for about half our
 membership, followed by F#, and then a heap of other languages).

 As this is a global mailing list, I would also like to invite our
 colleagues from around Australia, and indeed anywhere in the world, to get
 in touch if you are ever passing through Perth. We're always happy to share
 a beer and talk about programming!

 For more information, visit: http://www.meetup.com/PerthFP/



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


-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Unit and pair

2012-05-08 Thread Tony Morris
On 09/05/12 03:49, MigMit wrote:
 On 8 May 2012, at 21:42, Felipe Almeida Lessa wrote:

 On Tue, May 8, 2012 at 2:36 PM, MigMit miguelim...@yandex.ru wrote:
 Hi café, a quick question.

 Is there a somewhat standard class like this:

 class Something c where
unit :: c () ()
pair :: c x y - c u v - c (x, u) (y, v)

 ?

 I'm using it heavily in my current project, but I don't want to repeat 
 somebody else's work, and it seems general enough to be defined somewhere; 
 but my quick search on Hackage didn't reveal anything.

 I know about arrows; this, however, is something more general, and it's 
 instances aren't always arrows.
 Are you aware of generalized arrows [1]? It's still a lot more than
 your Something, though.
 I've heard of them, but some instances of my Something class aren't 
 categories either, which rules out GArrows too.
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
data-lens has something similar (Tensor):

http://hackage.haskell.org/packages/archive/data-lens/2.10.0/doc/html/Control-Category-Product.html

-- 
Tony Morris
http://tmorris.net/



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


[Haskell-cafe] Haskell source AST zipper with state

2012-05-02 Thread Tony Morris
Is there a library to traverse a source AST keeping state?

-- 
Tony Morris
http://tmorris.net/



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


Re: String != [Char]

2012-03-16 Thread Tony Morris
On 17/03/12 11:44, Greg Weber wrote:
 the text library and Text data type have shown the worth in real world
 Haskell usage with GHC.
 I try to avoid String whenever possible, but I still have to deal with
 conversions and other issues.
 There is a lot of real work to be done to convert away from [Char],
 but I think we need to take it out of the language definition as a
 first step.

 I can only see one issue with the proposal: it can be convenient to
 operate on a list of characters.
 But I think there are plenty of solutions at our disposal. A simple
 conversion from Text to a list of characters might suffice. In GHC,
 OverloadedStrings means users would still be free to use String the
 same way they are now.

 ___
 Haskell-prime mailing list
 Haskell-prime@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-prime
Do you know if there is a good write-up of the benefits of Data.Text
over String? I'm aware of the advantages just by my own usage; hoping
someone has documented it rather than in our heads.

-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-29 Thread Tony Morris
On 01/03/12 14:40, wren ng thornton wrote:
 Of course, you can simplify the implementation by:

 inter f xs = zipWith f xs (tail xs) 
inter f = zipWith f * tail

-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] Not an isomorphism, but what to call it?

2012-01-19 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 01/20/2012 07:24 AM, Sean Leather wrote:
 I have two types A and B, and I want to express that the composition of two
 functions f :: B - A and g :: A - B gives me the identity idA = f . g ::
 A - A. I don't need g . f :: B - B to be the identity on B, so I want a
 weaker statement than isomorphism.
 
 I understand that:
 (1) If I look at it from the perspective of f, then g is the right inverse
 or section (or split monomorphism).
 (2) If I look at from g, then f is the left inverse or retraction (or split
 epimorphism).
 
 But I just want two functions that give me an identity on one of the two
 types and I don't care which function's perspective I'm looking at it from.
 Is there a word for that?
 
 Regards,
 Sean
 
 
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

It is not clear to me exactly what you are asking, so shot in the dark:
injection or surjection?


- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPGJNXAAoJEPxHMY3rBz0PHt0IAKP1lVcfDXZm00h4W1WQPDBT
h6LB9nLlp0cgAh5CH06FsdQFqdtDVJNMkV7/9q3H/wTFOoscZHCTigr1G+vE/kA8
lh1/Gb3caQByt6rWkgD79998FL5ZCBdHN2HYh1o/RPBwA/BYxA041P92pE0EFTKB
1oylh5ldUfv8rEzvHhQVw0USrJ11uiZfn/T3+UrO2s2xLQZS1oTWNZhsKMccjB95
tYaqEw+20Q+8yBanVnDJFOqD3yPXIRBHkTSJTOFO+Y++oen4gXUzSJJ2lkpXLECE
ojMNHD/9Yh43gCm1Jq3Wuz5B6mr+v+RTRuLkxiVMsK7wxW+lfmOgeMyxHyr8pxU=
=aPtB
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] Functor0?

2012-01-15 Thread Tony Morris
On 01/16/2012 03:26 PM, Evan Laforge wrote:
 Often when I define some type that wraps something else, I find myself writing
 a function like the following:

 newtype Thing = Thing X
 liftThing f (Thing x) = Thing (f x)

 It's like a Functor, but I can't make it an instance because Functor
 requires that the type be parametric.  So I've been using type families to
 make a kind of 0 argument functor:

 class Functor0 a where
 type Elem a :: *
 fmap0 :: (Elem a - Elem a) - a - a

 instance Functor0 Thing where
 type Elem Thing = X
 fmap0 = liftThing

 Is there a name for this?  A better way to do it?

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
?
http://hackage.haskell.org/packages/archive/newtype/0.2/doc/html/Control-Newtype.html
?

-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] strict, lazy, non-strict, eager

2011-12-24 Thread Tony Morris
On 24/12/11 17:54, Yves Parès wrote:
 See that's typically the speech that scares people away from Haskell...



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

Wait what?

I find it intriguing, helpful, provocative and potentially helpful
toward the common goal of helping others. I am interested in further
commentary. I'm not scared and you shouldn't be either.

-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] strict, lazy, non-strict, eager

2011-12-24 Thread Tony Morris
On 24/12/11 18:41, Gregory Crosswhite wrote:
 On Dec 24, 2011, at 6:22 PM, Tony Morris wrote:

 Wait what?

 I find it intriguing, helpful, provocative and potentially helpful toward 
 the common goal of helping others. I am interested in further commentary. 
 I'm not scared and you shouldn't be either.
 Asking honest questions is imminently reasonable; accusing others of being 
 incompetent hypocrites --- especially when you go to great length to make it 
 clear that this is *exactly* what you are doing --- is not.  The former is 
 helpful, but the latter is poisonous.  Yves's point is that doing the latter 
 risks scaring people away.

 Cheers,
 Greg

If I am an incompetent hypocrite, I want to know more. Toughen up.

-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] Tutorial/slides on pretty-printing combinators?

2011-11-16 Thread Tony Sloane
On 17/11/2011, at 12:31 AM, Jerzy Karczmarczuk wrote:

 Sean Leather:
 Do you know of any tutorial or slides from a talk on one of the 
 pretty-printing libraries?
 
 Sean, if you need info just on Haskell solutions, other people will help you. 
 There is a paper:
 Linear, bounded, functional pretty-printing by Doaitse Swierstra and Olaf 
 Chitil (and Pretty Printer with Lazy Deques by Olaf, a Functional Pearl if 
 I am not mistaken). BTW, something has been implemented in Scala based on the 
 S. and C. approach.

Yes, our Scala port of the continuation-based version from Doaitse and Olaf's 
paper is in the Kiama library:

http://code.google.com/p/kiama
http://code.google.com/p/kiama/source/browse/src/org/kiama/util/PrettyPrinter.scala

Some brief slides from a short fpsyd talk on this part of Kiama are at 
http://code.google.com/p/kiama/wiki/Research.

regards,
Tony


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


[Haskell-cafe] Lens with merge (Semigroup)

2011-09-05 Thread Tony Morris
A regular Lens can be represented as follows:

data CoState a = CoState (a - b) a

newtype Lens a b = Lens (a - CoState b a)

I once read about a lens representation that permits a general merge
operation. I forget where I read it -- I think it was #haskell IRC.
However, as I recall, perhaps incorrectly, the merge operation involves
a Semigroup[1] and helps to overcome the fact that Lens is not an Arrow
and so does not have a () operation.

I am interested to know what this Lens operation is and the associated
merge operation.

[1]
-- Approximate
data SemigroupT f a = SemigroupT (a - a - f a)


-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] Smarter do notation

2011-09-03 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Tasty.

On 04/09/11 12:34, Daniel Peebles wrote:
 Hi all,
 
 I was wondering what people thought of a smarter do notation. Currently,
 there's an almost trivial desugaring of do notation into (=), (), and
 fail (grr!) which seem to naturally imply Monads (although oddly enough,
 return is never used in the desugaring). The simplicity of the desugaring is
 nice, but in many cases people write monadic code that could easily have
 been Applicative.
 
 For example, if I write in a do block:
 
 x - action1
 y - action2
 z - action3
 return (f x y z)
 
 that doesn't require any of the context-sensitivty that Monads give you, and
 could be processed a lot more efficiently by a clever Applicative instance
 (a parser, for instance). Furthermore, if return values are ignored, we
 could use the ($), (*), or (*) operators which could make the whole thing
 even more efficient in some instances.
 
 Of course, the fact that the return method is explicitly mentioned in my
 example suggests that unless we do some real voodoo, Applicative would have
 to be a superclass of Monad for this to make sense. But with the new default
 superclass instances people are talking about in GHC, that doesn't seem too
 unlikely in the near future.
 
 On the implementation side, it seems fairly straightforward to determine
 whether Applicative is enough for a given do block. Does anyone have any
 opinions on whether this would be a worthwhile change? The downsides seem to
 be a more complex desugaring pass (although still something most people
 could perform in their heads), and some instability with making small
 changes to the code in a do block. If you make a small change to use a
 variable before the return, you instantly jump from Applicative to Monad and
 might break types in your program. I'm not convinced that's necessary a bad
 thing, though.
 
 Any thoughts?
 
 Thanks,
 Dan
 
 
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOYuR6AAoJEPxHMY3rBz0PRE8IAMK8sQTzxtgRYeWcyP6JmWso
Yl3eDUjny2uMSzIkifJix/t7tYuYG092H6SvA5VhgVBPQUd8LnZH/91X3PDGANBu
ufjmCJLuN5+bgeNxvyzBHwz5iYM3GOkPhGvpJ3hJzYFIBlDVnVmMNoCDkki46/nq
xJ/gsAIwfgpe4+Ll1LWu9DjVaQHb9nWmdBpTvpbXb7W+WEX7MHIsVsP/KysVFZkc
XwPESJntb7oTHCcS3q1GEVTYdMFNKHlWOFcrdkGGQlegvwfjdt221oVDNToZi4z1
wJ268MdvXLSVIcU+JHLYxElQj6zrf2D51oQbHWLS/wlHRnpZHU5gtmrMTKvPvf8=
=d1uz
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] Pointed, but not Applicative

2011-08-28 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 28/08/11 01:41, Sönke Hahn wrote:
 Hi!
 
 I was reading through the Typeclassopedia ([1]) and I was wondering which 
 type could be an instance of Pointed, but not of Applicative. But I can't 
 think of one. Any ideas?
 
 Sönke
 
 [1] http://www.haskell.org/haskellwiki/Typeclassopedia
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

Pointed f = Pointed (StateT s f)

but not

Applicative f = Applicative (StateT s f)

- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOWhtaAAoJEPxHMY3rBz0Pa3oIAMrqoyv4DW39VjIXwzV3/4Ir
W5s0+fdoPj7h1j6eyCB81VcDHNtGQmWhZ3+g2AhHo1jLAzmH8G5ACdD1c1FeF2dn
a0iO7uvH5sM0xovpsqUwZC8BkomdeAnRuYF5Ohzar5M/Ip2BD0k7QpIWJt3RdLZm
uCpwDnsQ2foHJCJYlGmmGkpzDAnkwePOfER93KrKXmzHqQxhS0oACQy6LKfXODTM
+d2VVzzb4tWuzijXE4NflpdtW/4jSs3gVFmkZ7BmXSg8XxZO3naO/y4gtrU4YVjw
7TKo4IOIygQVMsFbdV2WZHprMHU/VaM6MTByiNECyB0q/yhJhsXtGsd9eeR2jng=
=X4nM
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] why the name lambda calculus?

2011-08-24 Thread Tony Finch
Ezra Cooper e...@ezrakilty.net wrote:

 I believe this to be a general trait of things described as
 calculi--that they have some form of name-binders, but I have never
 seen that observation written down.

Combinator calculi are a counter-example.

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
Biscay, FitzRoy: Mainly westerly or southwesterly 4 or 5, occasionally 6 in
Fitzroy, becoming variable 3 at times in south. Slight or moderate, becoming
rough or very rough in northwest Fitzroy. Rain or showers, thundery at times.
Good, occasionally poor.

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


Re: [Haskell-cafe] why the name lambda calculus?

2011-08-22 Thread Tony Finch
KC kc1...@gmail.com wrote:

 Lambda abstraction was probably chosen in case someone found better
 abstractions; e.g. epsilon, delta, gamma, beta, alpha, ... :)

http://www-maths.swan.ac.uk/staff/jrh/papers/JRHHislamWeb.pdf

Page 7:

By the way, why did Church choose the notation λ? In [an unpublished
letter to Harald Dickson, Church] stated clearly that it came from the
notation x̂ used for class-abstraction by Whitehead and Russell, by first
modifying x̂ to ∧ x to distinguish functionabstraction from
class-abstraction, and then changing ∧  to λ for ease of printing.
This origin was also reported in [Rosser. Highlights of the history of the
lambda calculus. Annals of the History of Computing]. On the other hand,
in his later years Church told two enquirers that the choice was more
accidental: a symbol was needed and λ just happened to be chosen.)

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
Tyne, Dogger: Northwest becoming variable then east, 3 or 4, increasing 5 or 6
later. Slight or moderate. Showers, thundery later. Moderate or good.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Simon PJ in Australia

2011-08-19 Thread Tony Morris
On 08/19/2011 05:56 PM, Simon Peyton-Jones wrote:

 This is a message for *Australian FPers* -- sorry to spam the rest of you.

  

 I'm crossing the planet to Australia for YOW (Melbourne Dec 1-2,
 Brisbane Dec 5-6).  http://www.yowconference.com.au/YOW2011/

  

 I'm committed for the conference dates of course, but I could spend a
 few days before or afterwards, hanging out with some of you guys. 
 Hack on GHC, give a talk, eat pizza, university departments, Haskell
 users groups, surfing (on water, that is)

  

 Do drop me (not the list) a line if any of that sounds fun.

  

 Simon

  

 PS: John Hughes is coming to Yow too, so you could try luring him into
 your lair too.


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

...and I will be running a Haskell/FP workshop. I'm as keen as Simon to
meet others from further afield with similar interests.
http://www.yowconference.com.au/YOW2011/general/workshopDetails.html?eventId=3552

PS: we have a significant FP community here in Brisbane with nearly 250
members http://bfpg.org/

-- 
Tony Morris
http://tmorris.net/


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


[Haskell-cafe] Data.Time

2011-06-25 Thread Tony Morris

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I recently set out to write a library that required a decent time
library. Having only had a flirt with Data.Time previously, I assumed
it would be robust like many other haskell libraries. I don't know
about consensus, but I have been massively let down. I won't go in to
the details, since this is not the point -- I don't wish to complain
- -- I wish to get on with it.

So, assuming the consensus is in agreement, is there a reasonable
alternative to Data.Time (I looked on hackage and nothing seemed to
have come close)? Am I wrong in assuming Data.Time is pretty useless?

If I am right, and there is no alternative, I see no option but to
take an excursion into writing my own. Ultimately, I am just trying to
avoid this. Tips welcome.

- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk4Ggx4ACgkQmnpgrYe6r61BRQCfbn+1jqNSjR+lxM+4h3gpvAMM
VskAoKxqDCETyVAaOdoYDmFJGz1fOGd/
=IC7O
-END PGP SIGNATURE-


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


[Haskell-cafe] Iteratee stack-consumption

2011-05-30 Thread Tony Morris

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I have written iteratees on the JVM, which does not include tail-call
in its instruction set. They incur a stack frame per iteratee input,
which can be expensive and unable to scale beyond a few thousand. Is
there some trick to permitting this? Some sort of chunking the
enumeratee or something? I was unable to find any good general hints
in any of the hackage libraries.

Thanks for any pointers.

- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3jNHEACgkQmnpgrYe6r63QcACfSeZvvy+iYVisZ3e/dhWQd3D6
790AnRZCjJT6eCY21XlsVqcpTuamfuXY
=ADo5
-END PGP SIGNATURE-


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


Re: [Haskell-cafe] *GROUP HUG*

2011-05-25 Thread Tony Morris
On 24/05/11 22:41, Johannes Waldmann wrote:
 Then tell me, why does calculating the length of a (Haskell) 
 list has O(n) complexity. 
Infiniticity aside, tail would become O(n) if you store a length with
each cons cell.

-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] *GROUP HUG*

2011-05-25 Thread Tony Morris
On 25/05/11 16:46, Eugene Kirpichov wrote:
 data FList a = FNil | FCons Int a (FList a)
 empty = FNil
 len FNil = 0
 len (FCons n _) = n
 cons x xs = FCons (1 + len xs) x xs
 tail (FCons _ _ xs) = xs
My mistake, sorry. Currently looking for original reason to have
accidentally come to believe that.

-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] *GROUP HUG*

2011-05-24 Thread Tony Morris
Just laugh mate. It's the best possible outcomes sometimes.

On 24/05/11 15:10, Gregory Crosswhite wrote:
 Hey everyone,

 Okay, this will sound silly, but I ventured into the Scala mailing
 list recently and asked an ignorant question on it, and I was shocked
 when people reacted not by enlightening me but by jumping on me and
 reacting with hostility.  I bring this up not to badmouth the Scala
 community (they are apparently going through growing pains and will
 hopefully mature with time!) but just because it made me appreciate
 just how awesome you guys are, so I just feel the need to publicly
 express my admiration and thank to everyone on this list for having
 fostered such an incredibly professional, fanatically nonhostile, and
 generally pleasant place to talk about Haskell!!!

 *GROUP HUG*

 Okay, I'm done now.  :-)

 Cheers,
 Greg

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


-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-02 Thread Tony Morris
On 02/05/11 17:54, Ketil Malde wrote:
 I'm following Harper's blog, Existential Type¹, which I find to be an
 enjoyable and entertainingly written tirade about the advantages of
 teaching functional programming - specifically ML - to students.  Of
 course, he tends to be critical of Haskell, but it's nice to get some
 thought provoking opinion from somebody who knows a bit about the
 business.

 Recently, he had a piece on monads, and how to do them in ML, and one
 statement puzzled me:

   There is a particular reason why monads had to arise in Haskell,
though, which is to defeat the scourge of laziness.

 My own view is/was that monads were so successful in Haskell since it
 allowed writing flexible programs with imperative features, without
 sacrificing referential transparency.  Although people are quick (and
 rightly so) to point out that this flexibility goes way beyond IO, I
 think IO was in many ways the killer application for monads.  Before IO,
 we had very limited functionality (like 'interact' taking a 'String -
 String' function and converting it into an exectuable program) to build
 real programs from.

 Laziness does require referential transparency (or at least, it is
 easier to get away with the lack of RT in a strict language), so I can
 see that he is indirectly correct, but RT is a goal in itself.  Thus, I
 wonder if there are any other rationale for a statement like that?

 -k

 ¹ http://existentialtype.wordpress.com/
Interesting how I have been authoring and subsequently using monads in
scala for several years and it is strictness that gets in the way more
than anything.

http://github.com/scalaz/scalaz/

I have been teaching functional programming for quite a while, both in
universities and outside of academia, and I am of the opinion that
Haskell's suitability in first place has no close second place. I wonder
why I am wrong, but this post (and previous) is hardly persuasive.

-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] Python is lazier than Haskell

2011-04-27 Thread Tony Morris
On 27/04/11 20:02, Thomas Davie wrote:
 This completely misses what laziness gives Haskell – it gives a way of 
 completing a smaller number of computations than it otherwise would have to 
 at run time.  The hope being that this speeds up the calculation of the 
 result after the overhead of laziness is taken into account.
This is not what laziness gives us. Rather, it gives us terminating
programs that would otherwise not terminate.

-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] How large is the Haskell community ?

2011-02-12 Thread Tony Morris

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 13/02/11 08:37, Erik de Castro Lopo wrote:
 Aaron Gray wrote:

 I am wondering if mailing list statistics would be the best guide
 ?

 I am the organiser of FP-Syd, the Sydney (Australia) functiona
 prgramming group.

 Of the people who are regaular attendees to FP-Syed meetings, who
 say they are haskell users, I have seen less than 50% of these
 people post to this or other haskell mailing lists.

 Mailing list statistics may not be a good guide.

 Erik
I am the co-organiser of Brisbane Functional Programming Group with
nearly 200 members. I have not seen anywhere near 50% post here.

- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1XDbEACgkQmnpgrYe6r63g7ACghYtq7+lyba3S/UscZ34+DEvx
hxEAoJ0uDPTwNhM2LnvUekpmTG7C5SNV
=O/WP
-END PGP SIGNATURE-


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


Re: RFC: migrating to git

2011-01-13 Thread Tony Finch
On Wed, 12 Jan 2011, Claus Reinke wrote:

 What happens after the merges? Does one maintain the branches
 somehow, or does one lose the (in-)dependency information?

Remember that a branch in git is just a name for a point in the revision
graph. When you commit to a branch the name is updated to point to the new
commit. Names are local to a particular repository.

When you do a merge, you do it on a particular branch which is updated to
point to the merge commit. The other branches that were merged in (there's
usually one but you can create octopus merges if you want) remain as they
were. The merge commit contains un-named pointers to its parent commits
for use by git, and conventionally records the names of the brances that
were merged in the commit message for the convenience of humans. You can
commit to the other branches to extend them, or delete and reconstruct
them differently, without affecting the state represented by the merge.

Have a look the way topic branches are used in the maintenance of
git itself as an example of how to deal with a collection of independent
patches.
http://git.kernel.org/?p=git/git.git;a=blob;f=MaintNotes;hb=refs/heads/todo

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
HUMBER THAMES DOVER WIGHT PORTLAND: NORTH BACKING WEST OR NORTHWEST, 5 TO 7,
DECREASING 4 OR 5, OCCASIONALLY 6 LATER IN HUMBER AND THAMES. MODERATE OR
ROUGH. RAIN THEN FAIR. GOOD.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: RFC: migrating to git

2011-01-12 Thread Tony Finch
On Wed, 12 Jan 2011, Claus Reinke wrote:

 In my understanding, the unorderedness of patch history in darcs is
 there to make distributed repos easier (fewer constraints: same set of
 patches, but not same order; can mix local commits and pulls from
 various repos, no need for a central repo),

Apart from variable patch ordering all of that is true of all DVCSs.

 and because darcs has a causal rather than a temporal view of patch
 history (which patch depends on which other patches, instead of which
 patch came first).

You can emulate darcs's patch re-ordering in git if you put each
independent sequence of patches on a separate branch. Then you can
re-merge the branches in whatever order you want. This is a fairly
common git workflow.

 In other words, always keep a branch/repo that only pulls from the central
 repos (no other source of patches).

It is normal in git to keep a pristine branch for each remote repository
that you pull from - git sets these branches up by default. There can be
many remotes in a git repository.

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
HUMBER THAMES DOVER WIGHT PORTLAND: NORTH BACKING WEST OR NORTHWEST, 5 TO 7,
DECREASING 4 OR 5, OCCASIONALLY 6 LATER IN HUMBER AND THAMES. MODERATE OR
ROUGH. RAIN THEN FAIR. GOOD.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: RFC: migrating to git

2011-01-11 Thread Tony Finch
On Mon, 10 Jan 2011, Roman Leshchinskiy wrote:

 It also seems to make finding buggy patches rather hard.

Have a look at `git bisect`.

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
HUMBER THAMES DOVER WIGHT PORTLAND: NORTH BACKING WEST OR NORTHWEST, 5 TO 7,
DECREASING 4 OR 5, OCCASIONALLY 6 LATER IN HUMBER AND THAMES. MODERATE OR
ROUGH. RAIN THEN FAIR. GOOD.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] Generalizing catMaybes

2011-01-08 Thread Tony Morris

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Thanks guys for all the solutions. A slight correction below.

On 09/01/11 03:54, David Menendez wrote:

 Naturally, if you also have pure and fmap, you also have a monad.
You have a pointed functor but not necessarily a monad. There are many
pointed functors that are not monads. The paper, Applicative
Programming with Effects (McBride, Paterson) lists a couple.

- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0o4AgACgkQmnpgrYe6r62z4wCgk4A1njS5lLH3RHtxfnIkVGTL
t3sAoKNm7HjVQyk/Gb1AL5LxahRHPmKN
=5D4j
-END PGP SIGNATURE-


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


[Haskell-cafe] Generalizing catMaybes

2011-01-07 Thread Tony Morris

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 I am wondering if it possible to generalise catMaybes:

(Something f, SomethingElse t) = t (f a) - t a

I have being doing some gymnastics with Traversable and Foldable and a
couple of other things from category-extras to no avail. Perhaps
someone else's brain is molded into an appropriate shape to reveal an
answer!

- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0n0lwACgkQmnpgrYe6r6155gCeLjYizQ/5w1r2qkecbEqiQqq5
ihIAn1bmmK/qNFxM2sSusqjJu/g2/lH7
=+SdM
-END PGP SIGNATURE-


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


Re: In opposition of Functor as super-class of Monad

2011-01-05 Thread Tony Morris
On 06/01/11 04:58, Isaac Dupree wrote:
 Tony, you're missing the point... Alexey isn't making a complete patch
 to GHC/base libraries, just a hacky-looking demonstration.  Alexey is
 saying that in a class hierarchy (such as if Functor = Monad were a
 hierarchy, or for that matter XFunctor=XMonad or Eq = Ord), it
 is still possible to define the superclass functions (fmap) in terms
 of the subclass functions (return and =) (such as writing a functor
 instance in which fmap f m = m = (return . f)).  This has always
 been true in Haskell, it just might not have been obvious.

 ___
 Haskell-prime mailing list
 Haskell-prime@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-prime
Oh right sorry. I thought a stronger point was being made.

Then perhaps it's also worth pointing out that (*) can be written
using (=) and return:
f * a = f = \ff - a = \aa - return (ff aa)

-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] Trouble installing FileManipCompat

2011-01-05 Thread Tony Miller
Thanks that works, but I have packages that rely on mtl=2.0, so its
not the best solution. Perhaps the maintainer of FileManipCompat could
be contacted to update the package?

On 1/4/11, Daniel Fischer daniel.is.fisc...@googlemail.com wrote:
 On Wednesday 05 January 2011 01:54:36, Tony Miller wrote:
 Hi,

 I'm trying to install FileManipCompat(well, really
 HStringTemplateHelpers, but the error is from FileManipCompat) and I'm
 getting this error:

 [1 of 1] Compiling System.FilePath.FindCompat (
 System/FilePath/FindCompat.hs, dist/build/System/FilePath/FindCompat.o
 )

 System/FilePath/FindCompat.hs:175:20:
 Not in scope: data constructor `State'

 Apparently the code is written for an older version of mtl.
 As of mtl-2.*, State is no longer a separate type, it's a type synonym for

 StateT s Identity

 now.

 You can try

 $ cabal install --constraint=mtl  2.0 HStringTemplateHelpers

 (although having multiple versions of mtl installed may lead to some
 headaches too).




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


Re: In opposition of Functor as super-class of Monad

2011-01-04 Thread Tony Morris
I think you'll find a problem using do-notation with your Monad.

Tony Morris

On 04/01/2011 11:33 PM, Alexey Khudyakov alexey.sklad...@gmail.com
wrote:

On 04.01.2011 13:24, o...@okmij.org wrote:


 I'd like to argue in opposition of making Functor a...
I think I understood your point. But it looks like that it's possible to use
subclass's function in superclass instance. At very least GHC is able to do
it.

Following example works just fine without any language extensions in
GHC6.12.3


import Prelude hiding (Monad(..), Functor(..))

class Functor f where
 fmap :: (a - b) - f a - f b



class Functor m = Monad m where
 return :: a - m a
 (=) :: m a - (a - m b) - m b
instance Functor Maybe where


 fmap f m = m = (return . f)
instance Monad Maybe where
 return = Just
 Nothing = _ = Nothing
 Just x  = f = f x



___
Haskell-prime mailing list
haskell-pr...@haskell.o...
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


[Haskell-cafe] Trouble installing FileManipCompat

2011-01-04 Thread Tony Miller
Hi,

I'm trying to install FileManipCompat(well, really
HStringTemplateHelpers, but the error is from FileManipCompat) and I'm
getting this error:

[1 of 1] Compiling System.FilePath.FindCompat (
System/FilePath/FindCompat.hs, dist/build/System/FilePath/FindCompat.o
)

System/FilePath/FindCompat.hs:175:20:
Not in scope: data constructor `State'


I've attached the complete output of `cabal --verbose install
HStringTemplateHelpers`.


filemanipcompat.errors
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] UTF-8 BOM

2011-01-04 Thread Tony Morris
I am reading files with System.IO.readFile. Some of these files start
with a UTF-8 Byte Order Marker (0xef 0xbb 0xbf). For some functions that
process this String, this causes choking so I drop the BOM as shown
below. This feels particularly hacky, but I am not in control of many of
these functions (that perhaps could use ByteString with a better solution).

I'm wondering if there is a better way of achieving this goal. Thanks
for any tips.


dropBOM ::
  String
  - String
dropBOM [] =
  []
dropBOM s@(x:xs) = 
  let unicodeMarker = '\65279' -- UTF-8 BOM
  in if x == unicodeMarker then xs else s

readBOMFile ::
  FilePath
  - IO String
readBOMFile p =
  dropBOM `fmap` readFile p




-- 
Tony Morris
http://tmorris.net/



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


Re: [Haskell-cafe] (Co/Contra)Functor and Comonad

2010-12-23 Thread Tony Morris

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

...regardless of the utility of a contravariant functor type-class, I
strongly advocate for calling it Contrafunctor and not Cofunctor. I
have seen numerous examples of confusion over this, particularly in
other languages.

On 24/12/10 12:16, Mario Blažević wrote:

 On Thu, Dec 23, 2010 at 5:25 PM, Stephen Tetley
 stephen.tet...@gmail.com mailto:stephen.tet...@gmail.com
 wrote:

 On 23 December 2010 21:43, Mario Blažević mblaze...@stilo.com
 mailto:mblaze...@stilo.com wrote:
 Why are Cofunctor and Comonad classes not a part of the base
 library? [SNIP]
 Later on I found that this question has been raised before by
 Conal Elliott,
 nearly four years ago.


 http://www.haskell.org/pipermail/libraries/2007-January/006740.html




- From a somewhat philistine persepective, that Conal's question
 went unanswered says something:

 Does anyone have useful functionality to go into a Cofunctor
 module (beyond the class declaration)?

 Successful post-H98 additions to Base (Applicative, Arrows, ...)
 brought a compelling programming style with them. For Comonads,
 Category-extras does define some extra combinators but otherwise
 they have perhaps seemed uncompelling.



 There are plenty of potential Cofunctor instances on Hackage, as
 I've pointed out. The other side of the proof of the utility of
 the class would be to find existing libraries that could be
 parameterized by an arbitrary functor: in other words, some
 examples in Hackage of

 class Cofunctor c = ... instance Cofunctor c = ... f ::
 Cofunctor c = ...

 This would be rather difficult to prove - such signatures cannot
 be declared today, and deciding if existing declarations could be
 generalized in this way would require a pretty deep analysis. The
 only thing I can say is build it and they will come.

 To turn the proof obligation around, what could possibly be the
 downside of adding a puny Cofunctor class to the base library?



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


- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0UIJ0ACgkQmnpgrYe6r62kWgCeNwZnYLetOFevK6bpCBE/joKO
2QQAniaX4IGzAmdjEC8kdDV27upUTsBw
=NP27
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] DNS problems at haskell.org?

2010-12-18 Thread Tony Hannan
I am seeing this from New York. Has the domain expired?

dmmb:~ tony$ dig haskell.org

;  DiG 9.6.0-APPLE-P2  haskell.org
;; global options: +cmd
;; Got answer:
;; -HEADER- opcode: QUERY, status: NOERROR, id: 36391
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:
;haskell.org. IN A

;; ANSWER SECTION:
haskell.org. 1177 IN A 209.62.105.19

;; AUTHORITY SECTION:
haskell.org. 80371 IN NS ns2.pendingrenewaldeletion.com.
haskell.org. 80371 IN NS ns1.pendingrenewaldeletion.com.

;; ADDITIONAL SECTION:
ns1.pendingrenewaldeletion.com. 1172 IN A 205.178.190.51
ns2.pendingrenewaldeletion.com. 1172 IN A 205.178.189.51

;; Query time: 13 msec
;; SERVER: 10.3.1.40#53(10.3.1.40)
;; WHEN: Fri Dec 17 12:27:58 2010
;; MSG SIZE  rcvd: 139


On Fri, Dec 17, 2010 at 9:01 AM, Eugene Kirpichov ekirpic...@gmail.comwrote:

 Hello.

 For a couple of friends of mine, hackage.haskell.org happens to
 resolve to something strange (parked domain), though haskell.org works
 ok. This might be something to tell to haskell.org admins.

 Find below an example tracert (messages in Russian have been translated).

 C:\Program Files (x86)\Far2tracert hackage.haskell.org

 Tracing to hackage.haskell.org [209.62.105.19], max hops = 30

  1 8 ms 4 ms 4 ms  bsr01.nn.ertelecom.ru [91.144.184.69]
  2 **2 ms  net184-77.nn.ertelecom.ru [91.144.184.77]
  313 ms 9 ms 9 ms
 NNOV-D2-HQ-XX---1-3-0.499.main.synterra.ru [83.229.187.17]
  4 9 ms29 ms 9 ms  83.229.226.101
  510 ms 9 ms 9 ms  m9-cr01-te4-3.msk.stream-internet.net
 [195.34.38.37]
  6   142 ms   142 ms   142 ms  ss-crs-1-be3.msk.stream-internet.net
 [195.34.53.86]
  7   142 ms   142 ms   142 ms  mar-crs-1-be6.msk.stream-internet.net
 [195.34.59.141]
  8   143 ms   142 ms   142 ms  oct-crs-1-be1.spb.stream-internet.net
 [195.34.53.194]
  9   143 ms   142 ms   142 ms  bro-cr01-be3.stk.stream-internet.net
 [212.188.1.194]
  1066 ms66 ms66 ms  tct-cr01-te5-1.ams.stream-internet.net
 [195.34.53.14]
  11   142 ms   307 ms   207 ms  sd-cr01-te2-1.nyc.stream-internet.net
 [195.34.59.114]
  12 *** Request timed out
  13   179 ms   179 ms   179 ms  e8-2.ibr03.dllstx3.networklayer.com
 [70.87.253.189]
  14   190 ms   189 ms   190 ms  e1-1.ibr01.hstntx2.networklayer.com
 [70.87.253.50]
  15   190 ms   190 ms   190 ms  te2-2.dsr02.hstntx2.networklayer.com
 [74.55.252.38]
  16   184 ms   185 ms   184 ms  po2.car3.hstntx2.networklayer.com
 [74.55.252.106]
  17   189 ms   189 ms   189 ms  
 ev1s-209-62-105-19.theplanet.com[209.62.105.19]

 Trace finished

 C:\Program Files (x86)\Far2tracert haskell.org

 Tracing to haskell.org [78.46.100.180], max hops = 30

  1 4 ms 3 ms 2 ms  bsr01.nn.ertelecom.ru [91.144.184.69]
  2 *2 ms 2 ms  net184-77.nn.ertelecom.ru [91.144.184.77]
  310 ms 9 ms 9 ms
 NNOV-D2-HQ-XX---1-3-0.499.main.synterra.ru [83.229.187.17]
  4 9 ms 9 ms11 ms  83.229.226.101
  510 ms 9 ms 9 ms  m9-cr01-te4-3.msk.stream-internet.net
 [195.34.38.37]
  655 ms55 ms55 ms  ss-crs-1-be3.msk.stream-internet.net
 [195.34.53.86]
  753 ms52 ms52 ms  m9-crs-1-be9.msk.stream-internet.net
 [195.34.59.250]
  855 ms55 ms55 ms  bor-crs-1-be1.spb.stream-internet.net
 [195.34.53.126]
  952 ms52 ms52 ms  anc-cr01-po3.ff.stream-internet.net
 [195.34.53.102]
  1052 ms52 ms52 ms  anc-cr02-po1.ff.stream-internet.net
 [212.188.0.122]
  1156 ms56 ms56 ms  decix2-gw.hetzner.de [80.81.193.164]
  1260 ms60 ms60 ms  
 hos-bb1.juniper1.fs.hetzner.de[213.239.240.242]
  1364 ms61 ms63 ms  
 hos-tr1.ex3k10.rz12.hetzner.de[213.239.228.139]
  1460 ms60 ms62 ms  lambda.haskell.org [78.46.100.180]

 Trace finished


 --
 Eugene Kirpichov
 Senior Software Engineer,
 Grid Dynamics http://www.griddynamics.com/

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

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


[Haskell-cafe] dot-ghci files

2010-12-08 Thread Tony Morris
I teach haskell quite a lot. I recommend using .ghci files in projects.
Today I received complaints about the fact that ghci will reject .ghci
if it is group-writeable. I didn't offer an opinion on the matter. I am
wondering if these complaints have legitimate grounds i.e. maybe you
want to have group write on that file for some reason.

I'd appreciate some comments on this issue. Thanks.

-- 
Tony Morris
http://tmorris.net/



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


[Haskell-cafe] Load testing

2010-11-28 Thread Tony Morris
Does there exist a package for convenient load-testing against a
website? e.g. making lots of HTTP requests against a server, including
timing, and collecting the results?

-- 
Tony Morris
http://tmorris.net/


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


[Haskell-cafe] category-extras clash with transformers

2010-11-20 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I have installed mtl-1.1.1.0 so that xmonad-contrib-0.9.1 would compile
with GHC 6.12.1.
http://permalink.gmane.org/gmane.comp.lang.haskell.xmonad/10603

Then I tried to installed category-extras-0.53.5, which clashed with
transformers-0.2.2.0 for the Applicative/Monad instances for Either.

Is there any way out of this problem? Thanks for any pointers.

$ ghc-pkg list | grep mtl
mtl-1.1.1.0
mtl-2.0.1.0
$ ghc-pkg list | grep transformers
transformers-0.2.2.0
$ cabal install category-extras
...
[39 of 99] Compiling Control.Monad.Either ( src/Control/Monad/Either.hs,
dist/build/Control/Monad/Either.o )

src/Control/Monad/Either.hs:44:9:
Duplicate instance declarations:
  instance Monad (Either e)
-- Defined at src/Control/Monad/Either.hs:44:9-24
  instance Monad (Either e)
-- Defined in transformers-0.2.2.0:Control.Monad.Trans.Error

src/Control/Monad/Either.hs:49:9:
Duplicate instance declarations:
  instance Applicative (Either e)
-- Defined at src/Control/Monad/Either.hs:49:9-30
  instance Applicative (Either e)
-- Defined in transformers-0.2.2.0:Control.Monad.Trans.Error

src/Control/Monad/Either.hs:53:9:
Duplicate instance declarations:
  instance MonadFix (Either e)
-- Defined at src/Control/Monad/Either.hs:53:9-27
  instance MonadFix (Either e)
-- Defined in transformers-0.2.2.0:Control.Monad.Trans.Error
cabal: Error: some packages failed to install:
category-extras-0.53.5 failed during the building phase. The exception
was:
ExitFailure 1

- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkznxgQACgkQmnpgrYe6r60dkACfZQkYKbMOQuGfaVpFb2MfhJWD
asAAn1/hoX+m/YpUOch3r4NsR99y2htz
=IsZc
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] category-extras clash with transformers

2010-11-20 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 21/11/10 04:43, Ross Paterson wrote:
 On Sat, Nov 20, 2010 at 10:58:44PM +1000, Tony Morris wrote:
 I have installed mtl-1.1.1.0 so that xmonad-contrib-0.9.1 would
 compile with GHC 6.12.1.
 http://permalink.gmane.org/gmane.comp.lang.haskell.xmonad/10603

 Then I tried to installed category-extras-0.53.5, which clashed
 with transformers-0.2.2.0 for the Applicative/Monad instances for
 Either.

 Is there any way out of this problem? Thanks for any pointers.

 The instance in question is in the base package from GHC 7, which
 should avoid this problem of clashing orphans in the future.
 Unfortunately that doesn't help you -- I think both xmonad-contrib
 and category-extras need to be updated.
 ___ Haskell-Cafe
 mailing list Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
Thanks Ross,
I just wish to confirm -- I'm totally screwed, right?

- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzoSnsACgkQmnpgrYe6r62K3QCgnxkRqnQbv0FlKBy1sfrxcoKC
1zcAoM295VGFZBo/OQR1Qq4jW1zI3C+D
=FRrh
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] category-extras clash with transformers

2010-11-20 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 21/11/10 08:41, Edward Z. Yang wrote:
 No, you're not totally screwed; you just need to bug
 xmonad-contrib and category-extras to fix their code.

 Edward
I am wondering if upgrading from 6.12.1 to 6.12.3 will allow me to
compile xmonad-contrib* and therefore, be ride of the old version of
mtl and therefore, can install category extras.

*

$ cabal install xmonad-contrib
Resolving dependencies...
Configuring xmonad-contrib-0.9.1...
Preprocessing library xmonad-contrib-0.9.1...
Building xmonad-contrib-0.9.1...
[  1 of 180] Compiling XMonad.Util.Replace ( XMonad/Util/Replace.hs,
dist/build/XMonad/Util/Replace.o )

XMonad/Util/Replace.hs:1:0:
Warning: Module `Prelude' is deprecated:
   You are using the old package `base' version 3.x.
   Future GHC versions will not support base version 3.x. You
   should update your code to use the new base version 4.x.
[  2 of 180] Compiling XMonad.Util.CustomKeys (
XMonad/Util/CustomKeys.hs, dist/build/XMonad/Util/CustomKeys.o )

XMonad/Util/CustomKeys.hs:80:23:
Not in scope: data constructor `Reader'
cabal: Error: some packages failed to install:
xmonad-contrib-0.9.1 failed during the building phase. The exception was:
ExitFailure 1



- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzoUrYACgkQmnpgrYe6r60E4QCfXjGuWsu9xLcEVn142+lJkzRQ
+0QAoJpbYpioJaIeuygxZXKLHKb7fRBk
=dBSD
-END PGP SIGNATURE-

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


[Haskell-cafe] Non-hackage cabal source

2010-11-02 Thread Tony Morris
I am trying to set up an apache server as an additional source to
hackage for haskell packages.

I have added to my ~/.cabal/config file:
remote-repo: myhackage:http://myhackage/packages

I am able to successfully make the HTTP requests:
http://myhackage/packages/00-index.tar.gz
http://myhackage/packages/MyPackage/0.0.1/MyPackage-0.0.1-tar.gz

I can execute:

$ tar -tvf 00-index.tar.gz
-rw-r--r-- root/root  1491 2010-11-03 15:16
./MyPackage/0.0.1/MyPackage.cabal

However, when I try to unpack my package with cabal:
$ cabal unpack MyPackage
Downloading MyPackage-0.0.1...
cabal: Failed to download
http://myhackage/packages/package/MyPackage-0.0.1.tar.gz : ErrorMisc
Unsucessful HTTP code: 404

Why is cabal even making this request?
Why is it not making the request to
http://myhackage/packages/MyPackage/0.0.1/MyPackage-0.0.1.tar.gz

Thanks for any tips.

-- 
Tony Morris
http://tmorris.net/

 

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


Re: [Haskell-cafe] Re: Re: A rant against the blurb on the Haskell front page

2010-10-16 Thread Tony Morris


On 17/10/10 12:03, Ben Franksen wrote:
 wren ng thornton wrote:
   
 On 10/16/10 10:48 AM, Ben Franksen wrote:
 
 Don Stewart wrote:
   
 It is open source, and was born open source. It is the product of
 research.
 
 How can a language be open source, or rather, how can it *not* be open
 source? The point of a (programming) language is that it has a published
 ('open') definition. Nothing prevents anyone from creating a proprietary
 compiler or interpreter for Haskell, AFAIK.
   
 Miranda[TM] is/was a proprietary language, quite definitively so. If
 nothing else, this should be apparent by the fact that every reference
 to it in research papers of the era (a) included the TM sigil, and (b)
 had footnotes indicating who the IP holders are. That was before my
 time, but I was under the impression that Haskell was open from the
 beginning ---by express intention--- in order to enable work on lazy
 functional languages without being encumbered by Miranda[TM]'s closed
 nature.

 For that matter, until rather recently Java was very much a closed
 language defined by the runtime system provided by Sun Microsystems and
 not defined by the sequence of characters accepted by that system, nor
 by the behavior of the system when it accepts them. Sun even went
 through some trouble to try to shut out competitive development of
 runtime systems such as SoyLatte, IcedTea, and the like.

 Even the venerable C language has a long history of companies making
 proprietary extensions to the language in order to require you to buy
 their compiler, and they would most certainly pursue legal action if
 someone else copied the features. This is why GCC is as big a coup for
 the free/open-source movement as Linux is--- long before GCC changed its
 name and focus to being a compiler collection.

 The languages which are open-source are in close correspondence with the
 languages which have a free/open-source implementation. There are a lot
 of them, including the vast majority of recent languages. But don't be
 seduced into thinking that a language is a predicate on acceptable
 strings, a transducer from those strings into computer behaviors, or
 that such predicates and transducers are public domain.
 
 Sigh. Yes, you are right, of course. All this is true, sadly. There are
 stupid people who think that they can own a programming language. I hope
 they will go the way all the other mis-adapted creatures have gone and just
 die out.

 Still, Haskell is an open source product doesn't sound right to me.
 Even Haskell is open source (without the product) has a bad ring
 because source is short for source code and source code is not
 something a programming language has.

 I agree that non-proprietary is a valid and important characterization of
 the language. This should be mentioned where we speak about libraries and
 community, since the active and friendly community is the motor behind the
 growing set of libraries, and you get this sort of participation only with
 a free/non-proprietary language. This applies not only to individuals but
 to companies as well, maybe even more.

 I anticipate the objection that potential commercial users might be scared
 off by the terms non-proprietary or free, whereas the term open
 source has been coined to (and probably actually does) sound more commerce
 friendly. To countermand such an effect, we can point out that most
 libraries have non-copyleft licenses and that there are a number of
 companies who have done and still do a lot to support and advance Haskell.

 Cheers
 Ben

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

   
I am somewhat sympathetic to your argument, but I care far less overall.

Nevertheless, perhaps this would appease:

Haskell is an open standard with a robust open source implementation.

-- 
Tony Morris
http://tmorris.net/


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


[Haskell-cafe] Network.HTTP, BasicAuth+Headers

2010-10-04 Thread Tony Morris
I'm trying to send a simple request using Network.HTTP and getting a bit
lost in all the possibilities. I've experimented with both Network.HTTP and
Network.Browser but have been unable to come up with something specific to
my needs, which are quite simple.

I'd like to send a request equivalent to the following curl:

curl --basic -u user:pass -H Accept: application/xml -H Content-type:
application/xml https://host/path;

It seems with Network.Browser I cannot send headers, but with Network.HTTP I
cannot see how to send the BasicAuth information.

Any tips are appreciated.

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


[Haskell-cafe] Hackage package download count

2010-09-09 Thread Tony Hannan
Is there anywhere we can see the number of download for a particular
package, especially ones you maintain yourself?

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


Re: [Haskell-cafe] Hackage package download count

2010-09-09 Thread Tony Hannan
Nice, thanks, looking forward to it.

On Thu, Sep 9, 2010 at 12:14 PM, Duncan Coutts duncan.cou...@googlemail.com
 wrote:

 On 9 September 2010 14:56, Tony Hannan tonyhann...@gmail.com wrote:
  Is there anywhere we can see the number of download for a particular
  package, especially ones you maintain yourself?

 And the new hackage server implementation maintains download counts.

 See the server test instance here: http://sparky.haskell.org:8080/

 Duncan

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


Re: [Haskell-cafe] Unwrapping newtypes

2010-09-08 Thread Tony Morris
I think you might want -XGeneralizedNewtypeDeriving

http://haskell.org/ghc/docs/6.12.2/html/users_guide/deriving.html#id659906

On 08/09/10 22:01, Kevin Jardine wrote:
 I have a generic object that I want to wrap in various newtypes to
 better facilitate type checking.

 For example,

 newtype Blog = Blog Obj
 newtype Comment = Comment Obj
 newtype User = User Obj

 Unlike Obj itself, whose internal structure is hidden in a library
 module, the newtype wrappings are purely to facilitate type checking.
 It is no secret that each is just a wrapper around Obj.

 It is obvious how to construct the various wrapper objects. It is not
 so obvious how to extract the Obj they contain in a reasonably generic
 way however. What I want is a getObj function that works on all of
 them.

 Of course this could work if someone using the library wrote an
 instance for each wrapper object:

 instance GetObject Blog where
 getObj (Blog obj) = obj

 but this is a pain in the neck to write for each newtype.

 I discovered that Foldable defines a handy toList function that
 extracts content from generic Foldable structures.

 So that I could write:

 toObj :: Foldable thing = thing Obj - Obj
 toObj w = head $ toList w

 Slightly kludgy but it works.

 Even better, recent versions of GHC will allow you to automatically
 derive Foldable.

 Unfortunately,

 newtype Blog = Blog Obj deriving Foldable

 returns a kind error.

 What does work is:

 newtype BlogF a = Blog a deriving Foldable
 type Blog = BlogF Obj

 After having spent close to a day on this, I am a bit baffled that
 such a seemingly trivial problem seems so hard to do.

 I am wondering if I am missing something really, really obvious.

 Any suggestions? Or is there perhaps a more Haskelly way to place type
 constraints on a more generic type?

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

   

-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Re: Unwrapping newtypes

2010-09-08 Thread Tony Morris


On 08/09/10 22:19, Kevin Jardine wrote:
 Hi Tony,

 I stared at that specific section for at least half an hour earlier
 today but could not figure out how it applied in my specific case. The
 only examples I have see are for deriving Num. Do you have any more
 detail on how I could use that extension?

   
Here is an example:

{-# LANGUAGE GeneralizedNewtypeDeriving #-}

class C a where
  c :: a - Int

data G = G

instance C G where
  c _ = 7

newtype H = H G deriving C

-- 
Tony Morris
http://tmorris.net/


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


[Haskell-cafe] lambdacats

2010-08-05 Thread Tony Morris
Hello, does anyone happen to have the lambdacats page cached? The domain (
arcanux.org) and server have disappeared and the wayback machine doesn't
have the images.

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


Re: [Haskell-cafe] lambdacats

2010-08-05 Thread Tony Morris
I wonder if the original site is recoverable from this, but I suspect there
are some missing.

On Fri, Aug 6, 2010 at 2:33 PM, Don Stewart d...@galois.com wrote:

 ivan.miljenovic:
  On 6 August 2010 14:12, Tony Morris tonymor...@gmail.com wrote:
   Hello, does anyone happen to have the lambdacats page cached? The
 domain
   (arcanux.org) and server have disappeared and the wayback machine
 doesn't
   have the images.
 

 Plenty of stuff shows up on google:

http://images.google.com/images?q=lambdacats




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


[Haskell-cafe] Monad transformers, design

2010-07-31 Thread Tony Morris
Hello I have a question regarding monad transformers and how to design
an API with a transformer. I have a narrowed code example of the
question. Please see the questions in the comments below.



import Data.Monoid
import Control.Monad

-- Suppose some data type
newtype Inter a = Inter (Int - a)

-- and a monad transformer for that data type.
newtype InterT m a = InterT (m (Inter a))

-- It's easy to implement this type-class
instance (Monoid a) = Monoid (Inter a) where
  mempty = Inter (const mempty)
  Inter a `mappend` Inter b = Inter (a `mappend` b)

-- and for the transformer too by lifting into the monad
instance (Monad m, Monoid a) = Monoid (InterT m a) where
  mempty = InterT (return mempty)
  InterT a `mappend` InterT b = InterT (liftM2 mappend a b)

-- But what about this type-class?
class Ints a where
  ints :: a - Int - Int

-- Seems easy enough
instance (Integral a) = Ints (Inter a) where
  ints (Inter a) n = fromIntegral (a n)

-- OH NO!
{-
instance (Monad m, Integral a) = Ints (InterT m a) where
  ints (InterT a) n = error OH NO!
-}

-- We could try this
class Copointed f where
  copoint :: f a - a

-- but it seems rather impractical
instance (Copointed m, Integral a) = Ints (InterT m a) where
  ints (InterT a) = ints (copoint a)

{-
So it seems that for some type-classes it is possible to implement
for both the data type and the transformer, but not all type-classes.

Is there a general approach to this problem?
-}



-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Monad transformers, design

2010-07-31 Thread Tony Morris
gah you're right, @mtl had confuzzled me.

Well that changes things then, thanks.

Ross Paterson wrote:
 On Sat, Jul 31, 2010 at 10:56:31PM +1000, Tony Morris wrote:
   
 -- Suppose some data type
 newtype Inter a = Inter (Int - a)

 -- and a monad transformer for that data type.
 newtype InterT m a = InterT (m (Inter a))
 

 The monad transformer should be Inter (m a).
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

   

-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Type-Level Programming

2010-06-26 Thread Tony Morris
http://www.cs.nott.ac.uk/~txa/publ/ydtm.pdf

Andrew Coppin wrote:
 Liam O'Connor wrote:
 It means that not only can values have types, types can have values.
   

 Uh, don't types have values *now*?

 An example of the uses of a dependent type would be to encode the
 length of a list in it's type.
   

 Oh, right. So you mean that as well as being able to say Foo Bar,
 you can say Foo 7, where 7 is (of course) a value rather than a
 type. (?)

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


-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Re: ANN: bitspeak 0.0.1

2010-06-22 Thread Tony Finch
On Mon, 21 Jun 2010, Maurí­cio CA wrote:

   bitspeak is a small proof of concept application that allows
   writing text using only two commands (yes/no, 1/2, top/down etc.).
 
  There is a parallel between data compression algorithms and this sort of
  task, expressing a sentence in the minimal number of bits via
  compression also minimized the number of yes/no questions that need to
  be asked.
 
  In particular, a Huffman coding:

 Sure, Huffman was actually my first tought. But I couldn't think
 of a pratical display for the result of Huffman encoding that
 could be easily followed by a human looking at the screen.

http://www.inference.phy.cam.ac.uk/dasher/

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
SOUTH BISCAY: EASTERLY OR NORTHEASTERLY 4 OR 5, OCCASIONALLY 6 IN SOUTHWEST.
SLIGHT OR MODERATE. FAIR. GOOD.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Retrospective type-class extension

2010-05-20 Thread Tony Morris
Ivan Miljenovic wrote:
 On 20 May 2010 14:42, Tony Morris tonymor...@gmail.com wrote:
   
 We all know that class (Functor f) = Monad f is preferable but its
 absence is a historical mistake. We've all probably tried once:

 instance (Functor f) = Monad f where
 

 Do you mean the reverse of this (instance (Monad m) = Functor m where) ?
   
Yes.

-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Retrospective type-class extension

2010-05-20 Thread Tony Morris
I've compared and clearly the former is significantly superior :)

I'm rather interested if there are any sound suggestions to resolve the
general issue of retrospective type-class extension.


Miguel Mitrofanov wrote:
 That won't be a great idea; if I just want my monad to be declared as
 one, I would have to write

 instance Functor MyMonad where fmap = ...
 instance Pointed MyMonad where pure = ...
 instance Applicative MyMonad where (*) = ...
 instance Monad MyMonad where join = ...

 Compare this with

 instance Monad MyMonad where
   return = ...
   (=) = ...

 and take into account that (=) is usually easier to write than join.

 Limestraël wrote:
 Then it would be:

 class Functor f where
 fmap :: (a - b) - f a - f b

 class (Functor f) = Pointed f where
 pure :: a - f a

 class (Pointed f) = Applicative f where
 (*) :: f (a - b) - f a - f b

 class (Applicative f) = Monad f where
 join :: f (f a) - f a

 This would be a great idea, for the sake of logic, first (a monad
 which is not a functor doesn't make sense), and also to eliminate
 redudancy (fmap = liftM, ap = (*), etc.)

 2010/5/20 Tony Morris tonymor...@gmail.com
 mailto:tonymor...@gmail.com

 Ivan Miljenovic wrote:
   On 20 May 2010 14:42, Tony Morris tonymor...@gmail.com
 mailto:tonymor...@gmail.com wrote:
  
   We all know that class (Functor f) = Monad f is preferable
 but its
   absence is a historical mistake. We've all probably tried once:
  
   instance (Functor f) = Monad f where
  
  
   Do you mean the reverse of this (instance (Monad m) = Functor m
 where) ?
  
 Yes.

 --
 Tony Morris
 http://tmorris.net/


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org mailto: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


-- 
Tony Morris
http://tmorris.net/


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


[Haskell-cafe] Retrospective type-class extension

2010-05-19 Thread Tony Morris
We all know that class (Functor f) = Monad f is preferable but its
absence is a historical mistake. We've all probably tried once:

instance (Functor f) = Monad f where
...

However, is there a type system extension (even proposed but not
implemented) that allows me to retrospectively apply such a notion?

Ideally something like this would be handy if it could somehow be
retrospectively applied:
Monad - Applicative - Pointed - Functor


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


Re: [Haskell] Monads Terminology Question

2010-04-11 Thread Tony Morris
I think these names are specific to each data type (which happens to be
a monad) so unless they generalise, then they are not deserving of any
special terminology than any other functions.

While State and Reader are both Monads, they are also many other things
such as Functor and Applicative (and perhaps more), so this doesn't
require any special treatment.

Mark Snyder wrote:
 Hello,

 I'm wondering what the correct terminology is for the extra functions 
 that we define with monads.  For instance, State has get and put, Reader has 
 ask and local, etc.  Is there a good name for these?  I've been calling them 
 the non-proper morphisms (as opposed to the proper morphisms unit/return 
 and bind).  But I don't know if others call them that.  Is there any accepted 
 phrase for them?

 Thanks,
 ~Mark Snyder


   
   
 

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


-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Hackage accounts and real names

2010-04-06 Thread Tony Finch
I note that in some jurisdictions there is no such thing as a real name.
You can change your name for legal purposes (on official documentation and
so forth) simply by asserting that this is the name you prefer to be known
by. Your legal name doesn't have to be the same as your everyday name
(mine isn't).

What matters is continuity of identity and the ability to link your
identities across the places you participate.

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the meaning of tilde (~) symbol

2010-02-14 Thread Tony Morris
Stephen Tetley wrote:
 Hi Evan

 Singleton (aka wrap) would be nice - isn't it called Pointed in the
 typeclassopedia but not otherwise existent? I suppose its missing by
 historical accident rather than design.

 I frequently use Semigroup (append but no zero) - there is one on
 Hackage without any instances:
 http://hackage.haskell.org/package/algebra
   
I do too. I also wish there was an associative: class F f where k :: f a
- f a - f a without the zero component.


-- 
Tony Morris
http://tmorris.net/


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


[Haskell-cafe] Lazy language on JVM/CLR

2010-02-08 Thread Tony Morris
I have hypothesised a pure, lazy language on the JVM and perhaps the
.NET CLR with FFI to .NET/Java libraries. I foresee various problems but
none that are catastrophic; just often requiring a compromises,
sometimes very unattractive compromises. I have authored several
libraries in the same vain as pure, lazy programming to run on the JVM
in Java and Scala programming languages.

I expect others have forethought and perhaps even experimented with such
a language. Are there any dangers to be wary of that undo the entire
endeavour?

Thanks for any insights.

-- 
Tony Morris
http://tmorris.net/

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


Re: [Haskell-cafe] Game of life in haskell.

2010-02-02 Thread Tony Finch
On Tue, 2 Feb 2010, Arne D Halvorsen wrote:

 If I may butt in here: to get a scalable, fast Game of Life, you should look
 into Hashlife (by Gosper?) as exemplified in the open source application
 Golly. It gives an astonishing speedup, and it would be interesting to see it
 expressed in Haskell.

I played around with implementing hashlife a few years ago. It is a truly
beautiful algorithm, and mind-expanding if all you know is representing
Life as an array of booleans.

The problem with implementing it in Haskell is it relies on persistent
object identities (of the branches of a quadtree) that it hashes in order
to memoize quadtree creation. This makes what ought to be a beautifully
quasi-functional algorithm look ugly and imperative.

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Game of life in haskell.

2010-02-02 Thread Tony Finch
On Tue, 2 Feb 2010, Serguey Zefirov wrote:

 Creation of new Array is (without knowing some subtle details) is
 O(max coordinates difference between live cells). Creation of new Set
 (X,Y) is O(NlogN) (N = number of live objects). Most of the cells in
 Life are empty, so the Set/Map approach is faster. Also it leads to
 very concise code.

I have a small and relatively quick Life algorithm that's based on lists,
so it should translato to Haskell quite nicely.

The basic representation of the Life universe is a sorted list of the
co-ordinates of live cells. You can compute a new generation in one scan
of the list, or rather a kind of zip3 that scans a 3x3 box along three
adjacent rows, skipping empty space. It's much faster if, instead of
storing one live cell in each list element, you store a small word-sized
bitmap. You can then use SIMD-within-a-register to combine the three rows
of cells and emit a new bitmap if it is non-zero.

Have a look at http://dotat.at/prog/life/life.html for the story of how I
developed the algorithm, including C source (about 40 lines of code).
I've written a couple of other articles about SWAR techniques for Life:
http://fanf.livejournal.com/81169.html
http://fanf.livejournal.com/93032.html

Getting the bits onto the screen quickly is the hardest part :-)

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Game of life in haskell.

2010-02-02 Thread Tony Finch
On Tue, 2 Feb 2010, ed...@ymonad.com wrote:

 http://dotat.at/prog/life/hslife.hs

Er, yes, I didn't link to that in my earlier message because it's a
half-completed attempt. I think I got to the stage of realising that I
needed to write a monad or a monad transformer to thread the hash cons
state through the code without it getting in the way.

For those interested in Hash Life whether or not it's written in
Haskell, there's a description of how it works in
http://dotat.at/prog/life/hashlife.c
though that code is also incomplete.

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Game of life in haskell.

2010-02-02 Thread Tony Finch

On 3 Feb 2010, at 02:04, Jon Harrop j...@ffconsultancy.com wrote:

On Tuesday 02 February 2010 23:54:58 Richard O'Keefe wrote:


One message in this thread has already pointed to a
solution (in C) that in effect uses a bit-packed sparse  
representation
to achieve high speed.  The point is that that approach takes time  
(and

space) per generation proportional to the number of occupied cells,
not the size of the space, and that is the basis of the scaling  
claim.

A simple Haskell analogue, which has the right asymptotic cost, would
be to represent a Life generation by a list of
   (row_number, [col_no, ..., col_no])
pairs in strictly ascending order of row number, where each pair
contains a list of the numbers of the occupied columns in strictly
ascending order.  The space is (number of occupied cells * a  
constant)

+ (number of occupied rows * another constant).  Computing the next
generation then amounts to a bunch of 3-way merges.


That will be a lot faster than using Map or Set but you're still  
paying a lot
for the indirections between cons cells. Mutating an array in-place  
would be
significantly faster and no more difficult to code correctly because  
this is

such a trivial algorithm.


Richard's description is pretty much exactly what I had in mind for a  
Haskell version of my C code. The C translates to Haskell so well  
because its data structure is immutable: the new generation is written  
to fresh memory then the old generation becomes garbage. The old  
generation is scanned in the order it is written (albeit by three  
pointers with a row between each one) which is inconvenient for linked  
lists. However the algorithm is symmetrical so it doesn't mind  
processing the universe in alternating directions, so long as the  
rendering code can cope :-) The indirections are less bad than they  
might be because the code will always be following a pointer to an  
adjacent memory location, because of the algorithm's simple allocation  
behaviour. But it'll be about twice as slow as the C equivalent  
because it uses twice the memory.


Efficient mutate-in-place Life algorithms become disgustingly  
complicated before they can beat listlife.


Tony.
--
f.anthony.n.finch  d...@dotat.at  http://dotat.at/

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


Re: [Haskell-cafe] Maybe, maybe not.

2010-01-26 Thread Tony Morris
It might be more obvious by giving:

fromMaybe :: a - (a - x, x) - x

Ivan Miljenovic wrote:
 2010/1/27 Edward Z. Yang ezy...@mit.edu:
   
 Excerpts from Daniel Peebles's message of Tue Jan 26 23:25:28 -0500 2010:
 
 There are actually only two (extensionally) possible total functions with
 that type, as far as I can see :)
   
 Is the other one... const?
 

 As far as I can tell, yes.

   


-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Maybe, maybe not.

2010-01-26 Thread Tony Morris
Ivan Miljenovic wrote:
 2010/1/27 Tony Morris tonymor...@gmail.com:
   
 It might be more obvious by giving:

 fromMaybe :: a - (a - x, x) - x
 

 I actually found this more confusing, and am not sure of its validity:
 should that be Maybe a there at the beginning?

   

Sorry a mistake. Correction: fromMaybe :: a - ((a - x, x) - x) - x

{-# LANGUAGE RankNTypes #-}

data Maybe' a = M (forall x. (a - x, x) - x)

to :: Maybe' t - Maybe t
to (M f) = f (Just, Nothing)

from :: Maybe a - Maybe' a
from (Just a) = M (flip fst a)
from Nothing  = M snd


-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Parse error

2010-01-17 Thread Tony Morris
No, but there's a specific reason why GHC consistently refuses to accept
your perfectly unreasonable code snippet :)

GHC accepts the following perfectly reasonable code snippet:

main = do
 putStrLn Line 1
 putStrLn Line 2

 let xs = do x - [1..10]
 y - [1..10]
 return (x+y)

 print xs

Andrew Coppin wrote:
 Is there a specific reason why GHC consistently refuses to accept the
 following perfectly reasonable code snippet?

 main = do
  putStrLn Line 1
  putStrLn Line 2

  let xs = do
x - [1..10]
y - [1..10]
return (x+y)

  print xs

 No matter which way I rearrange this, it *insists* that there's a
 parse error. This is very frustrating, given that it's utterly clear
 what I want...

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


-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Language simplicity

2010-01-12 Thread Tony Morris
Andrew Coppin wrote:
 OK people, it's random statistics time!

 Haskell '98 apparently features 25 reserved words. (Not counting
 forall and mdo and so on, which AFAIK are not in Haskell '98.) So
 how does that compare to other languages?

 C: 32
 C++: 62
 Borland Turbo Pascal: ~50 [without the OOP extensions added later]
 Eiffel: 59
 VB: The source I checked listed in excess of 120 reserved words, but
 I'm dubious as to how reserved they really are. (Is CInt really
 reserved? I doubt it!) It also depends wildly on which of the
 bazillion VB dialects you mean.
 Java: 50
 JavaScript: 36
 Smalltalk: 0
 Lisp: AFAIK, there are no truly reserved words in Lisp, only
 predefined functions. (??)
 Python: 31
 Ruby: 38
 Tcl: Same analysis as for Lisp I believe.

 As you can see, this conclusively proves... something.

 Hmm, I wonder if there's some way to compare the size of the language
 specification documents? :-}

 PS. It comes as absolutely no surprise to me that C++ has the most
 keywords. But then, if I were to add AMOS Professional, that had well
 over 800 keywords at the last count...

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

Java has 53 reserved words.

-- 
Tony Morris
http://tmorris.net/


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


[Haskell-cafe] ghc -e

2010-01-06 Thread Tony Morris
Can I import a module when using ghc -e?

e.g. ghc -e import Control.Monad; forM [[1,2,3]] reverse

-- 
Tony Morris
http://tmorris.net/

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


Re: [Haskell-cafe] ghc -e

2010-01-06 Thread Tony Morris
Gwern Branwen wrote:
 On Wed, Jan 6, 2010 at 7:23 PM, Tony Morris tonymor...@gmail.com wrote:
   
 ghc -e import Control.Monad; forM [[1,2,3]] reverse
 

 As of 6.10.2, the bug whereby the GHC API lets you use functions from
 anywhere just by naming them (Java-style) has not been fixed:

 $ ghc -e Control.Monad.forM [[1,2,3]] reverse
 package flags have changed, resetting and loading new packages...

 interactive:1:25:
 Warning: Defaulting the following constraint(s) to type `Integer'
  `Num t' arising from the literal `3' at interactive:1:25
 In the expression: 3
 In the expression: [1, 2, 3]
 In the first argument of `forM', namely `[[1, 2, 3]]'

 interactive:1:25:
 Warning: Defaulting the following constraint(s) to type `Integer'
  `Num t' arising from the literal `3' at interactive:1:25
 In the expression: 3
 In the expression: [1, 2, 3]
 In the first argument of `forM', namely `[[1, 2, 3]]'
 [[3],[2],[1]]
 it :: [[Integer]]
 (0.01 secs, 1710984 bytes)

   
I see the same on GHC 6.10.4.
$ ghc -e Control.Monad.forM [[1,2,3]] reverse
[[3],[2],[1]]


What would it be fixed to? What is wrong with how it is?

-- 
Tony Morris
http://tmorris.net/


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


[Haskell-cafe] (liftM join .) . mapM

2009-12-29 Thread Tony Morris
Can (liftM join .) . mapM be improved?
(Monad m) = (a - m [b]) - [a] - m [b]

-- 
Tony Morris
http://tmorris.net/


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


[Haskell-cafe] Children elements with HXT

2009-12-22 Thread Tony Morris
I am trying to parse XML using HXT following
http://www.haskell.org/haskellwiki/HXT/Conversion_of_Haskell_data_from/to_XML

Here is my XML file (way.xml):

way id=27776903 visible=true timestamp=2009-05-31T13:39:15Z
version=3 changeset=1368552 user=Matt uid=70
  tag k=access v=private/
  tag k=highway v=service/
/way

The problem is when parsing, by reading the tag entries into the
list held by the Way data structure, I cannot get anything but an
empty list.

Here is my parsing code:

import Text.XML.HXT.Arrow

newtype Way = Way {
  tags :: [Tag]
} deriving (Eq, Show)

xpWay :: PU Way
xpWay = xpElem way (xpWrap (Way, tags) (xpList xpTag))

data Tag = Tag {
  k :: String,
  v :: String
} deriving (Eq, Show)

xpTag :: PU Tag
xpTag = xpElem tag (xpWrap (uncurry Tag, k  v) (xpPair (xpAttr
k xpText) (xpAttr v xpText)))

When I run, I get the following result:

Main run = runX (xunpickleDocument xpWay [] way.xml)
[Way {tags = []}]

Why is the tags list empty instead of holding two entries?


-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Children elements with HXT

2009-12-22 Thread Tony Morris
Adding (a_remove_whitespace,v_1) as a parser option when running solves
it. Silly me.


Tony Morris wrote:
 I am trying to parse XML using HXT following
 http://www.haskell.org/haskellwiki/HXT/Conversion_of_Haskell_data_from/to_XML

 Here is my XML file (way.xml):

 way id=27776903 visible=true timestamp=2009-05-31T13:39:15Z
 version=3 changeset=1368552 user=Matt uid=70
   tag k=access v=private/
   tag k=highway v=service/
 /way

 The problem is when parsing, by reading the tag entries into the
 list held by the Way data structure, I cannot get anything but an
 empty list.

 Here is my parsing code:

 import Text.XML.HXT.Arrow

 newtype Way = Way {
   tags :: [Tag]
 } deriving (Eq, Show)

 xpWay :: PU Way
 xpWay = xpElem way (xpWrap (Way, tags) (xpList xpTag))

 data Tag = Tag {
   k :: String,
   v :: String
 } deriving (Eq, Show)

 xpTag :: PU Tag
 xpTag = xpElem tag (xpWrap (uncurry Tag, k  v) (xpPair (xpAttr
 k xpText) (xpAttr v xpText)))

 When I run, I get the following result:

 Main run = runX (xunpickleDocument xpWay [] way.xml)
 [Way {tags = []}]

 Why is the tags list empty instead of holding two entries?


   

-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Finding HP

2009-12-03 Thread Tony Morris

 Furthermore, when someone offers feedback designed to improve a page, and 
 does so in a very non-threatening way:

 On Dec 2, 2009, at 2:26 PM, Andrew Coppin wrote:

   
 My suggestion is that if we really want people to grab the HP rather than 
 download GHC directly, maybe we could make the link slightly more prominent? 
 It also wouldn't hurt to mention it from the Implementations page, and 
 maybe the GHC homepage? Just a suggestion...
 

 ... then in my own humble opinion, snapping back with Are you sure this 
 isn't user error? is not a particularly nice response.

   
When someone asks a question after being offered feedback designed to
improve a page, and does so in a very non-threatening way:

 Are you sure this isn't user error?

... then in my own humble opinion, snapping back with \Are you sure
this isn't a user error?\ is not a particularly nice response is not a
particularly nice response.

-- 
Tony Morris
http://tmorris.net/


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


  1   2   3   >