[Haskell-cafe] Re: Laws and partial values

2009-01-24 Thread Henning Thielemann


On Sat, 24 Jan 2009, Thomas Davie wrote:


On 24 Jan 2009, at 21:31, Dan Doel wrote:


For integers, is _|_ equal to 0? 1? 2? ...
Hypothetically (as it's already been pointed out that this is not the case in 
Haskell), _|_ in the integers would not be known, until it became more 
defined.  I'm coming at this from the point of view that bottom would contain 
all the information we could possibly know about a value  while still being 
the least value in the set.


In such a scheme, bottom for Unit would be (), as we always know that the 
value in that type is (); bottom for pairs would be (_|_, _|_), as all pairs 
look like that (this incidentally would allow fmap and second to be equal on 
pairs); bottom for integers would contain no information, etc.


Zero- and one-constructor data types would then significantly differ from 
two- and more-constructor data types, wouldn't they?

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


Re: [Haskell-cafe] Re: Laws and partial values

2009-01-24 Thread Henning Thielemann


On Sat, 24 Jan 2009, Thomas Davie wrote:

I'm not sure why you're saying that this semantics does not capture 
non-termination – the only change is that computations resulting in the unit 
type *can't* non terminate, because we can always optimize them down to (). 
Of course, if you want to be able to deal with non-termination, one could use 
the Maybe () type!


I find the current semantics better: All types are handled the same way by 
default and whenever you want to optimize (undefined::()) to () you can 
use

   optimizeNull :: () - ()
   optimizeNull _ = ()___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] mapM_ - Monoid.Monad.map

2009-01-23 Thread Henning Thielemann


 I always considered the monad functions with names ending on '_' a 
concession to the IO monad. Would you need them for any other monad than 
IO? For self-written monads you would certainly use a monoid instead of 
monadic action, all returning (), but IO is a monad. (You could however 
wrap (newtype Output = Output (IO ())) and define a Monoid instance on 
Output.)
 However our recent Monoid discussion made me think about mapM_, 
sequence_, and friends. I think they could be useful for many monads if 
they would have the type:

 mapM_ :: (Monoid b) = (a - m b) - [a] - m b
  I expect that the Monoid instance of () would yield the same efficiency 
as todays mapM_ and it is also safer since it connects the monadic result 
types of the atomic and the sequenced actions. There was a recent 
discussion on the topic:

 http://neilmitchell.blogspot.com/2008/12/mapm-mapm-and-monadic-statements.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Pure Haskell implementation of Float type?

2009-01-22 Thread Henning Thielemann
Lennart Augustsson schrieb:
 There's the numbers package which contains BigFloat.  You can pick
 your own precision, but it's not IEEE.
 It's actually base 10 floats which makes it more fun (actually, the
 iEEE standard will cover base 10 floats in the future).

Actually, all of the arbitrary precision real number implementations may
be of interest for you:

http://haskell.org/haskellwiki/Applications_and_libraries/Mathematics#Number_representations

The NumericPrelude implementation by me, however, sometimes uses the
Double implementation for speedup.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Elevator pitch for functional programming

2009-01-20 Thread Henning Thielemann
Jim Burton schrieb:

 Well, I might but they definitely do not :-) We are talking about some
 maths-averse people and you would not have got to the final syllable
 of 'fibonacci' before all hope was lost. But I am sure there are 
 plenty of examples that rely on laziness which will communicate. I am
 sure I read a blog post or something on c.l.f/c.l.h recently about
 lazily sorting a million numbers but can't find it. 

Maybe they are interested in finding all equal files in a set of files.
This can be done in an elegant way by sorting the files with respect to
their content. Practical enough?

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/equal-files
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Comments from OCaml Hacker Brian Hurt

2009-01-20 Thread Henning Thielemann


On Thu, 15 Jan 2009, John Goerzen wrote:


 One thing that does annoy me about Haskell- naming. Say you've
 noticed a common pattern, a lot of data structures are similar to
 the difference list I described above, in that they have an empty
 state and the ability to append things onto the end. Now, for
 various reasons, you want to give this pattern a name using on
 Haskell's tools for expressing common idioms as general patterns
 (type classes, in this case). What name do you give it? I'd be
 inclined to call it something like Appendable. But no, Haskell
 calls this pattern a Monoid.


I risk to repeat someones point, since I have not read the entire thread 
... What I don't like about the Monoid class is, that its members are 
named mempty and mappend. It may be either (also respecting 
qualified import)

  Monoid(identity, op)
 or
  Appendable(empty, append)
 where only the first one seems reasonable, since the Sum monoid and its 
friends do not append anything.

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


Re: [Haskell-cafe] Comments from OCaml Hacker Brian Hurt

2009-01-20 Thread Henning Thielemann
John Goerzen schrieb:

 Though if all we're talking about is naming, I would still maintain that
 newbie-friendly naming is a win.  We can always say HEY MATHEMETICIANS:
 APPENDABLE MEANS MONOID in the haddock docs ;-)

We already have a problem with this:
Haskell 98 uses intuitive names for the numeric type classes.
It introduces new names, which do not match the names of common
algebraic structures.
Why is a type Num (numeric?), whenever it supports number literals, (+)
and (*)? Why not just number literals? Why not also division?
The numeric type hierarchy of Haskell must be learned anyway,
but the user learns terms he cannot use outside the Haskell world.
Ring and Field are harder to learn first, but known and precise terms.
(And if you don't like to learn the names, just write functions without
signatures and let GHCi find out the signatures with the appropriate
class constraints.)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Comments from OCaml Hacker Brian Hurt

2009-01-20 Thread Henning Thielemann
Apfelmus, Heinrich schrieb:

 Obviously, those who know what a monoid is have already invested years
 of time practicing mathematics while those that even attack the name
 monoid clearly lack this practice. It's like peano virtuosoes compared
 to beginning keyboard pressers.

Aren't all Haskellers some kind of Peano virtuosos? :-)

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


Re: Improved documentation for Bool (Was: [Haskell-cafe] Comments from OCaml Hacker Brian Hurt)

2009-01-20 Thread Henning Thielemann
rocon...@theorem.ca schrieb:
 On Sun, 18 Jan 2009, Ross Paterson wrote:
 
 Anyone can check out the darcs repos for the libraries, and post
 suggested improvements to the documentation to librar...@haskell.org
 (though you have to subscribe).  It doesn't even have to be a patch.

 Sure, it could be smoother, but there's hardly a flood of contributions.
 
 I noticed the Bool datatype isn't well documented.  Since Bool is not a
 common English word, I figured it could use some haddock to help clarify
 it for newcomers.

The type should be named Truth.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: Coadjute 0.0.1, generic build tool

2009-01-18 Thread Henning Thielemann
Matti Niemenmaa schrieb:
 Announcing the release of Coadjute, version 0.0.1!
 
 Web site: http://iki.fi/matti.niemenmaa/coadjute/
 Hackage:
 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Coadjute
 
 Coadjute is a generic build tool, intended as an easier to use and more
 portable replacement for make. It’s not tailored toward any particular
 language, and is not meant to replace tools which target a specific
 environment (such as ghc --make or Cabal, taking Haskell as an example).
 
 I've been sitting on this for a couple of months now and figured I might
 as well push it out since it seems to be in relative working order. I've
 used it on my web site since July and it hasn't resulted in data loss yet.

How does it compare to
   http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hake

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


[Haskell-cafe] Re: ANNOUNCE: Coadjute 0.0.1, generic build tool

2009-01-18 Thread Henning Thielemann
Matti Niemenmaa schrieb:

 Anyway, hake looks interesting but it's not a replacement for Coadjute;
 and neither is Coadjute for hake. To be completely honest I'm not sure
 what use case hake is meant to solve: how does it improve over plain make?

It seems to be programmable, and thus may better cope with LaTeX, where
the simple 'make' philosophy fails. 'latex' must be called repeatedly,
interleaved with 'bibtex' and 'mkindex'.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: HTTPbis / HTTP-4000.x package available

2009-01-16 Thread Henning Thielemann


On Thu, 15 Jan 2009, Sigbjorn Finne wrote:

I guess it's time to publish more widely the availability of a 
modernization of the venerable and trusted HTTP package, which I've been 
working on offon for a while.


 I was always afraid that a fork may happen during I work on HTTP in order 
to get it more lazy. That's why I started discussion on web-devel mailing 
list, but got only limited response. I also notified Bjorn, that my 
changes need still a little time and that I'm worried about darcs 
conflicts. Seems that we now run into a perfect conflict. I don't like to 
throw away the work that I have done the last weeks.


My version is at
  http://code.haskell.org/~thielema/http/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Open unqualified imports

2009-01-16 Thread Henning Thielemann


On Fri, 16 Jan 2009, eyal.lo...@gmail.com wrote:


I believe that the last type, open-unqualified is a really bad idea,
and should be discouraged or even disallowed. It should definitely not
be the default, like it is today.


You are not alone:
   http://haskell.org/haskellwiki/Import_modules_properly
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Open unqualified imports

2009-01-16 Thread Henning Thielemann


On Fri, 16 Jan 2009, eyal.lo...@gmail.com wrote:


import qualified Control.Monad as M

M.for
M.map

and so on.


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


Re: [Haskell-cafe] ANN: HTTPbis / HTTP-4000.x package available

2009-01-16 Thread Henning Thielemann


On Fri, 16 Jan 2009, Sigbjorn Finne wrote:


gain access to  www.haskell.org and update http://www.haskell.org/http,
so for now you may pick up a new version the lib via

 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HTTP

GIT repo for HTTP-4000  / HTTPbis is here

  git://code.galois.com/HTTPbis.git


Can you please add a motd to the old darcs repository, which tells the 
downloader that this repository has moved to a git repository?

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


Re: [Haskell-cafe] F# active patterns versus GHC's view

2009-01-16 Thread Henning Thielemann


On Fri, 16 Jan 2009, John Van Enk wrote:


2009/1/16 Peter Verswyvelen bugf...@gmail.com


[...]

After a while you decide that you need to change the Bla data type, maybe
give Dog more fields, maybe completely redesign it, maybe not exposing it,
but you want to keep existing code backwards compatible. With F# you can
write Active Patterns for the old Dog and Cat constructors, so all existing
code remains compatible. At least that is the way I understand it, but I
have not actually worked yet with Active Patterns, will do so soon :)


You get something similar with the record syntax (though, probably still not
quite as powerful as the active patterns):


... or use data-accessor package.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: HTTPbis / HTTP-4000.x package available

2009-01-16 Thread Henning Thielemann


On Thu, 15 Jan 2009, Sigbjorn Finne wrote:

I guess it's time to publish more widely the availability of a 
modernization of the venerable and trusted HTTP package, which I've been 
working on offon for a while.


Bunch of changes, but the headline new feature of this new version is 
the parameterization of the representation of payloads in both HTTP 
requests and responses. Two new representations are supported, strict 
and lazy ByteStrings.


After looking into your code it seems that an easy merge will not be 
possible. I'm not quite ready with Lazy I/O, but close to it. I introduced 
a new monad which allows to get rid of explicit usage of the IO monad. I 
also rewrote Network.HTTP in order to handle asynchronous exceptions in a 
clean way, thus making Network.HTTP really lazy. See also the thread:

  http://www.haskell.org/pipermail/web-devel/2008/48.html

I'm really frustrated now, since I invested much time into improvement of 
the HTTP package. I did a lot of communication in order to prevent me from 
doing duplicate work, which already happened in other Haskell projects, 
and now an official successor appears from nowhere which can almost not be 
merged with my effort.

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


Re: [Haskell-cafe] ANN: HTTPbis / HTTP-4000.x package available

2009-01-16 Thread Henning Thielemann
Sigbjorn Finne schrieb:

 Hi Levi,
 
 I'm guessing that you are reading something different into that
 than what's intended - it's client-side in the sense that it can
 only issue web requests and handle their responses. i.e., it
 doesn't handle incoming HTTP requests and issue suitable
 responses. Web server implementation is an interesting problem
 in its own right, and many packages/frameworks do an
 admirable job of that already, so no plans (by me) to tackle
 that via the HTTP package.

There's however still no framework which supports both HTTP client and
server functions using the same Request and Response data type, right? I
don't know whether I am the only one who needs this (e.g. for the Real
Monad Transformer). E.g. a proxy would need this, too.

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


Re: [Haskell-cafe] ANN: HTTPbis / HTTP-4000.x package available

2009-01-16 Thread Henning Thielemann
Don Stewart schrieb:
 lemming:
 On Thu, 15 Jan 2009, Sigbjorn Finne wrote:

 I guess it's time to publish more widely the availability of a 
 modernization of the venerable and trusted HTTP package, which I've been 
 working on offon for a while.
  I was always afraid that a fork may happen during I work on HTTP in order 
 to get it more lazy. That's why I started discussion on web-devel mailing 
 list, but got only limited response. I also notified Bjorn, that my 
 changes need still a little time and that I'm worried about darcs 
 conflicts. Seems that we now run into a perfect conflict. I don't like to 
 throw away the work that I have done the last weeks.

 My version is at
   http://code.haskell.org/~thielema/http/
 
 There's absolutely no need to throw away work. Hackage is a broad
 church, release it as http-lazy, at the very least.

Somehow yes. As I said, it still needs cleanup and I wonder whether I
invest that time in my version or whether I should merge my changes
immediately into HTTP-4000. As it now stands, I can provide laziness and
HTTP-4000 provides ByteStrings and I'm sure people wants both of them.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: HLint 1.2

2009-01-15 Thread Henning Thielemann


On Sun, 11 Jan 2009, Neil Mitchell wrote:


I am pleased to announce HLint version 1.2. HLint is a lint-like tool
for Haskell that detects and suggests improvements for your code.
HLint is compatible with most GHC extensions, and supports a wide
variety of suggestions, and can be extended with additional user
suggestions.

To install: cabal update  cabal install hlint


Fails for me, because of the base-4 dependency. - I'm still using 
GHC-6.8.2. Can HLint suggest view-pattern-free expressions, such that the 
program also runs on GHC-6.8 ?  :-)

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


Re: [Haskell-cafe] ANN: HLint 1.2

2009-01-15 Thread Henning Thielemann


On Thu, 15 Jan 2009, Neil Mitchell wrote:


Hi Henning,


To install: cabal update  cabal install hlint


Fails for me, because of the base-4 dependency. - I'm still using GHC-6.8.2.
Can HLint suggest view-pattern-free expressions, such that the program also
runs on GHC-6.8 ?  :-)


HLint is written using view-patterns so requires GHC 6.10 to compile
it. After you have it compiled its just a standard Haskell binary, so
can be run on any Haskell code and will never suggest view-patterns
anyway.


My question was, whether HLint can help translating HLint to code without 
view patterns.

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


Re: [Haskell-cafe] ANN: HLint 1.2

2009-01-15 Thread Henning Thielemann


On Thu, 15 Jan 2009, Neil Mitchell wrote:


Hi


My question was, whether HLint can help translating HLint to code without
view patterns.


Ah, I misunderstood. Yes, it could (in theory), but it can't
automatically apply the hints it generates. Upgrading to GHC 6.10 is
probably easier :-)


Also throwing away Hugs ... (YHC too ?)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: HLint 1.2

2009-01-15 Thread Henning Thielemann


On Thu, 15 Jan 2009, Neil Mitchell wrote:


I normally develop in Hugs, for a change I wanted to try GHCi. It's
also a project that has loads of pattern matching at a fairly complex
level, so the benefits offered by view-patterns and pattern-guards
were just too hard to pass up.


Are you sure that you can't come up with some nice functions like 'maybe' 
to replace those view patterns by function calls? Did you really try? I 
remember the recent discussion on pattern combinators here on Haskell 
Cafe.

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


Re: [Haskell-cafe] Maintaining laziness

2009-01-14 Thread Henning Thielemann


On Tue, 13 Jan 2009, Jan Christiansen wrote:

I would be very interested in functions that can be improved with respect to 
non-strictness as test cases for my work.


See the List functions in
  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utility-ht

Version 0.0.1 was before applying StrictCheck, 0.0.2 after processing its 
suggestions. I have stopped when I saw that it repeatedly shows examples 
where I expect, that they are unresolvable.

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


[Haskell-cafe] version conflict on Hackage

2009-01-12 Thread Henning Thielemann


I repeatedly encounter the following versioning problem on Hackage:
There is a package A with version 1.0.
I upload a package B which imports A.
Thus B is bound to A-1.0
Now a new version of A is uploaded, say 1.0.1.
then I upload package C which depends both on A and B.
However C is bound to the new A-1.0.1, which gives conflicts with the interface 
of B.
All packages are sane. Both B and C work with either A-1.0 or A-1.0.1,
but they must use the same version.

Currently I'm forced to upload many packages with different versions, 
although nothing really changed.
Maybe the most easiest fix to this problem is to let maintainers of a 
package allow to trigger re-configuration and re-compilation of a package.


I would also like to flag package versions that people can safely ignore, 
because there was a flaw in package dependencies. On the other hand there 
are packages that are useful, but can no longer be compiled on Hackage, 
e.g. compatibility packages for older versions of GHC.

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


Re: [Haskell-cafe] Maintaining laziness

2009-01-12 Thread Henning Thielemann


On Mon, 12 Jan 2009, Jan Christiansen wrote:


Hi,

Although it seems to be overkill for a single module - How about a 
cabalized version on Hackage and a darcs repository? It would simplify 
using and updating it.


I am not sure whether this would be a good idea. The original version makes a 
lot of suggestions which are not satisfiable but it is not at all trivial to 
decide which are satisfiable and which are not. I have rewritten StrictCheck 
from scratch to overcome this problem. But the current implementation is not 
presentable right now and I have no formal prove that the criterion that I am 
using is correct.


As I said, the current version is already very useful. I have applied it 
to several basic functions and found a lot to improve.

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


Re: [Haskell-cafe] ANN: HLint 1.2

2009-01-12 Thread Henning Thielemann


On Mon, 12 Jan 2009, Duncan Coutts wrote:


On Mon, 2009-01-12 at 01:02 +0100, Lennart Augustsson wrote:

Does GHC specialize map?  If it doesn't, then hand crafted version
could be faster.


No because the current definition are recursive and ghc cannot inline
recursive functions.

map :: (a - b) - [a] - [b]
map _ [] = []
map f (x:xs) = f x : map f xs

It has to be manually transformed into a version that is not recursive
at the top level:

map :: (a - b) - [a] - [b]
map f = go
 where
   go [] = []
   go (x:xs) = f x : go xs

Then the map can be inlined at the call site and the 'f' inlined into
the body of 'go'.


Maybe HLint can make such suggestions ...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: HLint 1.2

2009-01-12 Thread Henning Thielemann


On Mon, 12 Jan 2009, Neil Mitchell wrote:


Hi


No because the current definition are recursive and ghc cannot inline
recursive functions.



map :: (a - b) - [a] - [b]
map f = go
 where
  go [] = []
  go (x:xs) = f x : go xs

Then the map can be inlined at the call site and the 'f' inlined into
the body of 'go'.


Maybe HLint can make such suggestions ...


HLint would probably just suggest you use a supercompiler*, for which
specialisation such as this is easy
(http://www.cs.york.ac.uk/~ndm/supero). HLint is about making code
prettier,


Actually, I find the 'go' variant prettier, because it clearly shows that 
the 'f' is not altered in the recursion.

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


Re: [Haskell-cafe] ANN: HLint 1.2

2009-01-12 Thread Henning Thielemann


On Mon, 12 Jan 2009, Robin Green wrote:


I tend to use Control.Monad.Fix.fix (which actually has nothing to do
with monads, despite the package name)


That's why it is also available from Data.Function now:
   http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Function.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] HaskellWiki Upgrade Aborted

2009-01-12 Thread Henning Thielemann


On Sun, 11 Jan 2009, Duncan Coutts wrote:


We really need to upgrade the whole thing. Not an easy job given the
range of stuff being run on there by lots of different people.


Btw. is there a simple way to download all the Wiki content?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] unfoldr [ANN: HLint 1.2]

2009-01-12 Thread Henning Thielemann


On Mon, 12 Jan 2009, Andrew Coppin wrote:


Off the top of my head, try this:

convert b 0 = []
convert b n = n `mod` b : convert b (n `div` b)

(Takes a number and yields the radix-B representation of it. Backwards.)

convert b = unfoldr (\n - if n  0 then Just (n `mod` b, n `div` b) else 
Nothing)


I have the nice function 'toMaybe' which simplifies this to:
  unfoldr (\n - toMaybe (n0) (n `mod` b, n `div` b))

Maybe HLint can also suggest non-base functions? ;-)

http://hackage.haskell.org/packages/archive/utility-ht/0.0.2/doc/html/Data-Maybe-HT.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Monads aren't evil? I think they are.

2009-01-12 Thread Henning Thielemann
Apfelmus, Heinrich schrieb:
 Ertugrul Soeylemez wrote:
 Let me tell you that usually 90% of my code is
 monadic and there is really nothing wrong with that.  I use especially
 State monads and StateT transformers very often, because they are
 convenient and are just a clean combinator frontend to what you would do
 manually without them:  passing state.
 
 The insistence on avoiding monads by experienced Haskellers, in
 particular on avoiding the IO monad, is motivated by the quest for elegance.
 
 The IO and other monads make it easy to fall back to imperative
 programming patterns to get the job done. But do you really need to
 pass state around? Or is there a more elegant solution, an abstraction
 that makes everything fall into place automatically? Passing state is a
 valid implementation tool, but it's not a design principle.

I collected some hints, on how to avoid at least the IO monad:
  http://www.haskell.org/haskellwiki/Avoiding_IO

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


Re: [Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-12 Thread Henning Thielemann
Ertugrul Soeylemez schrieb:
 Apfelmus, Heinrich apfel...@quantentunnel.de wrote:
 
 The insistence on avoiding monads by experienced Haskellers, in
 particular on avoiding the IO monad, is motivated by the quest for
 elegance.

 The IO and other monads make it easy to fall back to imperative
 programming patterns to get the job done.  [...]
 
 Often, the monadic solution _is_ the elegant solution.  Please don't
 confuse monads with impure operations.  I use the monadic properties of
 lists, often together with monad transformers, to find elegant
 solutions.  As long as you're not abusing monads to program
 imperatively, I think, they are an excellent and elegant structure.

I have seen several libraries where all functions of a monad have the
monadic result (), e.g. Binary.Put and other writing functions. This is
a clear indicator, that the Monad instance is artificial and was only
chosen because of the 'do' notation.

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


Re: [Haskell-cafe] ANN: HLint 1.2

2009-01-11 Thread Henning Thielemann


On Sun, 11 Jan 2009, Neil Mitchell wrote:


HLint will automatically detect if you should have used a map, a foldr
or a foldl and suggest how to change your code. In the GHC, darcs and
Hoogle code bases there are no obvious map-like functions, which is a
good sign :-)


I found so many 'map' re-implementations in Haskell libraries, even in 
those, where I thought their programmers must be more experienced than me. 
Hm, maybe even in libraries by Neil?

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


Re: [Haskell-cafe] ANN: Haskell BLAS bindings version 0.7

2009-01-10 Thread Henning Thielemann
Patrick Perry schrieb:
 The reason I want to expose modules but hide the documentation is
 because there are a lot of unsafeX functions I want to provide access
 to, but which 99% of users don't care about.  The array library does the
 same thing.

Alternatively, the DEPRECATED pragma may prevent programmers from using
these functions too extensively. However, this may be considered abuse
of this pragma. I think the Unsafe module is the cleanest solution.

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


[Haskell-cafe] Syntactic Sugar (Was: Monads aren't evil)

2009-01-10 Thread Henning Thielemann
Peter Verswyvelen schrieb:
 Related to this issue, I have a question here.
 
 I might  be wrong, but it seems to me that some Haskellers don't like
 writing monads (with do notation) or arrows (with proc sugar) because of
 the fact they have to abandon the typical applicative syntax, which is
 so close to the beautiful lambda calculus core. Or is it maybe because
 some people choose monads were the less linear applicative style could
 be used instead, so the choice of monads is not always appropriate.
 
 Haskell is full of little hardcoded syntax extensions: list notation
 syntactic, list comprehensions, and even operator precedence that
 reduces the need for parentheses, etc...

http://www.haskell.org/haskellwiki/Syntactic_sugar/Cons

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


[Haskell-cafe] Infix expressions (Was: Monads aren't evil)

2009-01-10 Thread Henning Thielemann
Peter Verswyvelen schrieb:

 Now, for binary operators, Thomas Davie made a nice pair of combinators
 on Hackage (InfixApplicative) that would allow this to become:
 
 h3 x = f x ^(+)^ g x

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

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


[Haskell-cafe] advanced class constraints in Haskell 98?

2009-01-08 Thread Henning Thielemann


GHC accepts a class declaration like
  class Monad (m Maybe) = C m where
 ...
 without having any language extension switched on. But it isn't Haskell 
98, is it? Hugs 2005 also accepts this.

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


Re: [Haskell-cafe] advanced class constraints in Haskell 98?

2009-01-08 Thread Henning Thielemann


On Fri, 9 Jan 2009, Miguel Mitrofanov wrote:


On 8 Jan 2009, at 23:59, Henning Thielemann wrote:



GHC accepts a class declaration like
class Monad (m Maybe) = C m where
   ...
without having any language extension switched on. But it isn't Haskell 98, 
is it?


It is.

From Report:



A class assertion has form qtycls tyvar, and indicates the membership of the 
type tyvar in the class qtycls. A class identifier begins with an uppercase 
letter. A context consists of zero or more class assertions, and has the 
general form


( C1 u1, ..., Cn un )

where C1, ..., Cn are class identifiers, and each of the u1, ..., un is 
either a type variable, or the application of type variable to one or more 
types.


A nice. I jumped into 4.3 and found

§ §  R  32  ©
¦   6  
©  ¦ 32   ¢ R ¨ © ¥


7

  ¤ ¢¨ 7

5© ¥   ¦
class 
=where

   ¢

§   § §  §
   ¥   ¦ ¡ 2 §
6 
© R©

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


Re: [Haskell-cafe] advanced class constraints in Haskell 98?

2009-01-08 Thread Henning Thielemann


On Thu, 8 Jan 2009, Henning Thielemann wrote:


On Fri, 9 Jan 2009, Miguel Mitrofanov wrote:


On 8 Jan 2009, at 23:59, Henning Thielemann wrote:



GHC accepts a class declaration like
class Monad (m Maybe) = C m where
   ...
without having any language extension switched on. But it isn't Haskell 
98, is it?


It is.

From Report:



A class assertion has form qtycls tyvar, and indicates the membership of 
the type tyvar in the class qtycls. A class identifier begins with an 
uppercase letter. A context consists of zero or more class assertions, and 
has the general form


( C1 u1, ..., Cn un )

where C1, ..., Cn are class identifiers, and each of the u1, ..., un is 
either a type variable, or the application of type variable to one or more 
types.


A nice. I jumped into 4.3 and found

§ §  R  32  ©


... copying from Haskell 98 report did not only insert rubbish, but also 
triggered sending the e-mail. I hope it did not more damage ...



scontext - simpleclass
 | (simpleclass_1, ..., simpleclass_n)

simpleclass - qtycls tyvar

So it must be 'atype' instead of 'tyvar'? Haskell 98 is really mighty.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Hypothetical Haskell job in New York

2009-01-08 Thread Henning Thielemann


On Thu, 8 Jan 2009, Manlio Perillo wrote:


Personally, I only know http://hpaste.org/, based on
Server: HAppS/0.8.4


I'm using a modified HWS for the parallel webs, e.g. the Real Monad 
Transformer:

  
http://www.haskell.org.monadtransformer.parallelnetz.de/haskellwiki/Category:Monad
However, recently a lot of accesses made the server quite unusable.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell not ready for Foo [was: Re: Hypothetical Haskell job in New York]

2009-01-08 Thread Henning Thielemann


On Thu, 8 Jan 2009, Bardur Arantsson wrote:


Thanks. For some reason I hadn't thought to use

  (fromIntegral x)::PortNumber

I guess I got stuck on the idea of constructing a PortNum directly and didn't 
think beyond that. (Maybe PortNum should really be an abstract type to force 
indirect construction...?)


I also think that a Num instance for PortNumber is not a good idea. How 
shall (+) and (*) be defined?

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


Re: [Haskell-cafe] Staged evaluation, names?

2009-01-08 Thread Henning Thielemann
wren ng thornton schrieb:

 Every now and then I find myself in the position where I'd like to
 define some hairy value as a CAF instead of a literal, but I'd like for
 it to be fully evaluated at compile-time rather than postponed until
 runtime. It'd be possible to bludgeon the CPP into doing this, but it
 seems easier to use an autocannon like Template Haskell to swat this fly.

Is it really necessary to use CPP or TemplateHaskell for this kind of
optimization? Can a pragma help? Maybe {-# INLINE #-} ?

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


Re: [Haskell-cafe] advanced class constraints in Haskell 98?

2009-01-08 Thread Henning Thielemann


On Fri, 9 Jan 2009, Miguel Mitrofanov wrote:


On 9 Jan 2009, at 02:47, Ross Paterson wrote:


On Thu, Jan 08, 2009 at 10:27:59PM +0100, Henning Thielemann wrote:

A nice. I jumped into 4.3 and found

scontext - simpleclass
   | (simpleclass_1, ..., simpleclass_n)

simpleclass - qtycls tyvar

So it must be 'atype' instead of 'tyvar'? Haskell 98 is really mighty.


Oh.  Don't I look silly?  You were absolutely right, it's not Haskell 98.


Me too. I've looked at the type declaration syntax instead of instance 
declaration one.


Maybe the report is not complete? I mean, the current behaviour of Hugs 
and GHC (as I observed it) is more consistent, and maybe that's what the 
designers had in mind.



Actually Hugs does reject it without flags.  Maybe you have a -98 stored
somewhere?


When starting, my Hugs tells

Haskell 98 mode: Restart with command line option -98 to enable extensions
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Taking Exception to Exceptions

2009-01-08 Thread Henning Thielemann
Immanuel Litzroth schrieb:

 Anyway, there is one more problem I have related to exceptions that is
 about forcing strictness. It relates to option parsing. I have an option -t
 that says which track from a file of tracks to print. So I go
 
 data Flags = TrackNumber !Int deriving(Read, Show, Eq)
 
 makeTrackNumber :: String - Flags
 makeTrackNumber str =
 TrackNumber $ read str
 
 options = [GetOpt.Option ['t'] [tracknumber] (GetOpt.ReqArg
 makeTrackNumber tracknumber) number of track to show]
 
 Now my main goes
 main = do
   args - getArgs
   opts - evaluate $ GetOpt.getOpt GetOpt.RequireOrder options args
   print done getting the opts
   case opts of ...
 
 which of course first prints done getting opts and then throws an
 exception if I give it a flag
 -t abc.

'evaluate' is strange here. Is it ok to put the print after the case ?
But I have probably still not understood the problem.

Let me point to two other issues:
  An elegant way to use GetOpt is:

http://www.haskell.org/haskellwiki/High-level_option_handling_with_GetOpt

  I find it bad style to hide the exceptions, that can be raised. The
type of an action should reflect what exceptions are to be expected. You
can achieve this with Control.Monad.Exception.Synchronous from

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/explicit-exception
   or Control.Monad.Error from
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/transformers

For an application, using these techniques, see:
   http://hackage.haskell.org/cgi-bin/hackage-scripts/package/equal-files
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] advanced class constraints in Haskell 98?

2009-01-08 Thread Henning Thielemann


On Fri, 9 Jan 2009, Ross Paterson wrote:


On Fri, Jan 09, 2009 at 01:11:12AM +0100, Henning Thielemann wrote:

Maybe the report is not complete? I mean, the current behaviour of Hugs
and GHC (as I observed it) is more consistent, and maybe that's what the
designers had in mind.


I'm puzzled by the Hugs behaviour.  The current version rejects it, and
I downloaded and built the Mar2005 version just to check, and it also
rejected it, saying

Illegal Haskell 98 class constraint in class declaration


You are right. I don't know, what I made different before. Btw. 2005 was 
the copyright year, Hugs' version is September 2006:


__   __ __  __     ___  _
||   || ||  || ||  || ||__  Hugs 98: Based on the Haskell 98 standard
||___|| ||__|| ||__||  __|| Copyright (c) 1994-2005
||---|| ___||   World Wide Web: http://haskell.org/hugs
||   || Bugs: http://hackage.haskell.org/trac/hugs
||   || Version: September 2006 _

Haskell 98 mode: Restart with command line option -98 to enable extensions

ERROR src/Data/Spreadsheet/CharSource.hs:14 - Illegal Haskell 98 class 
constraint in class declaration

*** Constraint : Monad (a Maybe)
*** Context: (Monad (a Maybe), Monad (a Identity))


So, since GHC allows this extension without an option - how can I tell 
Cabal, which extension I'm using? Has it a name anyway?

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


Re: [Haskell-cafe] Maintaining laziness

2009-01-07 Thread Henning Thielemann


On Wed, 7 Jan 2009, Jan Christiansen wrote:

The non least strict definition of (*) is taken from the module 
Data.Number.Natural which was published by Lennart Augustsson in the numbers 
package at hackage. I mention this here because I think it clearly shows that 
it is even hard for experienced Haskell programmers to define least strict 
functions.


very interesting ...

It's the third time within about 2 months were I was pointed to a lack of 
laziness in my own Peano implementation!

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


Re: [Haskell-cafe] Maintaining laziness

2009-01-07 Thread Henning Thielemann


On Wed, 7 Jan 2009, Jan Christiansen wrote:

This is great. I am working on the very same topic for quite a while now. My 
aim is to develop a tool that tells you whether a function is least strict. 
My work is based on an idea by Olaf Chitil:


http://www.cs.kent.ac.uk/people/staff/oc/


Although it seems to be overkill for a single module - How about a 
cabalized version on Hackage and a darcs repository? It would simplify 
using and updating it.

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


Re: [Haskell-cafe] Maintaining laziness

2009-01-07 Thread Henning Thielemann


On Wed, 7 Jan 2009, Henning Thielemann wrote:



On Wed, 7 Jan 2009, Jan Christiansen wrote:

This is great. I am working on the very same topic for quite a while now. 
My aim is to develop a tool that tells you whether a function is least 
strict. My work is based on an idea by Olaf Chitil:


http://www.cs.kent.ac.uk/people/staff/oc/


Although it seems to be overkill for a single module - How about a cabalized 
version on Hackage and a darcs repository? It would simplify using and 
updating it.


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


Re: [Haskell-cafe] Template Haskell question

2009-01-06 Thread Henning Thielemann
Jeff Heard schrieb:
 Alright...  I *think* I'm nearly there, but I can't figure out how to
 derive a class instance using record accessors and updaters...

Has this something to do with

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor-template
?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Portability of MonadError

2009-01-05 Thread Henning Thielemann


On Mon, 5 Jan 2009, Luke Palmer wrote:


Oh bother!  My new year's resolution: think before I speak.

While I do think this is the right answer, it is not the right answer in the 
status quo.  This is
because ErrorT e m is only a monad when e is an Error, which Either (and most 
types) are not.  It
will be the right answer when fail is factored out of Monad into MonadFail 
(which will happen
someday hopefully), because then the typechecker will verify that the above 
composition cannot
fail.

But now I can't think of a good answer.  Darn.


In the explicit-exception package I omit 'fail' and allow an exception 
type without constraints.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] unsafeInterleaveIO respecting order of actions

2009-01-04 Thread Henning Thielemann


On Sat, 3 Jan 2009, Henning Thielemann wrote:


I think I now have general Applicative functionality ...


I hope the following is a proper Monad implementation. In contrast to 
Applicative a Writer for sequencing actions does no longer work, instead I 
need a State monad.



newtype LazyIO a = LazyIO {runLazyIO :: StateT RunAll IO a}

data RunAll = RunAll
   deriving Show

instance Monad LazyIO where
   return x = LazyIO $ return x
   x = f = LazyIO $
  mapStateT unsafeInterleaveIO . runLazyIO . f =
  mapStateT unsafeInterleaveIO (runLazyIO x)

instance MonadIO LazyIO where
   liftIO m = LazyIO $ StateT $ \RunAll - fmap (\x-(x,RunAll)) m

evalLazyIO :: LazyIO a - IO a
evalLazyIO =
   flip evalStateT RunAll . runLazyIO


I'll write some tests and upload it to Hackage.

Thank you for being a patient audience. ;-)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] unsafeInterleaveIO respecting order of actions

2009-01-03 Thread Henning Thielemann


On Thu, 1 Jan 2009, Brandon S. Allbery KF8NH wrote:


On 2009 Jan 1, at 16:44, Henning Thielemann wrote:

If it is generally possible to use unsafeInterleaveIO such that it
executes actions in the right order, wouldn't this allow the definition
of a general lazy IO monad?


I thought unsafeInterleaveIO and users of it (readFile, hGetContents) didn't 
guarantee the order of actions relative to independent IO actions (that is, 
those performed outside the unsafeInterleaveIO) and this was why it is 
generally disrecommended.  For example the recurring situation where people 
try to readFile f = writeFile . someTransform and the writeFile fails with 
a file locked exception.


Sure, it's dangerous. But for what I want to do, this situation cannot 
occur. I can come up with a simple example which might be generalized. It 
simulates what hGetContents does.


liftLazy2 :: (a - b - c) - IO a - IO b - IO c
liftLazy2 f x y =
   fmap (\ ~(xr, ~(yr,())) - f xr yr) $
   unsafeInterleaveIO $ liftM2 (,) x $
   unsafeInterleaveIO $ liftM2 (,) y $
   return ()

test0, test1 :: IO String
test0 = liftLazy2 (const)  getLine getLine
test1 = liftLazy2 (flip const) getLine getLine


test0 only requests the first line,
test1 expects two lines as user input.

However, with liftLazy2 we have only Applicative functionality, not Monad, 
and it is not composable.


For example:
  fmap (\((x,y),z) - z) $ liftLazy2A (,) (liftLazy2A (,) getLine getLine) 
getLine

This requests only one line, but should three ones. The reason is that the 
first two getLines are defered even until the last one. Thus, it is not 
enough that liftLazy2 returns (IO c). Instead it must return (IO 
(c,(a,(b,() and these pair emulated lists must somehow be combined in 
order to preserve the order of execution. This looks somehow like a writer 
monad transformer.

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


Re: [Haskell-cafe] databases in Haskell type-safety

2009-01-03 Thread Henning Thielemann
Gour schrieb:
 Hi!
 
 I'd like to use sqlite3 as application storage in my haskell project...
 
 Browsing the available database options in Haskell it seems that:
 
 a) HSQL is dead (hackage reports build-failure with 6.8  6.10)

No, it is maintained by frede...@ofb.net . I have also contributed
Oracle/OCI code a half year ago.

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


Re: [Haskell-cafe] unsafeInterleaveIO respecting order of actions

2009-01-03 Thread Henning Thielemann


On Sat, 3 Jan 2009, Henning Thielemann wrote:


On Thu, 1 Jan 2009, Brandon S. Allbery KF8NH wrote:


On 2009 Jan 1, at 16:44, Henning Thielemann wrote:

If it is generally possible to use unsafeInterleaveIO such that it
executes actions in the right order, wouldn't this allow the definition
of a general lazy IO monad?


I thought unsafeInterleaveIO and users of it (readFile, hGetContents) 
didn't guarantee the order of actions relative to independent IO actions 
(that is, those performed outside the unsafeInterleaveIO) and this was why 
it is generally disrecommended.  For example the recurring situation where 
people try to readFile f = writeFile . someTransform and the writeFile 
fails with a file locked exception.


Sure, it's dangerous. But for what I want to do, this situation cannot occur. 
I can come up with a simple example which might be generalized. It simulates 
what hGetContents does.


liftLazy2 :: (a - b - c) - IO a - IO b - IO c
liftLazy2 f x y =
  fmap (\ ~(xr, ~(yr,())) - f xr yr) $
  unsafeInterleaveIO $ liftM2 (,) x $
  unsafeInterleaveIO $ liftM2 (,) y $
  return ()


I think I now have general Applicative functionality:


apply :: (a - b, ()) - (a,()) - (b,())
apply (f,fs) a =
   let (a0,as) = case fs of () - a
   in  (f a0, as)

lazyIO :: IO a - IO (a,())
lazyIO = unsafeInterleaveIO . fmap (\x - (x,()))


liftLazy2 :: (a - b - c) - IO a - IO b - IO c
liftLazy2 f x y =
   liftM2
  (\xr yr - fst $ (f,()) `apply` xr `apply` yr)
  (lazyIO x) (lazyIO y)


The () is used to enforce the order of evaluation.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Use of abbreviations in Haskell

2009-01-02 Thread Henning Thielemann
Miguel Mitrofanov schrieb:

 module Element where
 import QName
 import ...
 data Element = Element {name :: QName, attribs :: [Attr], content ::
 [Content], line :: Maybe Line}
 
 module Attr where
 import QName
 import ...
 data Attr = Attr {key :: QName, val :: String}
 
 module QName where
 import ...
 data QName = QName {name :: String, uri :: Maybe String, prefix :: Maybe
 String}
 
 module Main where
 import qualified QName as Q
 import qualified Element as E
 ... Q.name ... E.name ...

+1 for this style

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


Re: [Haskell-cafe] How do we decide on the new logo?

2009-01-02 Thread Henning Thielemann
Fritz Ruehr schrieb:

 Without starting a war on the theory of voting systems, perhaps we
 should use a system which allows for
 a certain amount of secondary (etc.) preference to be expressed?

Give everyone 10 points and let every voter assign these points to his
favorite logos, where it is possible to give more than one of his points
to the same logo. (Or give every user one point and let him choose how
to divide this into fractions which can be assigned to logos. Or give
every voter any number of points he want and scale them to 1 afterwards.)

Another question is how to handle logos with variations. I think all
logos of one idea should be grouped and considered one object and the
favorite variant can be voted on later.

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


Re: [Haskell-cafe] Re: How do we decide on the new logo?

2009-01-02 Thread Henning Thielemann
Achim Schneider schrieb:

 Step 2: Determine the winner by polling preferences, same-level
 preference (ambivalence) allowed
 (eg. place 1 for logos C and D, place 2 for A and place 3 for B)

We recently had to vote for the new design of our university's website.
This was done by asking every voter for an order of preference, with no
equal preferences allowed. However, when the maintainer of the voting
system was asked, how these answers are processed, he didn't know an
answer. I think he finally converted positions to scores and added them.
However, I suspect in chosing the scores for each position, he had an
essential influence of the outcome of the election.

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


[Haskell-cafe] unsafeInterleaveIO respecting order of actions

2009-01-01 Thread Henning Thielemann
I think I have a very similar problem to the currently discussed
WriterT [w] IO is not lazy in reading [w].

I want to defer IO actions, until they are needed, but they shall be
executed in order. If I call unsafeInterleaveIO, they can be executed in
any order. I understand that hGetContents does not defer the hGetChar
operations but instead defers the call of the (:) constructors, thus
preserving the order of the hGetChar calls. In the general case this is
not so simple, since the result of a monadic block might not be a list
and the result of particular actions might not be needed at all, e.g. ().
If it is generally possible to use unsafeInterleaveIO such that it
executes actions in the right order, wouldn't this allow the definition
of a general lazy IO monad?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [ANN] Haskell web server + wiki: salvia-0.0.4 + orchid-0.0.6

2009-01-01 Thread Henning Thielemann
Judah Jacobson schrieb:
 On Thu, Jan 1, 2009 at 10:39 AM, Sebastiaan Visser sfvis...@cs.uu.nl wrote:
 On Jan 1, 2009, at 7:15 PM, Gwern Branwen wrote:
 On Thu, Jan 1, 2009 at 9:04 AM, Sebastiaan Visser  wrote:
 Happy new year, you all!

 I'm pleased to announce three new packages on Hackage:
 ...
 Miscellaneous comments:
 1) You're right about cabal-install versus runhaskell etc. There seems
 to be a(nother) Control.Exception issue with cabal-install using
 base-4:
 src/Network/Orchid/Backend/DarcsBackend.hs:91:29:
   Couldn't match expected type `IOException'
  against inferred type `Exception'
 Expected type: IO (Either IOException String)
 Inferred type: IO (Either Exception String)
   In the second argument of `()', namely
   `(try (U.readFile (repo /+ file)) ::
   IO (Either IOException String))'
   In the expression:
 eitherToMaybe

 (try (U.readFile (repo /+ file)) :: IO (Either IOException String))
 I tried to enable building against both the old and the new Exception
 libraries by using some preprocessor statements. It seems this attempt
 failed.
 
 You may  find the extensible-exceptions package from Hackage to be
 useful.  It provides the new Exeptions API on all versions of ghc
 since 6.6 (and possibly earlier), so you don't have to deal with any
 preprocessing or cabal-install issues.

Alternatively use the explicit-exception package, which works like IO
(Either ...), but is more clean.

Btw. although I have not looked into Pandoc, in general I find it more
attracting to re-use existing software. If you think, that your document
system is better than Pandoc, it would also be nice to have it as a
separate package.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [ANN] Haskell web server + wiki: salvia-0.0.4 + orchid-0.0.6

2009-01-01 Thread Henning Thielemann
Sebastiaan Visser schrieb:
 Happy new year, you all!
 
 I'm pleased to announce three new packages on Hackage:
 
   * salvia-0.0.4: A lightweight modular web server framework.

Is it based on Simon Marlow's HWS, like mohws on Hackage? Does it
support HTTPS?

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


Re: [Haskell-cafe] Re: unsafeInterleaveIO respecting order of actions

2009-01-01 Thread Henning Thielemann


On Fri, 2 Jan 2009, Achim Schneider wrote:


Henning Thielemann schlepp...@henning-thielemann.de wrote:


If it is generally possible to use unsafeInterleaveIO such that it
executes actions in the right order, wouldn't this allow the
definition of a general lazy IO monad?


The question is what right order means.

Let B1..Bn be some arbitrary IO-Actions.
Let A1..An be some arbitrary IO Actions passed to unsafeInterleaveIO

You're guaranteed that
a) Bk+1 is executed after Bk
b) Ak+1 is executed after Ak

, all by virtue of the IO Monad.


If all Ak's are defered using individual unsafeInterleaveIO's then it is 
not guaranteed that A[k+1] is executed after A[k]. That's my problem.


Check:
Prelude fmap snd $ Monad.liftM2 (,) (unsafeInterleaveIO getLine) 
(unsafeInterleaveIO getLine)

If unsafely interleaved actions would be executed in order, then this 
would first ask you for the first pair member, then for the second one, 
then echo the second one. Actually it asks only for the second one and 
prints it.

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


Re: [Haskell-cafe] Don't make 'show*' functions

2008-12-30 Thread Henning Thielemann
wren ng thornton schrieb:
 Thomas DuBuisson wrote:
 Jeff Heard proclaimed:
  There are multiple distinct reasons people use Show, and this gets
  confusing.

 This is exactly what I was getting at.  I see four uses being discussed:
 
 Indeed, though I think the situation is even worse. It seems to me that
 there are a number of cross-purposes for the Read+Show classes. The two
 main questions at stake are:
 
 
 A) Who/what is the audience?
 
 Common answers:
 1) The human user on the other side of the terminal

no

 2) The human developer trying to debug their work

yes

 3) The compiler, a la cutpaste

yes

 4) A program on the other end of the wire/disk/flux capacitor

no


 B) What is the resolution/detail?
 
 Common answers:
 1) All the gory details

maybe

 2) Enough for a human to get the big picture

no

 3) Enough for a computer to get the right value

yes


 For complex
 datastructures like Map, IntMap, and Trie there are many details stored
 in the structure which end users need not or should not know about; but
 these details are essential to the developers to ensure their code is
 doing what they think it should be.

Hm, yes, there seems to be demand for debug-levels, even different ones
for different libraries


 Proposal 1: Combine Read and Show into a single class, enforcing @a ==
 (read . show) a@ with the intention of capturing A3/B1 or A3/B3. While
 this may be serviceable for A1 or A2 uses, the intention of the class
 should be made clear that it is for A3. Presumably some solution should
 be found for types which can be read or shown but not both.

functions - If you have only one field in a record, which is of function
type, you may use a dummy 'show' for it, but you cannot define a 'read'.

 Proposal 2: Clean up Text.PrettyPrint.HughesPJ and market it heavily for
 covering code-oriented aspects of A1. Other visualizations like charts,
 graphs, or trees should be relegated elsewhere.

... TeX, HTML, ...

 Proposal 3: Add a generic Lisp pretty printer function to convert from
 the output of Proposal 1 towards output like Proposal 2. Dealing with
 operators makes it trickier than Lisp, but most datastructures lack
 operators. I'm sure this has already been written in Haskell by Yi
 enthusiasts, and it should reduce the cost of getting people into using
 Pretty.
 
 
 Proposal 4: Write a generic function for taking recursive types and
 printing them as a tree. Users should only need to serialize the here
 content of each node, leaving it up to the generic function to add
 spines and adequate spacing between nodes. This is for targeting A2/B2.
 While it's a time-honored tradition to implement specialized versions of
 this function to introduce people to recursion, making a standard
 version for visualizing large datastructures would alleviate some of the
 burden of what Show should be doing.
 
 
 Proposal 5: Currently a main consumer of Show is the GHCi or Hugs REPL.
 However, those are used both by end users and by developers, which leads
 to the elision between A1 and A2.

I think, that a user who uses GHCi becomes a developer. For me a user is
someone who calls compiled Haskell programs.

 Provided the previous four proposals
 are taken to heart, it would be nice if GHCi and Hugs had commands to
 select which viewing mode (show, prettyShow, lispShow, treeShow) should
 be used for each type. By default, when available prettyShow should be
 favored over lispShow which is favored over show; but this behavior
 could be changed on a type-by-type basis. There are complications here
 regarding how to recurse for each element of a type, but they seem soluble.

Yes it would be nice, if the showing in GHCi could be changed. Such that
e.g. matrices are shown as grids. However, this can be currently done by
passing the expression to a function which does the required formatting.
I remember GSLMatrix had a function like
  (//) :: Matrix - Precision - IO ()
which let you write
GSLMatrix matrix // 2
/1.00 0.00\
\0.00 1.00/

I would not be surprised, if GHCi can already be configured to attach
the (//2) automatically.


I always think we need a type class which allows to give type specific
options. However, the option type would functionally dependency on the
type of the shown value, and thus the type class must be a
multiparameter typeclass with functional dependencies. This way you can
specify formatting options of the matrix (kind of parentheses) and its
elements (precision, exponential style etc.).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Function composition

2008-12-30 Thread Henning Thielemann


On Mon, 29 Dec 2008, Martijn van Steenbergen wrote:


Conal Elliott wrote:
If you think of f (here f=not) as an semantic editor (transformer) of 
values, then 'result', 'first', and 'second' are semantic editor 
combinators, which can be composed together arbitrarily.  See 
http://conal.net/blog/semantic-editor-combinators .


I recently found out Henning and Luke's Data.Accessor[1], and your editor 
combinators and their accessors seem very much related. Was one inspired by 
the other?


Martijn.


Well spotted - thank you for pointing out this connection! Interestingly 
since Conal's approach is motivated differently, he also included 
functions. Those are missing in data-accessor, although Accessor.Container 
is close to it. The main difference is, that Conal restricts to 'modify' 
functions, and does not support 'get' like Accessors do. You can 'set' and 
'modify' all function values (or all container elements) simultaneously, 
but you can only 'get' one at a time. Thus an Accessor could only access a 
single function value, but not all of them simultaneously.

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


Re: [Haskell-cafe] Re: instance Enum [Char] where ...

2008-12-30 Thread Henning Thielemann
Justin Goguen schrieb:

 My purpose is to have operations such as [aa..bc] be possible, with its
 result being [aa, ab, ac ..snip.. ba, bb, bc]

... what do you want to get, if the lengths of the start and the end
string do not match?


Maybe what you are after is the Ix class:

Prelude Data.Ix.range (('a','a'), ('b','c'))
[('a','a'),('a','b'),('a','c'),('b','a'),('b','b'),('b','c')]
Prelude map (\(x,y) - x:y:[]) $ Data.Ix.range (('a','a'), ('b','c'))
[aa,ab,ac,ba,bb,bc]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Gitit - Encoding

2008-12-30 Thread Henning Thielemann


On Tue, 30 Dec 2008, Arnaud Bailly wrote:


Hello,
I have started using Gitit and I am very happy with it and eager to
start hacking. I am running into a practical problem: characters
encoding. When I edit pages using accented characters (I am french),
the accents get mangled when the page come back from server.

The raw files are incorrectly encoded. Where Shall I look for fixing
this issue ?


How about
  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/encoding ?

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


Re: [Haskell-cafe] Function composition

2008-12-29 Thread Henning Thielemann
Luke Palmer schrieb:
 2008/12/26 Oscar Picasso oscarpica...@gmail.com
 mailto:oscarpica...@gmail.com
 
 Hi,
 
 I can write:
 *Main let yes = not . not
 *Main :t yes
 yes :: Bool - Bool
 
 But not:
 *Main let isNotEqual = not . (==)
 
 
 The definition of (.):
 
 f . g = \x - f (g x)

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


[Haskell-cafe] Maintaining laziness

2008-12-29 Thread Henning Thielemann


In case someone cares - after some battles with functions that are less 
lazy than expected, I have written a tutorial on how to get functions lazy 
and how to test, whether they are actually lazy:

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

I found it especially enlightening, that one can avoid a 'force' function 
in a lazy parser by making the possibility of a parser failure explicit in 
its type. I.e. a parser that cannot fail, need no 'force'. (I learnt that 
in polyparse the 'force' function is hidden in 'apply':

  
http://hackage.haskell.org/packages/archive/polyparse/1.1/doc/html/Text-ParserCombinators-PolyLazy.html#v%3Aapply
  )
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Maintaining laziness

2008-12-29 Thread Henning Thielemann
Jake McArthur schrieb:
 Henning Thielemann wrote:
 I found it especially enlightening, that one can avoid a 'force'
 function in a lazy parser by making the possibility of a parser
 failure explicit in its type. I.e. a parser that cannot fail, need no
 'force'. (I learnt that in polyparse the 'force' function is hidden in
 'apply':
 
 
 I'm curious, what is the difference between using a force function and
 using lazy pattern matching?

Erm, nothing? Because 'force' is implemented by lazy pattern matching.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Maintaining laziness

2008-12-29 Thread Henning Thielemann
Miguel Mitrofanov schrieb:
 Seems useful.
 
 BTW, why on earth should inits undefined be undefined instead of
 []:undefined? I mean, come on, we all know that inits anything
 starts with []!

I don't know the reason, but I have added this example to that article.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Infinite grid

2008-12-29 Thread Henning Thielemann
Martijn van Steenbergen schrieb:
 Hello,
 
 I would like to construct an infinite two-dimensional grid of nodes,
 where a node looks like this:
 
 data Node = Node
   { north :: Node
   , east  :: Node
   , south :: Node
   , west  :: Node
   }
 
 in such a way that for every node n in the grid it doesn't matter how I
 travel to n, I always end up in the same memory location for that node.
 
 I suspect another way of saying that is that
 
 let f = f . north . east . south . west in f origin
 
 should run in constant space. I hope this makes the problem clear. :-)

A dungeon game? :-)

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


Re: [Haskell-cafe] Don't make 'show*' functions

2008-12-26 Thread Henning Thielemann


On Fri, 26 Dec 2008, Thomas DuBuisson wrote:


Hello cafe,
This is just a small thought, but its been bugging me.  We have these things 
called type classes
for a reason (I like to think).  When making a new data type 'Data', it is not 
productive to
avoid type classes such as 'Show' and export a 'showData' function.

Examples of what I'm talking about include showHtml, showTrie, 
showInstalledPackageInfo...

I know the default derivation (and thus generally accepted) instance of Show 
isn't pretty, but
that just means to me that we need either more methods within the Show type 
class or start using
the prettyclass package more.

If the problem is an API issue lets fix Pretty or Show.  But this show* stuff 
should disappear in
the long run.


I disagree:
  http://www.haskell.org/haskellwiki/Slim_instance_declaration
  http://www.haskell.org/pipermail/libraries/2006-September/005791.html

There is not much to fix in Show (except the showList issue) since it is 
for showing Haskell expressions. One could however blame developers of 
calling pretty printing functions 'show*'. :-)___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Don't make 'show*' functions

2008-12-26 Thread Henning Thielemann


On Fri, 26 Dec 2008, Jeff Heard wrote:


I don't think that making Show a type class was a mistake.  I think
that we have long since overloaded the meaning of Show and made it
ambiguous.  There are multiple distinct reasons people use Show, and
this gets confusing.  It would be good if we as a community tried to
nail down these different meanings that people tend to attach to Show
and fork out new type classes that each encompass those meanings.


+1

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


[Haskell-cafe] Hackage packages for indexing by Google

2008-12-25 Thread Henning Thielemann


When testing the ShowMeta parallel web:
   
http://hackage.haskell.org.showmeta.parallelnetz.de/packages/archive/pkg-list.html
  I found, that all HackageDB pages forbid crawling and indexing. 
Actually, the content of this page is dynamic - but it changes only 
incrementally. It would be very worth when I search for markov chain 
haskell with Google, that I will be directed to the according package 
page of HackageDB.

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


Re: [Haskell-cafe] understanding enumerator/iteratee

2008-12-23 Thread Henning Thielemann
Jason Dusek schrieb:
   I'm taking a stab at composable streams, starting with
   cursors. I managed to make a derived cursor today -- as I work
   through this stuff, I hope to understand Iteratee/Enumerator
   better.

How about a wiki page on the roles of enumerators and iteratees, best
explained using a simple example?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] understanding enumerator/iteratee

2008-12-23 Thread Henning Thielemann
Jason Dusek schrieb:
 Henning Thielemann schlepp...@henning-thielemann.de wrote:
 Jason Dusek schrieb:
 I'm taking a stab at composable streams, starting with
 cursors. I managed to make a derived cursor today -- as I
 work through this stuff, I hope to understand
 Iteratee/Enumerator better.
 How about a wiki page on the roles of enumerators and
 iteratees, best explained using a simple example?
 
   At present, I am not totally convinced of Iteratee/Enumerator.
   Why aren't there any functor instances anywhere? Why do
   filestreams and lists present distinct interfaces? A stream
   computation is a stream computation; the effect of pulling an
   item off the stream and handling it is sequenced in these
   computations so it seems like a monad transformer is in order.
   So I am just going to keep trying until I can make that
   transformer.

I have put essentially Oleg's explanation to the Wiki:
  http://haskell.org/haskellwiki/Enumerator_and_iteratee
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Comparing on multiple criteria

2008-12-23 Thread Henning Thielemann
David Menendez schrieb:
 On Sun, Dec 21, 2008 at 11:20 AM, Jan-Willem Maessen
 jmaes...@alum.mit.edu wrote:
 On Dec 21, 2008, at 8:52 AM, Martijn van Steenbergen wrote:

 Hello all,

 Data.Ord has a handy function called comparing, and its documentation
 shows an example of its use.

 But what if you want to sort a list of values based on multiple criteria?
 It turns out there is a neat way to do this:

 compareTuple = mconcat [comparing fst, comparing snd]

 The default Monoid instances for Ordering and functions work exactly as
 required here. (Thanks to vixey in #haskell for the hint to look at
 monoids!)
 
 This is a great example of why it's a bad idea to introduce new
 functionality with a Monoid instance. Even if you know the instance
 exists, mappend is so general that it's difficult or impossible to
 predict what it will do at a given type.
 
 There should be an explicit function for combining Ordering values
 lexicographically, with a note in the documentation saying that it's
 the basis of the Monoid instance.

+1

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


Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-23 Thread Henning Thielemann
Andrew Wagner schrieb:
 The problem here is even slightly deeper than you might realize. For
 example, what if you have a list of functions. How do you compare two
 functions to each other to see if they're equal? There is no good way
 really to do it! So, not only is == not completely polymorphic, but it
 CAN'T be.
 
 There is a nice solution for this, however, and it's very simple:
 
 contain :: Eq a - [a] - Bool
 contain x [] = False
 contain x (y:ys) = if x == y then True else contain x ys

Would HLint jump in here and suggest:
   contain x (y:ys) = x == y || contain x ys
 ? Or even replace 'contain' by 'elem' ?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] monad constraint + record update

2008-12-23 Thread Henning Thielemann
Brent Yorgey schrieb:
 On Mon, Dec 22, 2008 at 06:19:07PM +0100, Peter Padawitz wrote:
 I'd like to define a monad Set for types in the class Eq. But how can the 
 arguments of Set be constrained when Set is defined as an instance of 
 Monad? instance Eq a = Monad Set where ... obviously cannot work.

 Is there a standard update function for fields in data types, something 
 that OO programmers do with assignments like obj.attr := value ?

 Peter

 
 Note there is already a package on Hackage to do exactly this, rmonad.
 
 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rmonad

And also
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Fwd: [Haskell-cafe] Haskell as a religion

2008-12-18 Thread Henning Thielemann
Alberto G. Corona schrieb:
 But many features need other features. For example, the option to use
 referential transparency will be common in future languages for
 multicore programming purposes.  This creates the problem of separating
 side-effect-free code from side-effect code.

In C/C++ referential transparent functions code can be declared by
appending a 'const' to the prototype, right?

 I think that once the average programmer start to use one or two of
 these features, he will feel a bit frustrated if its language don´t have
 all the others, specially if he know haskell. Probably, he will use
 haskell for fun. This is the best way for the takeover of the industry,
 because this has been so historically.

Extrapolating the habit of programmers from the past to the future, I
predict that Haskell can only become a mainstream language once there is
a cleaner, simpler, safer and more powerful programming language than
Haskell.


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


Re: [Haskell-cafe] Time for a new logo? - Haskell logo as a stamp!

2008-12-16 Thread Henning Thielemann


On Mon, 15 Dec 2008, Henning Thielemann wrote:


On Mon, 15 Dec 2008, Don Stewart wrote:


And anyone who does a version, place put it on the wiki.
It'll be lost if you only post to the list.

I propose we gather submissions and vote on the best for a new logo in
2009.


Whatever logo someone prefers: I have written a program using HPDF which 
creates stamps for the German post (see http://www.internetmarke.de/) with 
custom images:

 http://code.haskell.org/~thielema/internetmarke/


Try it out now:
  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/internetmarke
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Time for a new logo?

2008-12-15 Thread Henning Thielemann


On Sun, 14 Dec 2008, Don Stewart wrote:


I noticed a new haskell logo idea on a tshirt today,

   
http://image.spreadshirt.net/image-server/image/configuration/13215127/producttypecolor/2/type/png

Simple, clean and *pure*.

Instead of the we got lots going on of the current logo.


Call me conservative, but I like the current logo more than the new 
suggestions. Why isn't it shown big on the welcome page of haskell.org?

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


Re: [Haskell-cafe] Time for a new logo? - Haskell logo as a stamp!

2008-12-15 Thread Henning Thielemann


On Mon, 15 Dec 2008, Don Stewart wrote:


And anyone who does a version, place put it on the wiki.
It'll be lost if you only post to the list.

I propose we gather submissions and vote on the best for a new logo in
2009.


Whatever logo someone prefers: I have written a program using HPDF which 
creates stamps for the German post (see http://www.internetmarke.de/) with 
custom images:

  http://code.haskell.org/~thielema/internetmarke/
 It needs a bit generalization, though, and will then be uploaded to 
Hackage, of course. So a dedicated Haskell stamp is close to German 
Haskell users!

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


[Haskell-cafe] efficient combination of foldl' and foldr - foldl'r

2008-12-05 Thread Henning Thielemann


I want to do a foldl' and a foldr in parallel on a list. I assumed it 
would be no good idea to run foldl' and foldr separately, because then the 
input list must be stored completely between the calls of foldl' and 
foldr. I wanted to be clever and implemented a routine which does foldl' 
and foldr in one go. But surprisingly, at least in GHCi, my clever routine 
is less efficient than the naive one.


Is foldl'rNaive better than I expect, or is foldl'r worse than I hope?


module FoldLR where

import Data.List (foldl', )
import Control.Arrow (first, second, (***), )

foldl'r, foldl'rNaive ::
   (b - a - b) - b - (c - d - d) - d - [(a,c)] - (b,d)

foldl'r f b0 g d0 =
   first ($b0) .
   foldr (\(a,c) ~(k,d) - (\b - k $! f b a, g c d)) (id,d0)

foldl'rNaive f b g d xs =
   (foldl' f b *** foldr g d) $ unzip xs

test, testNaive :: (Integer, Char)
test =
   second last $ foldl'r (+) 0 (:)  $ replicate 100 (1,'a')
{-
*FoldLR test
(100,'a')
(2.65 secs, 237509960 bytes)
-}


testNaive =
   second last $ foldl'rNaive (+) 0 (:)  $ replicate 100 (1,'a')
{-
*FoldLR testNaive
(100,'a')
(0.50 secs, 141034352 bytes)
-}

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


Re: [Haskell-cafe] How to define Show [MyType] ?

2008-12-05 Thread Henning Thielemann
Jules Bean schrieb:
 Dmitri O.Kondratiev wrote:
 I am trying to define instance Show[MyType] so
 show (x:xs :: MyType) would return a single string where substrings
 corresponding to list elements will be separated by \n.
 This would allow pretty printing of MyType list in several lines
 instead of one, as default Show does for lists.
 
 You're doing it wrong.
 
 Show is not for pretty-printing.

(+1)

 Show is for the production of haskell syntax for debugging and
 copy-pasting into test cases, as well as for use with 'Read'.
 
 If you want to pretty print, use a different function name.

Maybe related:
   http://www.haskell.org/haskellwiki/List_instance

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


Re: [Haskell-cafe] efficient combination of foldl' and foldr - foldl'r

2008-12-05 Thread Henning Thielemann


On Fri, 5 Dec 2008, Ryan Ingram wrote:


You're testing the interpreted code, so it's not surprising that the
naive version performs better; the interpretive overhead only applies
to your bit of glue code.


I wanted to avoid the optimizer to do clever things itself.


Alternatively, at least compile the module with optimizations before
running it in ghci:

ryani$ ghc -ddump-simpl -O2 -c foldlr.hs foldlr.core
(This gives you functional assembly language to look at for
examining code generation)

ryani$ ghci foldlr.hs
[...]
Prelude FoldLR :set +s
Prelude FoldLR test
(100,'a')
(0.39 secs, 70852332 bytes)
Prelude FoldLR testNaive
(100,'a')
(0.42 secs, 105383824 bytes)


There is still no clear advantage of foldl'r compared to foldl'rNaive, is 
it?

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


Re: [Haskell-cafe] Cabal

2008-12-01 Thread Henning Thielemann


On Sun, 30 Nov 2008, Duncan Coutts wrote:


On Sun, 2008-11-30 at 21:14 +0100, Henning Thielemann wrote:

On Sun, 30 Nov 2008, Don Stewart wrote:


lemming:


Maybe you like to add a pointer in cabal-install.cabal/Homepage field to
this page.


Good idea. Duncan?


After I finished that article, I also found:
   http://hackage.haskell.org/trac/hackage/wiki/CabalInstall


I'm trying to work out what the best thing is to do with the Cabal
documentation. Currently it's kind of patchy and spread over about three
sites. There's the http://haskell.org/cabal website, the dev wiki and
trac and the pages on the main Haskell.org wiki.


... and it's divided into cabal and cabal-install documentation. Though, 
this separation might also be sensible.



I think ideally we'd have all the user documentation on the cabal
website, including the docs for cabal-install. Unless people think
that's a silly idea and we should just put everything on the haskellwiki
system.


For me, access to HaskellWiki is the easiest, because I have no access to 
haskell.org/cabal I think. :-) In general people might like to add 
personal comments about cabal, which is best done in the wiki. E.g. if you 
solve a problem you can quickly add that solution to the FAQ. I don't mind 
having an official static site like haskell.org/cabal which points to a 
dynamic haskellwiki/Cabal and vice versa, but I think another page at 
haskell.org/trac is redundant.

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


Re: [Haskell-cafe] Combining licences

2008-12-01 Thread Henning Thielemann


On Mon, 1 Dec 2008, Emil Axelsson wrote:

Or perhaps it's better to put the cell library in its own package? I'm a bit 
reluctant to do this, because it means that Wired will be essentially useless 
on its own.


It's more the question, whether a Haskell wrapper to the cell library is 
useful on its own. I assume yes, and thus it sounds like a good idea to 
make separate package for a cell library wrapper.

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


Re: [Haskell-cafe] Cabal

2008-11-30 Thread Henning Thielemann


On Sun, 30 Nov 2008, Don Stewart wrote:


*if* .. *might* .. *assuming* .. *potentially* .. *maybe* .. *if*..

You could have built it by now!

   Source:
   
http://hackage.haskell.org/packages/archive/cabal-install/0.6.0/cabal-install-0.6.0.tar.gz

   Dependencies that aren't in core:
   
http://hackage.haskell.org/packages/archive/HTTP/3001.1.5/HTTP-3001.1.5.tar.gz
   
http://hackage.haskell.org/packages/archive/zlib/0.5.0.0/zlib-0.5.0.0.tar.gz

Note the last one assumes you have zlib the C library installed. This
should be straight forward to obtain.


I have extended this description and put it to
   http://haskell.org/haskellwiki/Cabal-Install

Maybe you like to add a pointer in cabal-install.cabal/Homepage field to 
this page.

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


Re: [Haskell-cafe] Cabal

2008-11-30 Thread Henning Thielemann


On Sun, 30 Nov 2008, Don Stewart wrote:


lemming:


Maybe you like to add a pointer in cabal-install.cabal/Homepage field to
this page.


Good idea. Duncan?


After I finished that article, I also found:
  http://hackage.haskell.org/trac/hackage/wiki/CabalInstall
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Extensible Exceptions

2008-11-29 Thread Henning Thielemann


On Sun, 23 Nov 2008, Duncan Coutts wrote:


On Sun, 2008-11-23 at 01:40 +0100, Henning Thielemann wrote:

On Sat, 22 Nov 2008, Thomas Schilling wrote:


It's a pattern match error, implemented by throwing an asynchronous
exception.  The idea being, that we only have one mechanism (well, an
synchronous exceptions, thrown via throwIO).

Yes, I know that there's a difference between error and exception,
but I would argue that which is which depends on the program.  For
example, for most programs a pattern match error is a fatal condition,
there's no sane recovery from it.  OTOH, in a program like GHCi, a
pattern match error in an executed statement is an exceptional
condition, which we want to catch, so it doesn't kill GHCi.


It's completely ok to run something in a sandbox and try to observe
errors. But that's debugging and I think there is no need to do this in
many places of an application. In general handling errors automatically is
not possible, because an error might also be if a program loops
infinitely. Thus one should not generally handle an error like an
exception.


In general I agree. I would advise against explicitly catching such
exceptions just in the region where one is expecting them. That seems
like bad design.

On the other hand top level catch-all handlers that also catch such
logic errors sometimes make sense. For example in a Haskell web server
where we generate a page dynamically it makes a lot of sense to catch
errors in the page-generation function, including pattern match errors,
and produce a 500 error code response and log the error message.

That's a case, rather like ghci, where some flaw in the program can and
should be compartmentalised. There's no attempt to clean up the error
but it is a modular system and there is a clear boundary where failures
can occur without bringing down the entire system.


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


[Haskell-cafe] Re: Go Haskell! - array libraries

2008-11-28 Thread Henning Thielemann


On Fri, 28 Nov 2008, Simon Marlow wrote:


Manuel M T Chakravarty wrote:

Claus Reinke:

What do those folks working on parallel Haskell arrays think about the
sequential Haskell array baseline performance?


You won't like the answer.  We are not happy with the existing array 
infrastructure and hence have our own.  Roman recently extracted some of it 
as a standalone package:


  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vector

In the longer run, we would like to factor our library into DPH-specific 
code and general-purpose array library that you can use independent of DPH.


So we have two vector libraries, vector and uvector, which have a lot in 
common - they are both single-dimension array types that support unboxed 
instances and have list-like operations with fusion.  They ought to be 
unified, really.


It's worse:
   http://hackage.haskell.org/cgi-bin/hackage-scripts/package/storablevector
 :-)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Go Haskell!

2008-11-28 Thread Henning Thielemann


On Fri, 28 Nov 2008, Johan Tibell wrote:


On Fri, Nov 28, 2008 at 10:04 AM, Simon Marlow [EMAIL PROTECTED] wrote:


So we have two vector libraries, vector and uvector, which have a lot in
common - they are both single-dimension array types that support unboxed
instances and have list-like operations with fusion.  They ought to be
unified, really.


Yes please! Could we please have a ByteString style interface with
qualified imports instead of using ad-hoc name prefixes/suffixes as a
namespacing mechanism if we're going to merge the two libraries?


StorableVector is organized this way.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Extensible Exceptions

2008-11-22 Thread Henning Thielemann


On Sat, 22 Nov 2008, Thomas Schilling wrote:


Be careful, though.  This only works if there's a single constructor
for your exception type. If there are multiple, you should write it
like this:

 thing_to_try `catch` \(e :: MyErrorType) - case e of MyError1 _ -
..; MyError2 _ - ...

If you write `catch` (MyError1 ...) and a MyError2 is thrown, you will
get a pattern match error exception.


A pattern match exception or pattern match error? I mean, not handling 
a certain pattern is a programming error not an exceptional condition at 
runtime. Thus there is no need to throw a pattern match exception which 
is catched and handled somewhere else.


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


Re: [Haskell-cafe] Extensible Exceptions

2008-11-22 Thread Henning Thielemann


On Sat, 22 Nov 2008, Thomas Schilling wrote:


It's a pattern match error, implemented by throwing an asynchronous
exception.  The idea being, that we only have one mechanism (well, an
synchronous exceptions, thrown via throwIO).

Yes, I know that there's a difference between error and exception,
but I would argue that which is which depends on the program.  For
example, for most programs a pattern match error is a fatal condition,
there's no sane recovery from it.  OTOH, in a program like GHCi, a
pattern match error in an executed statement is an exceptional
condition, which we want to catch, so it doesn't kill GHCi.


It's completely ok to run something in a sandbox and try to observe 
errors. But that's debugging and I think there is no need to do this in 
many places of an application. In general handling errors automatically is 
not possible, because an error might also be if a program loops 
infinitely. Thus one should not generally handle an error like an 
exception.

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


Re: [Haskell-cafe] varargs zip

2008-11-21 Thread Henning Thielemann


On Fri, 21 Nov 2008, Jason Dusek wrote:


 It came up on IRC last night that there is no generic zip in
 Haskell. I decided to write one as an example, but it only
 half works.


I think that the ZipList type for Applicative functors is a solution.

http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Applicative.html#t%3AZipList

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


Re: [Haskell-cafe] Pattern matching on numbers?

2008-11-18 Thread Henning Thielemann


On Tue, 18 Nov 2008, Ryan Ingram wrote:


How does this work?


fac n = case n of
   0 - 1
   _ - n * fac (n-1)


ghci :t fac
fac :: (Num t) = t - t

The first line of fac pattern matches on 0.  So how does this work
over any value of the Num typeclass?  I know that the 1 on the rhs
of fac are replaced with (fromInteger 1), but what about numeric
literals in patterns?  Does it turn into a call to (==)?


As far as I know, yes. It is even possible to trap into an error on 
pattern matching this way if fromInteger generates an 'undefined'.



Should whatever technique is used be extended to other typeclasses too?


 It is unusual to do pattern matching on fractions, you mostly need it for 
recursion on natural numbers. Thus I think the cleanest solution would be 
to treat natural numbers like strict Peano numbers

  data PeanoStrict = Zero | Succ !PeanoStrict
 but with an efficient implementation using GMP integers, maybe using 
'views', if they were part of Haskell language. Then you can implement:


fac :: Integer - Integer
fac Zero = 1
fac n1@(Succ n) = n1 * fac n

 I would then give up pattern matching on any numeric type.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: OpenGL - OGL

2008-11-17 Thread Henning Thielemann


On Sun, 16 Nov 2008, Neal Alexander wrote:


Brent Yorgey wrote:

---
ANN: OpenGL with extra type safety. Neal Alexander
Hopefully the code will be uploaded to Hackage as a separate package soon.


http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OGL-0.0.0
http://haskell.org/haskellwiki/OGL


I'd prefer a more descriptive package name like safe-opengl or so.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What *not* to use Haskell for

2008-11-14 Thread Henning Thielemann
Dan Piponi schrieb:
 Real time audio applications are top of my list of crazy projects I
 would work on if I had a month spare. I think it might work out
 nicely. My approach wouldn't be to talk directly to audio hardware
 from Haskell but instead use a framework like Lava to generate low
 level code from an embedded DSL. I think that would be a really
 elegant way to work at a high level and yet have the result execute
 *faster* than traditionally written C++ code.
 --
 Dan
 
 On Tue, Nov 11, 2008 at 7:41 PM, sam lee [EMAIL PROTECTED] wrote:
 I haven't found multitrack audio recording applications written in
 Haskell. These are usually written in C++ using Jack audio or ASIO.
 This probably means that it is not a good idea to write real time
 audio applications in Haskell at the moment.
 So, probably avoid writing applications that use a high frequency
 timer and IO that should be synchronous to the timer in Haskell.


I do real time audio processing based on lazy storable vectors, however
I do not plan to implement another GUI driven program but want to
program audio algorithms and music in Haskell.
  http://www.haskell.org/haskellwiki/Synthesizer
 Although I can do some processing in real-time I don't approach the
speed of say SuperCollider so far. I must rely on GHC's optimizer and
sometimes it does unexpected things.

I know that one of Paul Hudak's students is working on something
similar, called HasSound. The DSL approach is already implemented for
CSound in Haskore (again there is also a not yet published library which
encapsulates this functionality) and you can also do real time sound
processing by controlling SuperCollider:
  http://www.haskell.org/haskellwiki/SuperCollider

See also:
  http://www.haskell.org/haskellwiki/Category:Music
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell] The Real Monad Transformer or is Haskell.org hijacked?

2008-11-12 Thread Henning Thielemann


On Tue, 3 Apr 2007, Henning Thielemann wrote:


It was argued that people avoid Haskell because of terms from Category
theory like 'Monad'. This problem can now be solved by a wrapper which
presents all the WWW without monads! Start e.g. at
http://saxophone.jpberlin.de/MonadTransformer?source=http%3A%2F%2Fwww%2Ehaskell%2Eorg%2Fhaskellwiki%2FCategory%3AMonadlanguage=English
 Of course the tool is written in Haskell, that is, Haskell helps solving
problems which only exist because of Haskell.
Bug reports and feature requests can be tracked at
 https://sourceforge.net/projects/parallelweb


The produced content has not changed very much, but the interface is much 
more friendly now. You can now enter the world of the Real Monad 
Transformer e.g. at:

 
http://www.haskell.org.monadtransformer.parallelnetz.de/haskellwiki/Category:Monad


Good luck!
Henning
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


<    5   6   7   8   9   10   11   12   13   14   >