Re: [Haskell-cafe] Why are field selectors functions?

2013-08-08 Thread Jon Fairbairn
AntC anthony_clay...@clear.net.nz writes:

 No! This isn't more bikeshedding about notation.

 It's a bit of Haskell archaeology.

 On Sun, Jun 30, 2013 at 2:59 AM, Judah Jacobson wrote:
 [This isn't exactly what Judah wrote.]
 ...

 Instead of `x f` (to access field x of record f),
 maybe we could write `f{x}` as the record selection.  


 The more I thought about that ...

 We use { ... } to declare records, build them, update them.
 We use { ... } in pattern matching to access named fields.

 Why don't we use { ... } to access named fields in terms?

 The syntax `e{ foo }` is unused in H98. (Or at least it was in 1998.)
 Can someone who was there at the time (1994?, TRex?)
 remember if that was ever considered?

No one else has answered (at least in café), but perhaps the
reason is that like me they can’t really remember! I do remember
that since Haskell is a functional language we wanted as many
things to be functions as possible; we did want to be able to
pass field selectors around as arguments to other functions.

I vaguely remember suggesting some years later that we should
have {…} being a function, so that {field} is a field selector
and {field=value} is a field setter (and requiring that you had
to write use normal function application: “{field} structure” to
select field from structure). SimonPJ gave a reason why not, and
I’m sure it will be possible to search out what he said.

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



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


Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-04 Thread Jon Fairbairn
Francesco Mazzoli f...@mazzo.li writes:

 At Fri, 03 May 2013 16:34:28 +0200,
 Andreas Abel wrote:
 The answer to your question is given in Boehm's theorem, and the answer 
 is no, as you suspect.
 
 For the untyped lambda-calculus, alpha-equivalence of beta-eta normal 
 forms is the same as observational equivalence.  Or put the other way 
 round, two normal forms which are not alpha-equivalent can be separated 
 by an observation L.

 Thanks for the reference, and sorry to Ian for the confusion given by the fact
 that I was thinking in types...

 However, what is the notion of ‘telling apart’ here exactly?  Is it simply 
 that
 the resulting terms will have different denotations in some semantics?  My
 initial (wrong) assumption about termination was due to the fact that I 
 thought
 that the ultimate test of equivalence was to be done with α-equivalence 
 itself,
 on the normal forms.

α-equivalence on the Böhm trees — normal forms extended to
infinity. I suppose that counts as “some semantics” but its very
direct.

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


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


Re: [Haskell-cafe] Prolog-style patterns

2013-04-09 Thread Jon Fairbairn
Jan Stolarek jan.stola...@p.lodz.pl writes:

 Hi all,

 consider this simple reimplementation of 'elem' function:

 member :: Eq a = a - [a] - Bool
 member _ [] = False
 member y (x:xs) | x == y= True
 | otherwise = member y xs

 If Haskell allowed to write pattern matching similar to Prolog then we could 
 write this function 
 like this:

 member :: Eq a = a - [a] - Bool
 member _ [] = False
 member x (x:_)  = True
 member x (_:xs) = member x xs

This kind of pattern matching was considered and rejected by the
very first Haskell committee. Others have given some of the
reasoning, and I don’t recall the rest so won’t attempt to
rehearse them here. What I would like to say (without meaning to
attack you personally, Jan) is that we really need to make a
rule that this sort of small convenience should never be
considered.

Every now and a language feature will be invented that really
makes a large difference to a large number of programmes (do
notation was a prime example), so the language should evolve.
But against that, there is considerable value in having the
basic syntax remain unchanged for as long as possible.

I don’t know how to formulate it formally, but the rule should
be something like, unless a new feature shortens programmes that
can use it by a significant factor, it shouldn’t be included.

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



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


Re: [Haskell-cafe] Ticking time bomb

2013-03-23 Thread Jon Fairbairn
Marc Weber marco-owe...@gmx.de writes:

 The only safe way is acceptnig keys from people you know don't view pdf
 using adobe reader,

I don’t…

 who don't browse the web (neither use flash) etc.

I only browse the web (in general) from a diskless virtual
machine.

 And then still you also have to know that their email account password
 is reasonable strong ..

I don’t think you need to know that: you need to know that their
signing key password is strong, that they’ve never entered it
into a machine with a keylogger running, and no-one has shoulder
surfed them. Oh, and that no-one can blackmail or torture them
:-P

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


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


Re: [Haskell-cafe] Country names and language names

2013-03-08 Thread Jon Fairbairn
Henk-Jan van Tuyl hjgt...@chello.nl writes:

 On Wed, 06 Mar 2013 20:53:57 +0100, Obscaenvs obscae...@gmail.com wrote:
 Do not forget that country names can change; e.g. the Netherlands
 Antilles were split up in 2010. This might cause problems if you store
 country codes in a database. If you simply remove obsolete country
 codes, the database can not be used properly any more.

 P.S. If you want people to be able to enter there country of
 birth, you should include all countries that existed in the
 past 116 years; if  historians should be able to use it, you
 should include all countries that  ever existed.

These are both important points, but I think they fall outside
the remit of a library for ISO 3166 country codes, which I wrote
originally for use in circumstances where some other standard
just says “an ISO 3166 country code”. If the country codes
standard included (as ISO 639 language codes does) historical
codes, it would be appropriate to include them in that library,
but since it doesn’t, it requires a separate library.

Quite how far one should go back in this separate library I
cannot say, but there are obvious use cases for country /names/
for countries that ceased to exist before 1974 and which
therefore have never had an ISO 3166 country code.


* * *

I’m currently working on ISO 639 which again will be a
presentation of the standard as Haskell data types. It requires
ISO 15924 Script codes. It’s irritating how these things have
been standardised: the registry for ISO 639 is a different
format from ISO 15924, and the former includes (presumably
non-normatively) records for the script codes. In 639 ranges are
specified with “..” but in 15924 they are simply mentioned in
the names :-(.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2012-10-07)


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


Re: [Haskell-cafe] How to input Unicode string in Haskell program?

2013-02-22 Thread Jon Fairbairn
Alexander V Vershilov alexander.vershi...@gmail.com writes:

 The problem is that Prelude.getLine uses current locale to load characters:
 for example if you have utf8 locale, then everything works out of the box:

 $ runhaskell 1.hs
 résumé 履歴書 резюме
 résumé 履歴書 резюме

 But if you change locale you'll have error:

 LANG=C runhaskell 1.hs
 résumé 履歴書 резюме
 1.hs: stdin: hGetLine: invalid argument (invalid byte sequence)

That seems to be correct behaviour: the only way to know the
meaning of the bits input by a user is what encoding the user
says they are in.

But in general this issue is an instance of inheriting sins from
the OS: the meaning of the bit pattern in a file should be part
of the file, but we are stuck with OSs that use a global
variable (which should be anathema to Haskell). So if user A has
locale set one way and inputs a file and sends the filename to
user B on the same system, user B might well see something
completely different to A when looking at the file.

 To force haskell use UTF8 you can load string as byte sequence
 and convert it to UTF-8 charecters

but of course, the programmer can only hope that utf-8 will work
here. If the user is typing in KOI-8R, reading it as utf-8 is
going to be wrong.
-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk


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


Re: [Haskell-cafe] Why isn't Program Derivation a first class citizen?

2013-02-13 Thread Jon Fairbairn
Rustom Mody rustompm...@gmail.com writes:

 On Wed, Feb 13, 2013 at 4:17 AM, Nehal Patel nehal.a...@gmail.com wrote:
 
 Why isn't Program Derivation a first class citizen?
 ---
 I am stating these things from somewhat foggy memory (dont have any
 lambda-calculus texts handy) and so will welcome corrections from those who
 know better…

 In lambda-calculus, if reduction means beta-reduction, then equality is

semi

 decidable

 If a theorem-prover were as 'hands-free' as a programming language
 Or if an implemented programming language could do the proving that a
 theorem-prover could do, it would contradict the halting-problem/Rice
 theorem.

Just so, but I’ve long (I suggested something of the sort to a
PhD student in about 1991 but he wasn’t interested) thought
that, since automatic programme transformation isn’t going to
work (for the reason you give), having manually written
programme tranformations as part of the code would be a useful
way of coding. RULES pragmas go a little way towards this, but
the idea would be that the language supply various known valid
transformation operators (akin to theorem proving such as in
HOL), and programmers would explicitly write transformation for
their functions that the compiler would apply.

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


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


Re: [Haskell-cafe] lambda case

2012-11-30 Thread Jon Fairbairn
Andreas Abel andreas.a...@ifi.lmu.de writes:

 I had been missing a pattern matching lambda in Haskell for
 a long time (SML had fn since ages) and my typical use
 will be

   monadic_expr = \case
 branches

We’ve been through that.  I want something similar, but would
have preferred something more algebraic.

 I think \case is not the worst choice, certainly better than
 of ...

What’s your argument? You’ll have to do better than blatant
assertion to convince me. Making “case exp” optional builds on
an existing expression syntax, giving an explicit meaning to a
part of it, so a reader only has to know that “of {alts}” is a
function and case does something specific with it. This “\case”
takes the keyword from that expression syntax and makes it a
special case of lambda, so a reader seeing a lambda now has to
check for a keyword instead of knowing straight off that the
next thing is going to be a variable.

Back when we originally designed Haskell there were lots of
things that people wanted to put in, and eventually we reached a
point where we said that we would only put something new in if
it allowed us to remove (or simplify) something else. “\case”
complicates lambda, using “of” simply breaks “case … of …” into
two easily understood parts.
-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk



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


[Haskell-cafe] lambda case (was Re: A big hurray for lambda-case (and all the other good stuff))

2012-11-29 Thread Jon Fairbairn
Ben Franksen ben.frank...@online.de writes:

 just wanted to drop by to say how much I like the new lambda case extension. 
 I use it all the time and I just *love* how it relieves me from conjuring up 
 dummy variables, which makes teh code not only esier to write but also to 
 read.

 […] should *definitely* go into Haskell'13.

As I was opposed to the suggestion for lambda case I didn’t
really follow the discussion of the syntax, but I’m puzzled by
the choice. To me it seems obvious that if we are going to do
this (as opposed to something more decomposable like
lambda-match), we should do it simply by making the “case exp”
part of a case expression optional. So the syntax for lambda-
case would be

   of {alts…}

and we would then describe

   case e of {…}

as syntactic sugar for

   (of {…}) (e)

Doing it this way doesn’t introduce any new syntactic elements
and has fewer tokens at the point of use.

I don’t see any need for a \ in the syntax: this is a functional
language we are talking about after all. Once we know that “of”
introduces a function, that should be enough.

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


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


Re: [Haskell-cafe] Sparse records/ADTs

2012-10-27 Thread Jon Fairbairn
Yuri de Wit yde...@gmail.com writes:

 Would this be relevant?

 https://github.com/jonsterling/Data.Records

That looks promising, thanks.  It does use rather a lot of
extensions, so it’ll take me a while to understand it.
-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk



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


Re: [Haskell-cafe] Sparse records/ADTs

2012-10-26 Thread Jon Fairbairn
Twan van Laarhoven twa...@gmail.com writes:

 On 24/10/12 12:08, Jon Fairbairn wrote:

 Is there a convenient way of handling a data structure with lots
 of fields of different types that may or may not be filled in?


 Not sure about convenience, but here is a type safe solution
 with O(log n) lookups and updates. The idea is to define a
 GADT tree type with a fixed layout:

Thanks for your reply (and for all the others). Since type safe
is something that (for me) goes without saying, this is the best
solution, but it doesn’t really satisfy the convenience aspect.
(I had already looked at solutions using Map and contemplated a
tree structure, but didn’t like anything I had come up with). In
short, it looks like the answer to my question is “No.” :-/

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


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


[Haskell-cafe] Sparse records/ADTs

2012-10-24 Thread Jon Fairbairn

Is there a convenient way of handling a data structure with lots
of fields of different types that may or may not be filled in?

Something equivalent to

data D = D {a::Maybe A, b::Maybe B, c::Maybe C, …}

but with better space efficiency and a more convenient empty
object.

An easy alternative is

data E = Ea A | Eb B | Ec C | …
type R = [E]

which has a straightforward empty object, but one then must
define

   getA e = listToMaybe [a | Ea a - e]

for each field, which is tedious (and O(n)). Obviously Templates
would help, but is there an alternative I’ve missed?

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



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


Re: [Haskell-cafe] Monads

2012-10-01 Thread Jon Fairbairn
Albert Y. C. Lai tre...@vex.net writes:

 On 12-09-30 06:33 PM, Jake McArthur wrote:
 When discussing monads, at least, a side effect is an effect that is
 triggered by merely evaluating an expression. A monad is an interface
 that decouples effects from evaluation.

 I don't understand that definition. Or maybe I do subconsciously.

 I have

 s :: State Int ()
 s = do { x - get; put (x+1) }

 Is there an effect triggered by merely evaluating s?

 I have

 m :: IO ()
 m = if True then putStrLn x else putChar 'y'

 Is there an effect triggered by merely evaluating m?

 What counts as evaluate?

Evaluation! Consider m `seq` 42. m is evaluated, but to no
effect.

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


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


Re: [Haskell-cafe] How to take a minimum sub list that only contain certain number of elements of certain type?

2012-09-25 Thread Jon Fairbairn
Magicloud Magiclouds magicloud.magiclo...@gmail.com writes:

 Hi,
   For example, I have an array [0..]. Now I want to take a sub list
 that starts from index 0, and only contain 4 odds, and is minimum
 result. The answer should be [0, 1, 2, 3, 4, 5, 6, 7].
   How to do that? Combining lazy computing, I cannot figure out an
 efficient algorithm.

Does

f bound odds_so_far [] = []
f bound odds_so_far (x:xs)
 | odds_so_far == bound = []
 | otherwise = x : f bound (odds_so_far + if odd x then 1 else 0) xs

required_funciton = f 4 0

meet your criteria, or am I missing something?

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



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


Re: [Haskell-cafe] Knight Capital debacle and software correctness

2012-08-05 Thread Jon Fairbairn
Jay Sulzberger j...@panix.com writes:

 On Sat, 4 Aug 2012, Clark Gaebel cgae...@uwaterloo.ca wrote:

 As far as I know, you can't check equivalence of _|_. Since Haskell uses
 _|_ to represent a nonterminating computation, this would be
 synonymouswith solving the halting
 problem.

 Ah, thanks.  I will attempt to think about this.

Also, one way of looking at type systems says that all these
_|_s are the same (but as Clark says, there’s no way within
Haskell to compare them). Haskell mangles this a little by
including non-value things other than non-termination in its
types.

   — Jón


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


[Haskell-cafe] Failing to find a function

2012-02-19 Thread Jon Fairbairn

This is probably a failure of my search fu or some other mental
lacuna, but is there already a definition of this function
somewhere:

\a b - runKleisli $ (Kleisli a) + Kleisli b
?

Hoogling for its type

   MonadPlus m = (a - m b) - (a - m b) - a - m b

doesn’t net me anything useful.

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



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


Re: [Haskell-cafe] Failing to find a function

2012-02-19 Thread Jon Fairbairn
Erik Hesselink hessel...@gmail.com writes:
 On Sun, Feb 19, 2012 at 12:50, Jon Fairbairn jon.fairba...@cl.cam.ac.uk 
 wrote:
 This is probably a failure of my search fu or some other mental
 lacuna, but is there already a definition of this function
 somewhere:

 \a b - runKleisli $ (Kleisli a) + Kleisli b
 ?

 Not a single name, but I believe

   liftA2 mplus

 is the same function, and much shorter (and more general).

That’s the ticket. I was sure there was something like that (and
I almost asked if there was a library function g such that g
mplus = …).

Thanks,

  — Jón


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


Re: [Haskell-cafe] Rewrite this imperative in FP way

2012-02-05 Thread Jon Fairbairn
Haisheng Wu fre...@gmail.com writes:

 a = [1,1,1,1]
 b = [0,1,2,3]
 d = [0,0,0,0]

 for i in b:
   for j in c:
 if (i+j)3:
   d[i+j] += a[i]
 Do you have any cool solution in FP way?

I find the above sufficiently alien that I can’t work out what
it’s meant to do (what is it actually for?). c is undefined for
one thing. But you might like to see what 

do i - b; j -c ; return (i,j)

does and consider what “filter ( 3) . map (uncurry (+))”
does, and possibly look at Data.Array.array, depending on what
the problem you are trying to solve is.

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



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


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

2012-01-18 Thread Jon Fairbairn
(I’m somewhat dismayed that the error in my preliminary remark
has overshadowed the point of my original message — which was
about the distinction between lazy and non-strict. However…)

David Barbour dmbarb...@gmail.com writes:
 Full beta-reduction is certainly not strict

What, precisely, do you mean by “full beta-reduction”?

 but also doesn't guarantee terminate even where it is possible
 (i.e. it might indefinitely unfold a value without making
 progress).

That sounds very much to me like being overly strict.

 I don't think there is much you can say about non-strictness
 and termination.

I would hope there would be, as that (or at least productivity)
is the point of saying that Haskell has non-strict semantics.

 On Mon, Jan 9, 2012 at 3:01 AM,
 Jon Fairbairn jon.fairba...@cl.cam.ac.uk wrote:

 Perhaps what I should have said to be almost as succinct but
 this time accurate is “non-strict semantics requires that the
 evaluation strategy terminate if there is any evaluation
 strategy that terminates”?

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


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


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

2012-01-09 Thread Jon Fairbairn
wren ng thornton w...@freegeek.org writes:

 On 12/28/11 10:23 AM, Jon Fairbairn wrote:
 Thiago Negrievoh...@gmail.com  writes:

 Lazy evaluation is one implementation of non-strict semantics, where
 the arguments are evaluated only when they are needed.

 I would say this:

 * non-strict semantics require that no argument is evaluated
unless needed.

 I'm not sure that's quite right.

I’m sure it’s not right (as was pointed out a while ago). I was
in too much of a hurry to get to the next bit, namely giving a
description of the difference between non-strict and lazy.
Perhaps what I should have said to be almost as succinct but
this time accurate is “non-strict semantics requires that the
evaluation strategy terminate if there is any evaluation
strategy that terminates”?


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



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


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

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

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

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

 span/break?

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

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

groupBy is currently implemented using span.

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

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

giving

   all (pairwiseInOrderBy p) (groupCut p l)

and we would want

   concat (groupCut p l) == l

(all modulo nontermination side conditions). Anything else?

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


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


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

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

 On 02/01/2012 11:12, Jon Fairbairn wrote:
 maxm...@mtw.ru  writes:

 I want to write a function whose behavior is as follows:

 foo string1\nstring2\r\nstring3\nstring4 = [string1,
 string2\r\nstring3, string4]

 Note the sequence \r\n, which is ignored. How can I do this?
 cabal install split

 then do something like

 import Data.List (groupBy)
 import Data.List.Split (splitOn)

 rn '\r' '\n' = True
 rn _ _ = False

 required_function = fmap concat . splitOn [\n] . groupBy rn

 (though that might be an abuse of groupBy)

 Sadly, it turns out that not only is this an abuse of
 groupBy, but it has (I think) a subtle bug as a result.

It does indeed. Thanks. That was pretty much what I feared.

 Explanation (best guess) - the function passed to groupBy,
 according to the docs, is meant to test whether two values
 are 'equal'. I'm guessing the assumption is that the
 function will effectively treat values as belonging to
 equivalence classes. That implies some rules such as...

Right.  This issue has come up from time to time since groupBy
was first written, and someone pops up to justify the present
behaviour, but I can never remember why.

 In the context of this \r\n test function, this behaviour
 will I guess result in \r\n\n being combined into one group.
 The second \n will therefore not be seen as a valid
 splitting point.

Correct. In my defence, I did say “do something like” :-)

 Personally, I think this is a tad disappointing. Given that
 groupBy cannot check or enforce that it's test respects
 equivalence classes, it should ideally give results that
 make as much sense as possible either way. That said, even
 if the test was always given adjacent elements, there's
 still room for a different order of processing the list
 (left-to-right or right-to-left) to give different results -
 and in any case, maybe it's more efficient the way it is.

Looking back at the libraries list, I get the impression that
there was a suggestion to change the behaviour of groupBy, but
it doesn’t seem to have happened.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2010-09-14)


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


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

2012-01-02 Thread Jon Fairbairn
max m...@mtw.ru writes:

 I want to write a function whose behavior is as follows:

 foo string1\nstring2\r\nstring3\nstring4 = [string1,
 string2\r\nstring3, string4]

 Note the sequence \r\n, which is ignored. How can I do this?

cabal install split

then do something like

   import Data.List (groupBy)
   import Data.List.Split (splitOn)

   rn '\r' '\n' = True
   rn _ _ = False

   required_function = fmap concat . splitOn [\n] . groupBy rn

(though that might be an abuse of groupBy)

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



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


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

2011-12-28 Thread Jon Fairbairn
Thiago Negri evoh...@gmail.com writes:

 Lazy evaluation is one implementation of non-strict semantics, where
 the arguments are evaluated only when they are needed.

I would say this:

* non-strict semantics require that no argument is evaluated
  unless needed.

* lazy evaluation is an implementation of non-strict semantics
  in which no argument is evaluated more than once.

As an example of something other than lazy, normal order
reduction is non-strict, but arguments may be evaluated multiple
times.

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



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


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

2011-12-28 Thread Jon Fairbairn
Thiago Negri evoh...@gmail.com writes:

 2011/12/28 Jon Fairbairn jon.fairba...@cl.cam.ac.uk:
 * non-strict semantics require that no argument is evaluated
  unless needed.

 That's not the case on optimistic evaluation.

Oops, yes.  I should have said something like “non-strict
semantics require that evaluation should terminate if there is a
terminating reduction order” but went for something snappier
(and missed).

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2010-09-14)


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


Re: [Haskell-cafe] Overloaded Strings as default

2011-11-29 Thread Jon Fairbairn
Ivan Lazar Miljenovic ivan.miljeno...@gmail.com writes:

 On 29 November 2011 07:28, Daniel Díaz Casanueva dhelta.d...@gmail.com 
 wrote:
 Hi Cafe,

 I only feel curious about what would be the consequences of becoming the
 Overloaded Strings feature (currently, an extension) to be default in
 Haskell. This is not a proposal. I just want to know what pros and
 cons there are.

 One cons would be that you may need some more explicit type signatures
 being used: I have the situation in my graphviz library where both
 Text and String have instances of some classes (e.g. Labellable, which
 has a method toLabel :: (Labellable a) = a - Label) which result in
 explicit String values in the source code result in the compiler not
 knowing which instance to use (e.g. toLabel hi).

Though that could be ameliorated by allowing defaulting with a
default default (if you will) of String.

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


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


Re: [Haskell-cafe] XML modification

2011-11-25 Thread Jon Fairbairn
Andrew Coppin andrewcop...@btinternet.com writes:

 On 23/11/2011 12:58 PM, Andrew Coppin wrote:
 On 23/11/2011 10:14 AM, Jon Fairbairn wrote:
 HaXml

 Mmm. That looks very promising...

 which gives some idea of the flavour.

 OK. So it looks like processXmlWith is the function I want, if I'm going
 to read one file and create another from it. So now I just need to
 figure out which combinators I need. (The documentation seems a bit
 thin.) Can you show me a snippet for how I would find [one] element
 named foo and change its bar attribute to have the value 5?

 Well, from what I've been able to gather, HaXml has a really
 nice filter combinator library. However...

 Weird thing #1: processXmlWith handles the common case of
 loading a file from disk, filtering it, and saving the
 result to disk again. However, it does this based on CLI
 arguments. There is no function anywhere that I can find
 which allows the host program to specify what files to
 process. If you want to do that, you have to reimplement
 most of the body of this function all over again yourself.
 That seems a strange omission.

 Weird thing #2: There are absolutely no filters for dealing
 with attributes. I couldn't find anything anywhere that says
 apply this function to all the attributes of this element.
 I can find a function to /replace/ an element's attributes
 without regard to what existed before. But even something as
 trivial as adding an additional attribute while keeping the
 existing ones doesn't appear to be supported at all.

 Fortunately it turns out to not be especially hard to read
 the source for the replace-attributes function and change it
 to do what I want. But, again, it seems a rather large and
 obvious ommission. (I'm guessing that since attributes are
 key/value pairs and not content, you would need a seperate
 attribute filter type, which is different from the
 existing content filters. Even so, it shouldn't be /that/
 hard to do...)

 Anyway, the important thing is, Haskell (and more
 specifically HaXml) let me accomplish the task I wanted
 without too much fuss. It's /certainly/ faster than editing
 80 files by hand in a text editor!

I think these observations should be addressed to Malcolm
Wallace.

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



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


Re: [Haskell-cafe] XML modification

2011-11-23 Thread Jon Fairbairn
Andrew Coppin andrewcop...@btinternet.com writes:

 I've got a folder with about 80 XML files in it. I want to
 take each file and make specific modifications to it.
 (Mostly just finding specific attributes and changing their
 values to make then all consistent.)

 Now I guess it wouldn't take me /that/ long to code
 something from scratch. But does anybody have a better
 suggestion for tools or libraries that might be useful?

HaXml

Before google earth exposed a facility for computing path
lengths, I wrote my own using HaXml. The guts of it look like
this:

main …
 xml - fmap (xmlParse filename) (readFile filename)
 print_path_length xml

print_path_length (Document _ _ content _)
= print $ compute_length $ coordinate_string_to_list coordinate_string
  where coordinate_string
= singleCString
  . (txt `o` children `o` deep (tag coordinates))
  $ (CElem content)

which gives some idea of the flavour.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2010-09-14)


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


Re: [Haskell-cafe] Solving the configuration problem with parametrized modules

2011-09-06 Thread Jon Fairbairn
Joachim Breitner m...@joachim-breitner.de writes:

 Hi Cafe,

 this is an idea that has been floating in my head for a while, and I’m
 wondering about its feasibility and, if feasible, complexity (in the
 range from „trivial“ over “blog post” over “paper” to “thesis”).

 Application authors in Haskell often face the problem of run-time
 constants, e.g. values that are expected to be determined once during
 program start and then stay fixed for the remainder of the run. Good
 examples are user configuration values (--verbose, certain paths,
 debugging level, etc.).

There are two aspects to this, both of which have potential
solutions that I’ve been thinking about on and off for a long
time.

The first is command line arguments.

As far as I’m concerned they ought to be passed as a parameter
to the whole programme. So instead of main being a value
exported to the outside world and all importing of values being
done through the IO monad, we would have main going out and
argv::[String] as a global variable (which, of course would not
change during any run of the programme). The alternative version
of this, to make main::[String] - IO ExitCode has a superficial
cleanliness but doesn’t help with the general problem of having
to pass these things about, and in fact makes no real difference
to the referential transparancy of a programme.

The second is configuration data in files.

This seems to fall into two parts: the data that can be fixed at
link time and the data that changes from run to run. For the
former, a simple solution would be to have a facility to compile
a module from non-haskell data. This can be done with template
Haskell doing IO. So that leaves configuration data that changes
from run to run.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2010-09-14)


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


Re: [Haskell-cafe] Data.IArray rant

2011-09-06 Thread Jon Fairbairn
Roman Leshchinskiy r...@cse.unsw.edu.au writes:

 On 03/09/2011, at 03:04, Ivan Lazar Miljenovic wrote:

 On 3 September 2011 11:38, Evan Laforge qdun...@gmail.com wrote:
  The result is that my first contact with haskell
 arrays left me with the impression that they were complicated, hard to
 use, and designed for someone with different priorities than me.  Of
 course, Data.Vector didn't exist back then, but if someone were new to
 haskell now I would recommend they skip Data.IArray and head straight
 for vector.
 
 To an extent, I wonder how much of this has been that arrays were
 considered to be bad in Haskell, so no-one used them and no-one
 bothered to try and improve the API much (and instead went and created
 Vector, etc.).

No, arrays were not considered to be bad, they were designed
with parallelism in mind. It’s just that no-one has really put
much effort into the implementation (partly because during the
first few years no-one wrote anything that used arrays much, and
then there’s a feedback loop no usage=no implementation
effor=no usage. Also there seem to be some misunderstandings.

 It's rather that some considered the IArray API to be
 inadequate most of the time. Really, H98 arrays aren't very
 good at anything they do. For collective operations, you are
 supposed to convert the array to a list, work on the list and
 then convert it back to an array which just seems wrong.

I am unconvinded that this is any more wrong than using a for
loop in an imperative language. Remember that the lists are
lazy, so it’s misleading to say “convert the array to a list”
since what happens most of the time is that elements are taken
out of the array and passed to the processing function and then
thrown away before the next element is processed.

 Multidimensional arrays can't be sliced and diced in the style
 of Repa or NumPy.

I’m not familiar with Repa or NumPy, but what can they do that
cannot be done with judicious use of ixmap, which is a very
powerful mechanism.

 In general, H98 arrays seem to have been designed with the
 goal of providing a container with O(1) indexing. They do
 that, I suppose, although they aren't very well integrated
 with the rest of the language

Can you give examples?

 and they have conceptual problems (such as requiring two
 bounds checks for one array access).

Assuming that you mean that for safe array access where nothing
is known about the index at compile time, since any sort of
array has at least a beginning and an end, they all require two
bounds checks. Once you do know something about the index, it’s
a question of implementation.

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



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


[Haskell-cafe] xmonad on xkcd

2011-08-07 Thread Jon Fairbairn

http://xkcd.com/934/ (and look at the “hover text”) — so who’s
going to implement it?

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



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


Re: [Haskell-cafe] The Typeable class is changing

2011-07-12 Thread Jon Fairbairn
Carl Howells chowe...@janrain.com writes:

 This will affect snap-core and heist, of the things I've provided
 Typeable instances for.

 In snap-core, deriving makes it use the internal module name, rather
 than the canonical location of the type.  This causes issues with the
 Hint library, so it's worked around by using a manual instance of
 Typeable.

There’ll be a replacement for mkTycon (mkTycon3), so you can
still do manual instances…

 So, this change will hit me for two different reasons, and sadly
 involve using CPP to control how things are compiled.

so that shouldn’t be necessary.

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



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


Re: [Haskell-cafe] Comment Syntax

2011-06-05 Thread Jon Fairbairn
Albert Y. C. Lai tre...@vex.net writes:

 On 11-06-04 02:20 AM, Roman Cheplyaka wrote:
 It is, for my taste, a good comment marker, because of its resemblance
 to a dash. It makes the code look like real text:

let y = x + 1 -- increment x

 COBOL is real text, if that is what you want.

MOVE PROGRAMMER TO SARCASM
-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk


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


Re: [Haskell-cafe] Comment Syntax

2011-06-04 Thread Jon Fairbairn
Roman Cheplyaka r...@ro-che.info writes:

 * Andrew Coppin andrewcop...@btinternet.com [2011-06-03 18:12:04+0100]
 On 03/06/2011 05:02 PM, Albert Y. C. Lai wrote:
 I propose that only {- -} is comment; that is, -- is an operator token
 and not a marker of comments.
 
 I'm curious to know why anybody thought that -- was a good comment
 marker in the first place. (I'm curious because Haskell isn't the
 only language to have made this strange choice.)

 It is, for my taste, a good comment marker, because of its resemblance
 to a dash. It makes the code look like real text:

   let y = x + 1 -- increment x

And when the language was first defined, there was no real dash
available for this purpose. Nowadays we could use the unicode em
dash (U+2014, — if it survices nntp), and free up -- for other
purposes.

Of course, its hard to predict what effect this would have when
people didn't know how to enter it, and although it's quite
distinctive in proportional fonts, the difference between - and
— in monospace fonts is much harder to see.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2010-09-14)


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


[Haskell-cafe] Re: a simple question about types

2010-11-18 Thread Jon Fairbairn
Daniel Fischer daniel.is.fisc...@web.de writes:

 On Wednesday 17 November 2010 19:09:16, Jerzy M wrote:
 Hallo,
 let me take this simple function: (2*).
 If I check its type

 :t (2*)

 I'll obtain
 (2*) :: (Num a) = a - a

 But now it suffices to write
 g = (2*)
 and check

 :t g

 to obtain
 g :: Integer - Integer

 One more combination, now I write
 h x = (2*) x
 and check once more

 :t h

 to get
 h :: (Num a) = a - a

 So my question is: why (in this second example) Integer is inferred?
 What makes a difference?

 The monomorphism restriction.

And default. If you load this into ghci

   module Main where

   default (Int)

   g = (2*)
   main = putStrLn foo

and type :t g

you'll get Int - Int

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



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


[Haskell-cafe] Catching up on Time and Directory

2010-11-16 Thread Jon Fairbairn

I'm probably terribly out of date with this, so I wonder if
anyone can save me the bother of working out what the
/preferred/ libraries are for (a) determining the
last-modified-time of a file or directory and (b) manipulating
the resulting time datum.

I can find System.Directory.getModificationTime and
Data.Time.formatTime, but using them together seems unduly
awkward.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2010-09-14)

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


[Haskell-cafe] Re: Mysterious fact

2010-11-03 Thread Jon Fairbairn
Lennart Augustsson lenn...@augustsson.net writes:

 Jon, you beat me to it.  I was going to mention Ponder.

Strange chance; yesterday was the first time I read haskell café
for something like half a year.

 But Ponder did have a builtin type, it had the function type built in. :)

Well, to use the nomenclature of Ponder itself, (-) is a type
/generator/, not a type. So either it had no built-in types, or
it had infinitely many ;-)

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


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


[Haskell-cafe] Re: Mysterious fact

2010-11-02 Thread Jon Fairbairn
Andrew Coppin andrewcop...@btinternet.com writes:

 The other day, I accidentally came up with this:

 |{-# LANGUAGE RankNTypes #-}

 type  Either  x y=  forall r.  (x -  r) -  (y -  r) -  r

 left :: x -  Either  x y
 left x f g=  f x

 right :: y -  Either  x y
 right y f g=  g y

 |

 This is one example; it seems that just about any algebraic
 type can be encoded this way. I presume that somebody else
 has thought of this before. Does it have a name?

You could try reading my PhD thesis!
http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-75.html
contains a link to the full text scanned to a pdf. (That -- 1985
-- was a long time ago. One thing I really regret about it is
that there should have been a comma between simple and typed
in the title. I suspect people think simply typed when they
see it). It isn't hard to read (one of my examiners said it made
good bed-time reading).

Anyway, the relevant part is that Ponder was a programming
language (Stuart Wray even wrote a GUI programme in it) that had
(in principle) no built-in types, relying on the type system
being powerful enough to express anything and the optimiser
being good enough to convert them to something more sensible.
In practice neither was /quite/ true, but it got quite close.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2010-09-14)

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


[Haskell-cafe] Re: Function to find a substring

2010-06-08 Thread Jon Fairbairn
R J rj248...@hotmail.com writes:

 What's an elegant definition of a Haskell function that takes
 two strings and returns Nothing in case the first string
 isn't a substring of the first, or Just i, where i is the
 index number of the position within the first string where the
 second string begins?

f n h = listToMaybe [b | (a,b)- tails h `zip` [1..], n `isPrefixOf` a]

seems plausible, but how do you define elegant?

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


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


[Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-24 Thread Jon Fairbairn
Alexander Solla a...@2piix.com writes:

 On May 23, 2010, at 1:35 AM, Jon Fairbairn wrote:

 It seems to me relevant here, because one of the uses to which
 one might put the symmetry rule is to replace an expression “e1
 == e2” with “e2 == e1”, which can turn a programme that
 terminates into a programme that does not.

 I don't see how that can be (but if you have a counter
 example, please show us). 

Oops! I was thinking of the symmetry rule in general. What I
said applies to “a  b” and not to “a == b”, but my point was
that surely you can’t be sure of that until after you’ve
finished a proof that does consider ⊥?

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-23 Thread Jon Fairbairn
Alexander Solla a...@2piix.com writes:

 On May 22, 2010, at 1:32 AM, Jon Fairbairn wrote:

 Since Bool is a type, and all Haskell types include ⊥, you need
 to add conditions in your proofs to exclude it.

 Not really.  Bottom isn't a value, so much as an expression
 for computations that don't refer to real values.  It's
 close enough to  be treated as a value in many contexts, but
 this isn't one of them.

It seems to me relevant here, because one of the uses to which
one might put the symmetry rule is to replace an expression “e1
== e2” with “e2 == e1”, which can turn a programme that
terminates into a programme that does not.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-22 Thread Jon Fairbairn
R J rj248...@hotmail.com writes:

 I'm trying to prove that (==) is reflexive, symmetric, and
 transitive over the Bools, given this definition:

 (==):: Bool - Bool - Bool
 x == y =  (x  y) || (not x  not y)

Since Bool is a type, and all Haskell types include ⊥, you need
to add conditions in your proofs to exclude it.

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

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


[Haskell-cafe] Re: Announcement: Data.ISO3166_CountryCodes version 0.1

2010-04-25 Thread Jon Fairbairn
John Millikin jmilli...@gmail.com writes:

 Thanks for the library! I'm sure it will be very useful for people
 dealing with internationalized applications / libraries. I have a few
 suggestions, which might make your library easier to use and maintain.

 First, it's very common to include generated files in the
 tarball.

Ah. That would solve the problem of the spurious empty .hsc file.

 This allows users to install the package, without installing 3rd-party
 utilities, or downloading (possibly varying) versions from external
 websites. As your library is currently written, two users who install
 it might end up with dramatically different modules, depending on the
 contents of  http://www.iso.org/iso/iso3166_en_code_lists.txt .

It would take a major global political ructions to make them
/dramatically/ different, but I'm aware of the issue...

 Second, since the module is based on an external data set, a
 date-based version might more appropriate. Version 0.1 means
 nothing, but version 2010.4.24 indicates when the given version was
 generated. Alternatively, you can use a hybrid system to indicate both
 stability and the date -- such as 0.1.20100424.

Something like this is already on my TODO list, but the date
that I want to appear in the version number would be the
last-modified-date of the downloaded code-list. How do I get
that (which the build already puts into a file¹) into the .cabal
file?

 Third, if you'd like your module to be widely used in the Haskell
 community, the BSD3 or MIT license would be more appropriate. For
 technical reasons, the GPL and LGPL are essentially equivalent for
 Haskell packages. For political reasons, choosing the GPL will reduce
 your user market to free-software users. This isn't *necessarily* bad
 -- all of my large projects are GPL'd -- but be aware that your choice
 will heavily limit how many people use your library.

Something close GPL is what I want -- if I'm doing this for
openly and for nothing, I don't see why anyone should build
something on the back of it and make it proprietary without me
having a say. I'd be happy to put a notice somewhere to the
effect that I'm willing to negotiate terms for a separate
license for inclusion in proprietary code, though I'd like to
know the proper way of doing that.

 Fourth, consider storing your code in a version control system (like
 Darcs[1]),

it already is.  

 and publishing it on a website like Patch-Tag[2].

I was waiting for it to be uploaded overnight. If my rsync
system isn't configured to delete it next time, 

   darcs get --lazy http://www.cl.cam.ac.uk/~jf15/ISO3166_CountryCodes/

should get a copy.

[
 trying that without the --lazy just now netted me this:
darcs: bug in darcs!
Another possible bug in URL.waitNextUrl:  curl_multi_perform() - no running 
handles at src/URL.hs:243 compiled Sep 12 2009 12:18:27
I'm unable to check http://darcs.net/maintenance to see if this version is 
supported.
If it is supported, please report this to b...@darcs.net
If possible include the output of 'darcs --exact-version'.

 which isn't encouraging.
]

 This enables people to contribute patches more easily. I've
 already checked it in as a branch[3]

That was a bit premature!

 -- either branch mine, or create your own trunk.

No! :-P

 Finally, instead of using a Makefile to build the library or
 documentation, consider using the cabal-install utility[4]. It's much
 more common for a library to use cabal build or cabal haddock than
 custom make commands, and external tools (such as Hackage) will work
 better.

I'd be grateful for a patch (against my repo) that did that.
I've used make for thirty years, so learning something else
doesn't hold great appeal.


[1] I was going to do something more sophisticated with the
last-modified-date, but in ghc 6.10.4 date and time handling
seems to be a bit of a mess, so I abandoned it.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: The instability of Haskell libraries

2010-04-24 Thread Jon Fairbairn
John Goerzen jgoer...@complete.org writes:

 It is somewhat of a surprise to me that I'm making this
 post, given that there was a day when I thought Haskell was
 moving too slow ;-)

 My problem here is that it has become rather difficult to
 write software in Haskell that will still work with newer
 compiler and library versions in future years.

I have the same problem, except that I work so slowly that
things have changed before I finish anything!

 Here is a prime example.  (Name hidden because my point here
 isn't to single out one person.)  This is a patch to
 old-locale:

 Wed Sep 24 14:37:55 CDT 2008  xx...@x.
   * Adding 'T' to conform better to standard
   This is based on information found at

 http://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
 diff -rN -u old-old-locale/System/Locale.hs new-old-locale/System/Locale.hs
 --- old-old-locale/System/Locale.hs   2010-04-23 13:21:31.381619614 -0500
 +++ new-old-locale/System/Locale.hs   2010-04-23 13:21:31.381619614 -0500
 @@ -79,7 +79,7 @@
  iso8601DateFormat mTimeFmt =
  %Y-%m-%d ++ case mTimeFmt of
   Nothing  - 
 - Just fmt - ' ' : fmt
 + Just fmt - 'T' : fmt

 A one-character change.  Harmless?  No.  It entirely changes
 what the function does.  Virtually any existing user of that
 function will be entirely broken.  Of particular note, it
 caused significant breakage in the date/time handling
 functions in HDBC.

 Now, one might argue that the function was incorrectly
 specified to begin with.

It certainly was, and I said so in
wfmytn48x5@calligramme.charmers posted to the Libraries
list back in 2007:

 According to http://www.w3.org/TR/NOTE-datetime (and other
 random sources), the iso format for date+time in one field
 is -MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00), ie
 no spaces around the T but iso8601DateFormat outputs a
 space after the day if the timeFmt is not Nothing, so
 
 formatTime System.Locale.defaultTimeLocale
(System.Locale.iso8601DateFormat (Just T%H:%M:%SZ)) 
(UTCTime (fromGregorian 2007 10 20) 26540)
 
 yeilds 2007-10-20 T07:22:20Z.  I reckon this is a bug,
 but at the very least it's not a good design.  Please can we
 change
 
 
  Just fmt - ' ' : fmt
 
 to 
 
  Just fmt - fmt
 
 ?  if someone wants a space, they can put it in the string,
 but it's a pain to take it out when you want the one field
 format with a T there.

Now, while that change would still have been incompatible, I
think it would have hurt less. But the problem here is that no
one noticed my message, and then someone else must have seen the
problem and made the different change without checking through
old messages. If I remember correctly, I didn't report it as a
bug because (a) I had some problem accessing trac at the time
and anyway 2007-10-20 07:22:20Z is acceptable as a two field
format, so it was a feature request (make it possible to output
the correct single field format).  But no discussion ensued.

My own, related, gripe about Haskell libraries is that they seem
very patchy; not adhering very well to relevant standards and
not using Haskell's types enough. For your cited example, there
is an applicable standard, so it should have been written to
adhere to it and properly typed formats are rather awkward to
do, so that can be forgiven.  But in many other places Strings
are used, with the effect that there's no typechecking at all.

An example I came across yesterday: I wanted to read a file
modification time and use that as the If-Modified-Since header
in an HTTP request. System.getModificationTime returns one type
of date, and I couldn't find how to format that correctly
(There's old-time and new time -- which one do I choose for
future compatibility? And how /do/ I convert that date to
something I can format for http?), but more to the point, I
shouldn't have to care: the IF-Modified-Since header in HTTP
expects a date, and I got a date from the system, so it should
be typed that way; converting it to the right format for HTTP is
simple-HTTP's job.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: persist and retrieve of IO type?

2010-04-10 Thread Jon Fairbairn
Ivan Lazar Miljenovic ivan.miljeno...@gmail.com writes:

 Daryoush Mehrtash dmehrt...@gmail.com writes:

 Is there a way to persist a [IO ()] to say a file then retrieve it later and
 execute it using a sequence function?

 I'm not sure I understand what you're wanting... you can pass around
 values of type IO () around, but they won't be executed until you
 actually use them...

It sounds more like he wants two functions something like

save:: FilePath - [IO ()] - IO ()
restore:: FilePath - IO [IO ()]

to which the answer would be no.
-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk


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


[Haskell-cafe] Re: Integers v ints

2010-04-02 Thread Jon Fairbairn
Jens Blanck jens.bla...@gmail.com writes:

 On 1 April 2010 10:53, Ivan Lazar Miljenovic ivan.miljeno...@gmail.comwrote:
 Jens Blanck jens.bla...@gmail.com writes:
  I was wondering if someone could give me some references to
  when and why the choice was made to default integral
  numerical literals to Integer rather than to Int in
  Haskell.

Seems to have been in 1998.  I don't have a complete archive of
the discussion, though, and I don't know where to find the
Haskell 98 committee minutes on-line.

 My guess is precision: some numeric calculations (even doing
 a round on some Double values) will be too large for Int
 values (at least on 32bit). Note that unlike Python, etc.
 Haskell doesn't allow functions like round to choose between
 Int and Integer (which is equivalent to the long type in
 Python, etc.).

 Ints have perfect precision as long as you remember that it
 implements modulo arithmetic for some power of 2. I was hoping
 that the reason would be that Integers give more users what
 they expect, namely integers, instead of something where you
 can add two positive numbers and wind up with a negative
 number.

As I interpret the part of the discussion I have on file, there
are two reasons: 

(1) as you hoped, because Integers are what people expect:
reasoning on Integers is more reliable -- you can't do induction
on Int, for example, and people don't generally try to prove
that they've implemented

 f x = the_f_they_originally_wanted x `mod` 2^32

(2) good language design. One of the things I've repeated over
the years is that Int doesn't have to be part of the language
(it's just another peculiar type that should be defined in a
library) but Integer does, because without it there's no way to
specify the meaning of an Integral constant¹.

  Jón


[1] This isn't quite true; using subtyping one could make
Integral constants into [Digit] and leave the conversion to the
point where overloading is resolved, but that's a much longer
story.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Are there any female Haskellers?

2010-03-28 Thread Jon Fairbairn
Leon Smith leon.p.sm...@gmail.com writes:

 On Sat, Mar 27, 2010 at 1:56 PM, Jason Dagit da...@codersbase.com wrote:
 For some reason it started out as a male dominated field.
 Let's assume for cultural reasons.  Once it became a male
dominated field, us males  unknowingly made the work and
learning environments somewhat hostile or unattractive to
women.  I bet I would feel out of place if I were the only
male in a class of 100 women.

 Is this really true?  I've heard rumors that in the early days of
 programming, that women were in the majority,  or at least they
 represented a much greater proportion of programmers than they do now.
   I seem to recall that this started to change sometime in the 60s.

One thing I observed of the Computer Science Tripos in Cambridge
was that the absolute number of women doing the course didn't
change much, but the size of the course increased over the
years. This suggests that men went into it because it was
trendy, but for the most part women went into it because they
found it interesting (and the proportion of women in the general
population who find it interesting was roughly constant). This
was twenty years ago, and I don't know if the subsequent data
supports the hypothesis.

Another (provocative) observation is that most of the women
programmers I've known were good at it and thought they might
not be, but most of the men claimed to be good at it but
were not.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Allowing hyphens in identifiers

2009-12-16 Thread Jon Fairbairn
Daniel Fischer daniel.is.fisc...@web.de writes:

 Am Dienstag 15 Dezember 2009 03:04:43 schrieb Richard O'Keefe:
 On Dec 14, 2009, at 5:11 PM, Daniel Fischer wrote:
  1. I wasn't playing in the under_score vs. camelCase game, just
  proposing a possible
  reason why the camelCase may have been chosen for Haskell's standard
  libraries.

 But the insanely abbreviated example did not provide such a reason.

 Of course not. But if you expand it - and it's not difficult,
 even when insanely abbreviated -, the resulting sentence gives
 a possible reason: Maybe it's because the underscore style is
 considered far uglier and less readable by others. If the
 early Haskellers felt that way, isn't it perfectly natural
 that they chose the camelCase style?

As one of the early Haskellers, I definitely preferred
underscores, because my intuition told me that it was closer in
appearance to normal English¹ text, and my belief was that even
programmers read more English than code. Unfortunately I'm not a
very persuasive person, and couldn't argue my case (beyond
having underscores /permitted/). The problem is that once people
have spent some time using one style or other, their ability to
self-analyse their reading of it becomes negligible. Ugly and
less readable become synonymous with not the style I'm used
to, irrespective of actual effects on reading speed. And
introspection is a notoriously bad method of anyalysing
psychological factors in the first place.

This really should have been decided with proper experiments.

 Of course, they may have had entirely different reasons, or no
 concrete reason at all and it just happened.

In the absence of hard data, it only takes a slight bias in
exposure among members of the committee to tip a decision the
wrong way.

[1] and quite a high proportion of other natural languages.

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


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


[Haskell-cafe] Re: Allowing hyphens in identifiers

2009-12-09 Thread Jon Fairbairn
Deniz Dogan deniz.a.m.do...@gmail.com writes:

 2009/12/8 Jon Fairbairn jon.fairba...@cl.cam.ac.uk:
 Deniz Dogan deniz.a.m.do...@gmail.com writes:

 [...] allow hyphens in identifiers, much like in Lisp
 languages? E.g. hello-world would be a valid function name.

 I (among others) suggested it right at the beginning when we
 were first defining the lexical syntax

 I just like the standard Lisp naming convention better than camel
 casing and saw someone on #haskell mentioning it the other day. No
 biggie though.

I prefer it too, but as far as Haskell is concerned, it's one of
those things that's not really worth changing at this stage of
its life. Changing the syntactic category of Unicode HYPHEN
(U+2010) might still be possible, but someone (with more stamina
than me) would have to advocate it.

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


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


[Haskell-cafe] Re: Allowing hyphens in identifiers

2009-12-08 Thread Jon Fairbairn
Deniz Dogan deniz.a.m.do...@gmail.com writes:

 Has there been any serious suggestion or attempt to change the syntax
 of Haskell to allow hyphens in identifiers, much like in Lisp
 languages? E.g. hello-world would be a valid function name.

I (among others) suggested it right at the beginning when we
were first defining the lexical syntax, and have raised the
possibility again a couple of times now that unicode hyphens are
available, but it wasn't liked at the beginning and hasn't
excited much interest since.  Why do you want them?

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Fwd: Is () a 0-length tuple?

2009-11-08 Thread Jon Fairbairn
Pasqualino \Titto\ Assini tittoass...@gmail.com writes:

 The syntax is similar, but what else is?

What would you expect from an empty tuple?

(a,b,c) has a constructor function p3 a b c = (a,b,c) and three
destructor functions s3_1 (a,b,c) = a, s3_2 (a,b,c) = b and s3_3 (a,b,c)=c

(a,b) has a constructor function p2 a b = (a,b) and two destructor functions
s2_1 (a,b) = a and s2_2 (a,b) = b

(a) has a constructor function p1 a = (a) and one destructor function 
s1_1 a = a

() has a constructor function p0 = () and zero destructor functions.



 In JavaScript there is a null value, that is the only value of the
 null type.

I'm not sure that Javascript is a suitable place to get intuitions for
Haskell (null type would seem more like empty than single), but anyway,
the thing is that the sole (non-bottom) value of the /unit/ type is the
same as the empty tuple¹.

 Isn't () the same thing?  The only value of the unary type?

The empty type in Haskell would be (forall a.a) which has no
non-bottom values.


[1] Aside: I wanted haskell to share the same type for all empty values
(ie lists would have been symmetric unions of pairs with the unit type
List t = (t,List t) || ()), but that didn't fit with algebraic datatypes
so the design went a different way.
-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk


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


[Haskell-cafe] Re: Curried function terminology

2009-10-06 Thread Jon Fairbairn
David Virebayre dav.vire+hask...@gmail.com writes:

 On Mon, Oct 5, 2009 at 11:52 AM, Jon Fairbairn
 jon.fairba...@cl.cam.ac.uk wrote:

 [1] A pet peeve of mine is x supports y being used backwards (as in
 our application supports windows Vista, which would only make sense if
 it were something like a system tool that stopped Vista crashing.

 (Not a native English speaker here)

 How would you say  x works well with y ?

I think I would say x works well with y. There's no reason to abuse
support (which carries an implication of one thing being on top of
another) for this.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Curried function terminology

2009-10-05 Thread Jon Fairbairn
michael rice nowg...@yahoo.com writes:

 This is from Learn You A Haskell:

 ==

 Curried functions

 Every function in Haskell officially only takes one
 parameter. So how is it possible that we defined and used
 several functions that take more than one parameter so far?
 Well, it's a clever trick! All the functions that accepted
 several parameters so far have been curried functions. What
 does that mean? You'll understand it best on an example.
 Let's take our good friend, the max function. It looks like
 it takes two parameters and returns the one that's bigger.
 Doing max 4 5 first creates a function that takes a
 parameter and returns either 4 or that parameter, depending
 on which is bigger. Then, 5 IS APPLIED TO THAT FUNCTION and
 that function produces our desired result.

 What really happens when we do multThree 3 5 9 or
 ((multThree 3) 5) 9? First, 3 is applied to multThree,
 because they're separated by a space. That creates a
 function that takes one parameter and returns a function. So
 then 5 IS APPLIED TO THAT, which creates a function that
 will take a parameter and multiply it by 15. 9 IS APPLIED TO
 THAT FUNCTION and the result is 135 or something.

 ===

 The language (in CAPS) in the above two paragraphs seems to
 be backwards.

It is. 5 is applied to that function should be 5 is supplied to that
function (or that function is applied to 5) and so on. It's a fairly
common error in writing this sort of thing¹, and given that the title
Learn You A Haskell is totally ungrammatical, hardly seems surprising.

 In the first paragraph, since functions are
 conventionally applied to parameters shouldn't it read
 something like THE PARTIALLY APPLIED FUNCTION IS THEN
 APPLIED TO the 5? Or is the terminology different for
 Haskell, 

No, but Haskell does have a lot of non-native users of English among its
users.


[1] A pet peeve of mine is x supports y being used backwards (as in
our application supports windows Vista, which would only make sense if
it were something like a system tool that stopped Vista crashing.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Cabal packages - cabbages

2009-09-21 Thread Jon Fairbairn
Conor McBride co...@strictlypositive.org writes:

 On 20 Sep 2009, at 23:11, Jason Dusek wrote:

  Some day, we're going to need a short, catchy name for Cabal
  packages. Let's call them cabbages.

 Not that this is a good reason to change your mind, but some
 sufficiently ancient Brits may remember a televisual

Speaking of ancient Brits, the Finns used to call Britain
cabbage-land, in case that alters anyone's opinion.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: [Haskell-beginners] map question

2009-09-18 Thread Jon Fairbairn
Ketil Malde ke...@malde.org writes:

 Gregory Propf gregorypr...@yahoo.com writes:

 Heh, perhaps we should petition to have a new computer key and symbol
 added to the world's way of writing maths, something like maybe a
 downward angled slash to mean prefix (-)  

 Or just use 'negate' and 'subtract'?

Well, now that ghc accepts unicode characters in programme source, we
could ask that ¬ (NOT SIGN, U+00AC) be recategorised as an identifier
character and use that (as a simple function name) for negation and lose
the wart altogether.

class Negatable t where
  ¬ :: t - t

(and as a side effect we could have identifiers like slightly¬dodgy).

Or, if we want to make things look even nicer, make ‐ (HYPHEN, U+2010)
an identifier character and use − (MINUS SIGN, U+2212) for the infix
operator. Now we could have hyphenated‐identifiers too.

I think this second option would be the ㊣ (CORRECT, U+32A3) thing to
do, though editors and so on would have to be changed to make the
distinction readily visible.

I think it's Friday, but I'm not entirely sure this is silly.

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

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


[Haskell-cafe] Re: Mapping over multiple values of a list at once?

2009-08-28 Thread Jon Fairbairn
Raynor Vliegendhart shinnon...@gmail.com writes:

 Just wondering, what should be the expected output be of something
 like mavg 4 [1..3]? [3%2] or []?

[0%1, 1%4, 3%4, 3%2, 3%2, 5%4, 3%4, 0%1], of course ;-P


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


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


[Haskell-cafe] Re: ANN: Typeful/Text/HTMLs (for AngloHaskell/for scrap?)

2009-08-19 Thread Jon Fairbairn
Colin Paul Adams co...@colina.demon.co.uk writes:

 Jon == Jon Fairbairn jon.fairba...@cl.cam.ac.uk writes:
 Jon darcs get --partial
 Jon http://homepage.ntlworld.com/jon.fairbairn/Typeful/Text/HTMLs

 Did you make any progress on this at Anglo-Haskell?

Not really, owing to Microsoft site security ;-) [not that they were
being unreasonable, just that it cut me off rather abruptly]. I've
started some notes connected with this at
http://www.cl.cam.ac.uk/~jf15/Haskell-notes/AngloHaskell2009-Not-Talk.xhtml
(which as implied is not quite finished), though they are not especially
interesting to anyone who simply wants to use the library.

 Will it be cabal-ized soon?

That depends on whether anyone wants it done sufficiently strongly to do
it... at the moment I'm not motivated to learning how to do it (if I get
past all the non-programming stuff on my life to-do list, there are
several things on the project's TODO list that come before Caballise).
After all, if I'm the only person using the library, there's no reason
to caballise... granted, that smacks of a self fulfilling prophecy, but
I'm led to believe that if someone already knows cabal, it would be the
work of moments to do the job, whereas learning it would take
significant effort¹

The license would need attention too... in the absence of convincing
arguments to the contrary, I would favour GPL myself.


[1] And by the time I next wanted to do it, the chances are it would
have changed so much (or I would have forgotten it anyway) that I'd have
to learn it again.

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


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


[Haskell-cafe] ANN: Typeful/Text/HTMLs (for AngloHaskell/for scrap?)

2009-08-05 Thread Jon Fairbairn

A while ago I wrote this rather pedantic html library (it guarantees
standards compliance via types, even down to the nesting restrictions).
I announced it on the libraries list, but chronic fatigue gets in the
way of following things up, so I haven't taken it any further until
recently. And recently there have been other efforts in the HTML area
that may make it out of date.

Anyway, I think there are one or two useful ideas in it, and if I manage
to get to AngloHaskell, I'd like to discuss it a bit, hence the
announcement (rather closer to AH than I intended).

You can get the whole thing with 

darcs get --partial 
http://homepage.ntlworld.com/jon.fairbairn/Typeful/Text/nHTMLs
It should build with ghc 6.10 and haddock 2.4.2

or you can browse the documentation starting at 
http://homepage.ntlworld.com/jon.fairbairn/Typeful/Text/HTMLs/Documentation/haddock/Typeful-Text-HTMLs.html

and AngloHaskell people who are interested might want to look at
http://homepage.ntlworld.com/jon.fairbairn/Typeful/Text/HTMLs/TODO


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

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


[Haskell-cafe] Re: ANN: Typeful/Text/HTMLs (for AngloHaskell/for scrap?)

2009-08-05 Thread Jon Fairbairn
I wrote:
 You can get the whole thing with 

 darcs get --partial 
 http://homepage.ntlworld.com/jon.fairbairn/Typeful/Text/nHTMLs

but that was a temporary url that I copied and pasted. The correct one:

darcs get --partial 
http://homepage.ntlworld.com/jon.fairbairn/Typeful/Text/HTMLs

And I uploaded only a partial get because I don't have much space on
that server, but apparently darcs 2.3 can't get --partial from that
repo, so I've uploaded the whole thing for now.

Thanks to Max Desyatov for pointing out these problems.

And one of the tests failed because Bolivia is now the Plurinational
State of Bolivia, so I've add a patch for that. I've seen politics get
in the way of programming, but I've never had a bug caused by
/international/ politics before.

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


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


[Haskell-cafe] Re: Need feedback on my Haskell code

2009-07-29 Thread Jon Fairbairn
CK Kashyap ck_kash...@yahoo.com writes:

 line' (x1, y1) (x2, y2) deltax deltay ystep isSteep error
   | x1 == x2 = if isSteep then [(y1, x1)] else [(x1, y1)]
   | isSteep =
 (y1, x1) :
   line' (newX, newY) (x2, y2) deltax deltay ystep isSteep newError
   | otherwise =
 (x1, y1) :
   line' (newX, newY) (x2, y2) deltax deltay ystep isSteep newError
   where newX = x1 + 1
 tempError = error + deltay
 (newY, newError)
   = if (2 * tempError) = deltax then
   (y1 + ystep, tempError - deltax) else (y1, tempError)

It's early in my day, so I'm not very awake, but this looks like it
could be an iterate or something like that, rather than explicit
recursion.

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


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


[Haskell-cafe] Re: Adding a field to a data record

2009-07-29 Thread Jon Fairbairn
Henry Laxen nadine.and.he...@pobox.com writes:

 It seems to me this should be easy, but I can't quite figure out
 how to do it without a lot of typing.  Here is the question:

 Suppose you have a data type like:
 Data Foo = Foo { a :: Int, b :: Int, 
... many other fields ... 
  y :: Int } deriving (Eq, Read, Show, Typeable, Data)

 Now I would like to add a field z :: Int to the end of Foo.  If
 I have a ton of data out on disk, which I wrote with, say
 writeFile a.data (show foo) -- where foo is a [Foo] say 1000
 long, I would like to get a new a.data file which has a new
 z::Int field.

One approach to this would be to temporarily redefine Foo

data Foo = Foo { a :: Int, b :: Int, 
... many other fields ... 
y :: Int } deriving (Eq, Read, Show, Typeable, Data)
 | NuFu {a :: Int, b :: Int,
... many other fields ... 
y :: Int,
z :: Int} deriving (Eq, Read, Show, Typeable, Data)

read the file, map Foo to NuFoo + whatever the initial value of z is
and write it out again.

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

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


[Haskell-cafe] Re: Implicit concatenation in list comprehensions

2009-07-22 Thread Jon Fairbairn
Bulat Ziganshin bulat.zigans...@gmail.com writes:

 Hello Neil,

 Tuesday, July 21, 2009, 1:26:55 PM, you wrote:

  ++ [ -i      | not (null (ghcOptSearchPath opts)) ]
  ++ [ -i, dir | dir - ghcOptSearchPath opts ]

 Following the discussions, I now support this extension too - I keep
 seeing more and more places in my code where it would be very useful.

  ++[ -i        | not (null (ghcOptSearchPath opts)) ]
  ++ concat [ [-i, dir] | dir - ghcOptSearchPath opts ]

That looks good enough to convince me that new syntax gains too little
here. When adding stuff to the syntax you have to be very careful about
interactions between forms, and possible errors. The more you add, the
more likely it is that something horrible gets overlooked. And learning
haskell becomes more tedious (you have to learn stuff that you'd never
use because other people will).

Having a fairly small amount of flexible syntax (and Haskell is already
pushing the boundaries of fairly small) together with powerful
abstraction tools is far better than having a syntax so huge that no-one
can see how weak the abstractions are... I keep trying, but I don't
think I can finish this posting without mentioning Perl, whose
aficionados have so much investment in having learned all that crap that
they can't see how awful it is.


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


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


[Haskell-cafe] Re: was: Debugging methods for haskell structured data types the right way in haskell

2009-07-20 Thread Jon Fairbairn
Fernan Bolando fernanbola...@mailc.net writes:

 On Sun, Jul 19, 2009 at 7:40 AM, wren ng thorntonw...@freegeek.org wrote:
 Fernan Bolando wrote:

 The intention is z0 is a system parameter and database, it contains a
 set of info needed to define a particular simulation

 A single-constructor ADT, especially with the labeled-fields syntax, is
 pretty close to C structs; no need to reinvent them and give yourself
 headaches.


 Really, the only thing you should be using lists for is a variable-length
 sequence of elements drawn from the same type and distinguished only by
 their position in the sequence.

 This is the kind of code recommendations I was looking.

I'd worked out a longer reply over the weekend, but wren got there first
(It hadn't occured to me that anyone would write that much code without
knowing about algebraic types, so thought something else was going on).

I'd like to add that thinking about the C code for a programme like this
is counterproductive. If you are doing various mathematical operations,
it's better to go straight from the mathematics to Haskell, and work out
the appropriate abstractions (in Haskell) for the operations you are
using. You'll generally end up with much shorter code that is easier to
maintain.

It might be worth pointing out that you can do things with Haskell data
structures that you can't do conveniently in C. For example, if you were
doing something that involved calculating the determinants of matrices
fairly often, but you didn't know in advance which matrices, you could
define your own matrix type like this (roughly):

data MyMatrix t = MM {theNumbers:: Matrix t, my_determinant:: t}

make_matrix m
= MM {theNumbers = m, 
  my_determinant = determinant m
 }

and then use make_matrix whenever you make a new matrix and
my_determinant whenever you want a determinant.

Now, although to a C programmer this looks like you calculate the
determinant of every matrix, laziness means that you only calculate the
ones you use, and calculate them at most once for each matrix.


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


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


[Haskell-cafe] Re: Debugging methods for haskell

2009-07-18 Thread Jon Fairbairn
Henning Thielemann lemm...@henning-thielemann.de writes:

 On Thu, 16 Jul 2009, Fernan Bolando wrote:

 Hi all

 I recently used 2 hours of work looking for a bug that was causing

 Program error: Prelude.!!: index too large

 A good way to avoid such problems is to avoid partial
 functions at all. (!!) is also inefficient. Is it possible
 to define the function in terms of foldl?

I've looked at the code a bit more, and, with apologies to the original
poster, it doesn't look much like Haskell. For example, in
http://plan9.bell-labs.com/sources/contrib/fernan/escomma/Circuit.hs
there's stuff beginning with

   tADM :: Int
   tADM = 1

   tVSRC :: Int
   tVSRC = 2 

   tISRC :: Int
   tISRC = 3

   ...

that I think probably should be

   data Something = ADM | VSRC | ISRC ... deriving (Enum, ...)

though when I get to (((fst z0)!!pMSET)!!pMTYPE) == mOP I'm at a loss
to determine quite what the intention is. Maybe it should be an array
indexed by enum types, maybe a function, maybe something that can be
pattern matched on? I don't know.

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


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


[Haskell-cafe] Re: Debugging methods for haskell

2009-07-16 Thread Jon Fairbairn
Fernan Bolando fernanbola...@mailc.net writes:

 Hi all

 I recently used 2 hours of work looking for a bug that was causing

 Program error: Prelude.!!: index too large

 This is not very informative. It did not give me a hint which function
 was causing this. In C adding a few printf would have helped me, but
 in haskell I was not sure how to do that. Can anybody point me to some
 debuggin method everyone uses.

 After 2 hours I did find the bug eventually. The code can be viewed here.
 Maybe some reformatting of the code would make finding bugs easier?
 http://plan9.bell-labs.com/sources/contrib/fernan/escomma/

I wonder if your code has to use !! at all? I took a look at a random
module from the above link, and (without making much attempt at
understanding it), I'd guess that using accumArray and friends would be
more appropriate. Mostly you don't want to be doing indexing on lists.

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


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


[Haskell-cafe] Re: Debugging methods for haskell

2009-07-16 Thread Jon Fairbairn
Fernan Bolando fernanbola...@mailc.net writes:

 On Thu, Jul 16, 2009 at 4:10 PM, Jon
 Fairbairnjon.fairba...@cl.cam.ac.uk wrote:

 I wonder if your code has to use !! at all? I took a look at a random
 module from the above link, and (without making much attempt at
 understanding it), I'd guess that using accumArray and friends would be
 more appropriate. Mostly you don't want to be doing indexing on lists.

 Most of the !! are used to access a list of parameters similar to
 accessing structures in C.

Ah. I wondered why so many of them were x!!0. list!!constant is almost
always something that could be done better.

 I am not particularly sure how to apply accumArray for something like
 that?

You [probably] don't. My apologies for not looking more carefully (I
really did just glance at it), but the remark about not using !! still
stands. I've been trying to look at your source again, but the link
doesn't respond to requests at the moment, so I can't be much help.
Haskell has much richer mechanisms for doing structure-like things than
C. Tuples and data types being the most obvious.

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


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


[Haskell-cafe] Re: Haskell Zippers on Wikibooks: teasing! :)

2009-07-15 Thread Jon Fairbairn
Matthias Görgens matthias.goerg...@googlemail.com writes:

 doesn't make much sense to me yet, although I suspect I can read the mu as a
 lambda on types?

 Not really.  The mu has more to do with recursion.

I'd say it's entirely to do with recursion. It's like the Y combinator
(or fix) for types, though it is combined with a lambda.

mu t . t is like fix (\t - t)

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK

2009-07-11 Thread Jon Fairbairn
Wolfgang Jeltsch g9ks1...@acme.softbase.org writes:

 Am Freitag, 10. Juli 2009 05:26 schrieb rocon...@theorem.ca:
 I find it amazing that you independently chose to spell colour with a `u'.
 It makes me feel better about my choice.

 I have to admit that it makes me unhappy. :-( 

 Why do we use English for identifiers? Because English is the language
 of computer science. What English should we use? It’s tempting to say,
 we should use the original English, which is British English. But we
 should ask again what is the language of computer science. And the
 language of computer science is American English.

I don't buy that. And don't forget India.

 To my knowledge, most early developments in computer science had their roots 
 in the US.

Really? Manchester Mark I, EDSAC I, EDSAC II? Alan Turing, David
Wheeler, Maurice Wilkes? To mention a random selection of early ones
(leaving aside Konrad Zuse and colleagues and various Russian pioneers
on account of not speaking English).

 One consequence of this is that reserved words of programming 
 languages are typically in American English. PASCAL uses “program”,

The use of program rather than programme in programming was mandated
by the IFIP in what I regard as an attempt to act outwith their remit.
I've never accepted it.

 not “programme”, and BASIC uses “COLOR”, not “COLOUR”.

I'm not sure I would use BASIC as an authority for any aspect of
programming language design. Going back to the early developments
aspect, a high proportion of early work in functional programming was
done in Britain and elsewhere in Europe (at a time when Europeans
typically preferred British spellings), so perhaps one should recognise
that in choosing identifiers.

But anyway, where's the harm in a bit of variety? If someone who prefers
British spellings originates a package, why get het up about it if they
use them in identifiers? I have to put up with American spellings all
over the place, so a few British spellings might even up the balance a
bit.

-- 
Jón Fairbairn (British, but with a tendency to identify myself as
European)


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


[Haskell-cafe] Re: golf, predicate check function for MonadPlus

2009-07-07 Thread Jon Fairbairn
Dan Doel dan.d...@gmail.com writes:

 On Thursday 02 July 2009 6:36:09 am Jon Fairbairn wrote:
 check :: (MonadPlus m) = (a - Bool) - a - m a
 check p a
 | p a = return a
 | otherwise = mzero

 I've often noticed the need for a similar function in conjunction with 
 unfoldr:

   -- This is overly general for unfoldr, but it lines up with check
   stopAt :: (MonadPlus m) = (a - Bool) - (a - b) - a - m b
   stopAt p f x
 | p x   = mzero
 | otherwise = return (f x)

Yes, I've had occasion to use something like that too,
eg things similar to:

reverse . unfoldr (stopAt (==0) (swap  . flip divMod 10))
   where swap (a,b) = (b,a)

 And of course: check = flip stopAt id . not

or, equally, stopAt p f = fmap f . check (not . p)

Granted,

reverse . unfoldr (fmap (swap . flip divMod 10) . check (/=0))

isn't /quite/ as nice as the first version, but I imagine one could get
used to it.

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


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


[Haskell-cafe] golf, predicate check function for MonadPlus (was Re: How to read safely?)

2009-07-02 Thread Jon Fairbairn
Dan Doel dan.d...@gmail.com writes:

 There was talk of adding a readMaybe a while ago, but apparently it
 never happened.

 As it is, you can use reads, read s becomes:

 case reads s of
   [(a, rest)] | all isSpace rest - code using a
   _  - error case

 which ensures that you have an unambiguous parse with only trailing
 whitespace. You can, of course, modify that if you don't care about
 ambiguity or trailing characters.

I was wondering about a more algebraic way of writing that; here's a
version (that doesn't care about ambiguity)

readMaybe :: Read a = String - Maybe a
readMaybe
= join . fmap no_trailing_garbage . listToMaybe . reads
  where no_trailing_garbage = fmap fst . check (all isSpace . snd)

check :: (MonadPlus m) = (a - Bool) - a - m a
check p a
| p a = return a
| otherwise = mzero


I tried Hoogling for a function like check, but couldn't find it. Surely
there's one in a library somewhere? It looks useful to me. (I'm rather
taken by way the check (all isSpace . snd) part reads)

Monad.guard comes close but fails to get the cigar; in fact 

guard b == check (const b) ()

So check is more general.


Also, I don't see a singletonListToMaybe that one could use in place of
listToMaybe to require unambiguity. Could do

isSingleton [a] = True
isSingleton _ = False

and then use listToMaybe . join . check isSingleton -- aha! Another
use for check!




 Jón


[Footnote: I thought of writing guard == flip (check . const) () but
then realised it was pointless]

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

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


[Haskell-cafe] Re: (fwd) Haskell logo fail

2009-06-18 Thread Jon Fairbairn
Jason Dusek jason.du...@gmail.com writes:

   Why don't we have a picture of a cool dinosaur instead?

Something cool because the last heat of life went out of it
65 million years ago?

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

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


[Haskell-cafe] Re: Haskell philosophy question

2009-05-17 Thread Jon Fairbairn
Vasili I. Galchin vigalc...@gmail.com writes:

 Hello,

  I am confused between Haskell as delineated in the Haskell Report VS
 ghc pragmas which extend Haskell beyond the Haskell Report.

Pragmas are part of the report, and while I agree that using
them for extensions is stretching the meaning a bit, it's
clearly the best way of doing it -- they're not supposed to
change the semantics of the language as defined, but it
doesn't say anything about what they do to stuff that isn't
part of the language.

 I am sure I am not the first to ask. Caveat: on my part, I
 am not against innovation/extensions, but I don't like to
 see language bloat.

Me neither, but many of the extensions are for things that
hadn't been invented (or perhaps finalised, such as
heirarchical modules, IIRC) when the standard was written,
and which make the language more expressive, which is a
worthwhile aim. Among the stated aims of Haskell was to be a
platform for language development. Pragmas keep the
experimental stuff separate from the stuff one can rely on
because it's part of H98.

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


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


[Haskell-cafe] Re: fromInteger for Lists

2009-05-02 Thread Jon Fairbairn
Henning Thielemann schlepp...@henning-thielemann.de writes:

 Paul Keir schrieb:
 There's nothing better than making a data type an instance of Num. In
 particular, fromInteger is a joy. But how about lists?

 http://www.haskell.org/haskellwiki/Num_instance_for_functions
 http://www.haskell.org/haskellwiki/Type_classes_are_for_reusability

Hear, hear!

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: chr/ord?

2009-04-29 Thread Jon Fairbairn
Tim Wawrzynczak inforichl...@gmail.com writes:
 On Tue, Apr 28, 2009 at 8:08 PM, michael rice [1]nowg...@yahoo.com
 wrote:

   Hi,

   My Prelude docs must be out of date because chr and ord don't seem to be
   there. How do I access these functions?

 Michael, those functions are not in the Prelude, they're in Data.Char.

But they're not really necessary anyway:

   Prelude fromEnum 'A'
   65
   Prelude toEnum 42::Char
   '*'


-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-23 Thread Jon Fairbairn
Colin Paul Adams co...@colina.demon.co.uk writes:

 Lennart == Lennart Augustsson lenn...@augustsson.net writes:

 Lennart Of course, n+k will be missed by Haskell obfuscators.  I
 Lennart mean, what will we do without (+) + 1 + 1 = (+) ?

 I think what would be missed would you be having the opportunity to
 explain to me what it means.

It means the same as

(+) ((+) + 1) 1 = (+)

HTH c.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) --first release

2009-04-23 Thread Jon Fairbairn
Sittampalam, Ganesh ganesh.sittampa...@credit-suisse.com writes:

 Jon Fairbairn wrote:
 But we can remove them in future language versions. The point I was
 trying to make at the beginning of this subthread was that
 implementations should follow the definition, because having a core
 language (Haskell 98) that can be relied on is simpler and wastes
 less time than the alternative.

 There has to be a bit of give and take here between standards and
 implementations.

There is no such compulsion. There's an excellent case for
information from implementors and programmers to feed
experience into future standards, but that's not a reason
for implementing something part way.

 The Haskell 98 standard is now very old and becoming
 increasingly less relevant, hence the Haskell' effort.
 (n+k) patterns were always controversial and the decision
 to include them has indeed been reversed by the Haskell'
 committee.

But there is no retroactive removal from Haskell 98.

 So I would say that {Haskell 98 - (n+k)} is itself a
 worthwhile standard to implement.

It's not a standard. You have to document the difference
(waste of time), programmers have to notice the difference
(waste of time), books that describe H 98 no longer apply
(waste of effort). You can argue that the wastes here are
individually small, but you have to multiply them by the
number of times they happen (and again, I'm taking n+k as an
example of a general problematic attitude that's been with
us since FORTRAN I*, rather than really arguing about n+k
specifically).


[*] The FORTRAN IV standard contains some really quite
entertaining examples of what happens when you try to
standardise the intersection of divergent implementations of
a programming language.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-23 Thread Jon Fairbairn
John A. De Goes j...@n-brain.net writes:

 That's absurd. You have no way to access private source
 code, so any  decision on what features to exclude from
 future versions of Haskell  must necessarily look at
 publicly accessible source code.

This is all entirely beside the point. The question is not
whether n+k patterns should be in the language, it's whether
an implementation of Haskell 98 should include them.

 The only alternative is to continuously add, and never
 remove, features from Haskell, even if no one (that we
 know) uses them.

But we can remove them in future language versions. The
point I was trying to make at the beginning of this
subthread was that implementations should follow the
definition, because having a core language (Haskell 98) that
can be relied on is simpler and wastes less time than the
alternative.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-22 Thread Jon Fairbairn
Miguel Mitrofanov miguelim...@yandex.ru writes:

 Well, the problem is that every implementor does choose a
 subset of standart to implement.

That's what I'm complaining about.

 It's much worse in JavaScript - essential features working
 differently in Internet Explorer, Firefox, Opera, and
 Safari, and sometimes they even differ between versions; Web
 programmers still manage.

Strange example to choose. Have you any idea how much time
is wasted because of the implementation differences in
JavaScript? 

 (n+k)-patterns are nothing compared to that.

Since there is no need for /any/ differences in the
implemented part of H98, we can, if we choose, have /the/
language where all this crap about I'd better not use this
part of the standard because the MuckWorx compiler doesn't
implement it doesn't apply.

This thread is really depressing (this is about the rest of
the thread, not your post Miguel). We're rehearsing the
arguments about n+k patterns that were gone through by the
first Haskell committee and then rehashed by the H98 folks,
when that's completely irrelevant -- n+k patterns are in
H98, so implementors should implement them. It's arrogant
and disrespectful on the part of the implementors to say
that they know better than the committee what features
should be part of the language.

I'm reminded of decades ago when people talked about
implementing extended subsets of this or that language.
Perl is an extended subset of Haskell...

Concerning the suggestion that I should implement them,
given that I'm against n+k patterns, I hardly think the
effort should fall on me -- I'm not in the business of
implementing Haskell at all at the moment. Or maybe I should
be more pro-active. Here, using my favoured paradigm of
Advanced Reactive Software Engineering (a successor to
extreme programming and the like) is my Haskell 98 compiler
(currently only implements a subset):

module Main where
main = error (You have used an unimplemented feature of Haskell 98.\n\
  \Please submit a test case and patch to correct the deficiency\n)

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-20 Thread Jon Fairbairn
Achim Schneider bars...@web.de writes:

 Jon Fairbairn jon.fairba...@cl.cam.ac.uk wrote:

 a...@cs.uu.nl writes:
 
 Utrecht Haskell Compiler -- first release, version 1.0.0
 
 
 
  The UHC team is happy to announce the first public release of the
  Utrecht Haskell Compiler (UHC). UHC supports almost all Haskell98
  features
 
 Why? Is there something about Haskell 98 that's hard to
 implement?
 
 Insanity. I doubt anyone is going to miss n+k patterns:

That (taken with the followup from Richard O'Keefe saying he
does use them) underlines my point, really. What follows is
specific to Haskell, but the general point applies to most
languages I've encountered.

I have no love for n+k patterns, but they are part of
Haskell98 -- and were the subject of protracted arguments
for and against them before the Report was finished (I was
against them, if I remember correctly). Any implementation
claiming to be of Haskell98 should have them, whether or not
the implementor likes them, because otherwise someone will
come along with a valid Haskell98 programme and it won't
compile, so they'll have to hack it around. This sort of
thing (and resulting #ifdef all over the place) wastes far
more programmer time in the end (assuming the compiler
becomes popular) than it would take to implement the
feature.

It's not an implementor's place to make such decisions --
they can legitimately say this feature sucks and tell the
next Haskell committee so. If they care enough about it,
they can lobby or get on that next committee, but the
arguments for n+k patterns /in Haskell98/ were done long
ago.


-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-19 Thread Jon Fairbairn
a...@cs.uu.nl writes:

   Utrecht Haskell Compiler -- first release, version 1.0.0
   


 The UHC team is happy to announce the first public release of the
 Utrecht Haskell Compiler (UHC). UHC supports almost all Haskell98
 features

Why? Is there something about Haskell 98 that's hard to
implement?

 plus many experimental extensions.

fair enough, but it always puzzles my why implementations of
compilers almost never start with a complete standard
language.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Learning Haskell

2009-03-24 Thread Jon Fairbairn
Tom.Amundsen tomamund...@gmail.com writes:

 How long did it take you to become proficient in Haskell?

Something more than twenty years.

 By that, I mean - how long until you were just as
 comfortable with Haskell as you were with your strongest
 language at that time?

Oh, Haskell was my strongest language during all that time! ;-)

If I have a serious point, it's that going from writing
imperative programmes to writing properly functional ones
takes a lot longer than it takes to learn every facet of the
language.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Haskell Logo write-in candidate

2009-03-21 Thread Jon Fairbairn
Warren Harris warrensomeb...@gmail.com writes:

 Hi Jon,

 I agree with much of your rant, and would agree that the
 logo is  probably the least interesting about haskell, but I
 think that it's  worth spending a little time to spiffy up
 haskell's image from a  marketing perspective.

I don't disagree with that. I'm complaining about the
method...

 Although I downplayed much of my design decisions by
 focusing on the logo's t-shirt potential, I just wanted to
 say that a lot of thought did go into the design aspects
 of what I sent out.

I don't dispute that either. My point (about lack of
justification) was not that people didn't put thought into
their efforts, but that there's no mention of it on the
listing.


 A logo needs to be a crisp graphic, needs to draw people
 in who don't yet understand (pure lazy fun-- huh? or
 what's with that Amtrak symbol?)

That's where that particular design falls down. = is an
ugly symbol in the first place, and while the pun with a
lambda in the middle provides some intellectual
satisfaction, it doesn't outweigh the fussiness of its shape
or the irrelevant associations. I hadn't thought of Amtrak,
but it made me think of the flags of Mozambique and South
Africa.

 This is all off in the realm of marketing psychology,
 which is a far cry from programming language design, but
 important in the overall product perception nonetheless.

Again, I don't dispute the importance, but...


 The other thing about this logo design that is so great is
 the  community process that's creating it. It's the open
 source process in  a nutshell -- the brightest minds playing
 off each other to build  something bigger than the sum of
 the parts.

That could happen, but a vote by people who haven't been
given a clue isn't the way to get there.

 So even if the new logo ends up looking like something
 that rolled down hill collecting rubbish, the story behind
 it will be brilliant -- like a family photo reflecting who
 we are and how we do things here.

Maybe so, but the story isn't what's important as far as
your first point is concerned.

 I hesitated in sending my write-in candidate in the first
 place  because I didn't want to derail the process that's
 underway,

derailing it is necessary if we are to get the brightest
minds playing off each other

 Now at the risk of further muddling things, I'll just say
 that I like your idea of focusing on the :: symbol, and
 just wanted to provide my interpretation:

That design is more like it! I would vote for that.

 I think that's not bad either, although I think it loses a
 little of  the distinction and intrigue of Pollard's lovely
 monad/lambda symbol  with its curved edges.

In the absence of the :: version, I'd might go for that one,
but I think it really isn't simple enough, though to
properly decide between them, we'd have to try them out on
non-Haskellers.

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

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


[Haskell-cafe] Re: Query on list comprehension

2009-03-20 Thread Jon Fairbairn
Richard O'Keefe o...@cs.otago.ac.nz writes:

 The problem we were asked about was specifically
 a
 aa
 aaa
 The code (iterate ('a':) \n) does not give the right answer.
 It's not just that it produces an infinite list instead of three
 strings, it doesn't even start with the right string.  It starts
 with \n when we need a\n.

It was impossible to determine that from the question.

 To produce the specified output using that pattern, you need
 (take 3 . tail . iterate ('a':)) \n

take 9, surely?

 or any of several other alternatives.

 The original poster also didn't ask what is the best way to do
 this, but specifically asked about doing it with list
 comprehension.  Presumably this was an attempt to understand list
 comprehension better.

Perhaps, but as the OP didn't follow up to the message where
I said that it wasn't clear what the question was, by the
time Henning posted, I think he was justified in
generalising the question and taking the answer further.
This café is for discussion; it's not a suitable place for
asking a question, copying out the answer and disappearing
without further comment.

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

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


[Haskell-cafe] Re: Haskell Logo write-in candidate

2009-03-20 Thread Jon Fairbairn
Warren Harris warrensomeb...@gmail.com writes:

 After spending a bit of time trying to decide how to vote, I
 ended up  deciding that my favorite would be a hybrid of
 several of the designs  (#9  #49 FalconNL, and #50 George
 Pollard). It's probably too late to  include this in the
 voting, but here it is nonetheless:

That's quite nice, but the = lambda thing looks too busy
to me. What surprises me is that none(?) of the candidates
makes use of the type symbol. I'd like to see a version
something like yours, but with :: instead of =/lambda

::Haskell

means of type Haskell, which is what we want people's
programmes to be. Colour it interestingly and choose a good
font and there you are. The interestingly coloured :: on
its own would make a reasonable choice for a badge (eg for a
favicon).

 * * *

semi-rant warning:

This whole badge/logo business seems to me to be an
excellent example of Parkinson's law of triviality (choosing
the colour of the bikeshed). We have a large (too large)
number of variations on relatively few themes and a really
sophisticated voting system, but no very clear idea of what
they're for and no explanation (such as my of type Haskell
above) of why the candidates are the way they are.

I didn't join in much to the earlier discussion because I
thought things would work out to something sensible in the
end, but it doesn't look like that happened. Work out what
the problem is before putting the solution up for election!

I agree that the current badge is horrid (it looks like
something that rolled down a hill and collected some rubbish
on the way), but in the absence of a reasoned replacement,
the first step would simply be to get rid of it. Designing
these things isn't trivial, and while many of the candidates
are quite good pieces of art, a badge needs to be more than
that. Not that professional designers do better in general;
only a few of them are any good at it -- the rest rely on
most people not knowing pretty from appropriate and just
rake in the cash.

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

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


[Haskell-cafe] Re: Query on list comprehension

2009-03-19 Thread Jon Fairbairn
Henning Thielemann lemm...@henning-thielemann.de writes:

 On Tue, 17 Mar 2009, Melanie_Green wrote:

 What are the limitations of list comprehension. I want to use
 listcomprehension to output the pattern below. So a mixture of a's and
 newline characters. The part im stuck at is creating arguments in the
 listcomprehension to stop at some point then execute next loop. Is it even
 possible to create the pattern below purely from list comprehension.Thankyou
 in advance.

 a
 aa
 aaa

 iterate ('a':) \n

Game to Henning Thielemann!

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Query on list comprehension

2009-03-18 Thread Jon Fairbairn
Melanie_Green jac_legend_...@hotmail.com writes:

 What are the limitations of list comprehension. I want to use
 listcomprehension to output the pattern below. So a mixture of a's and
 newline characters. The part im stuck at is creating arguments in the
 listcomprehension to stop at some point then execute next loop. Is it even
 possible to create the pattern below purely from list comprehension.Thankyou
 in advance. 

 a
 aa
 aaa

I'm not clear what you mean by the question. Why do you want
to use list comprehensions? What if they aren't the best way
of getting the result you want?

You can write 

[a | b - [replicate n 'a' | n - [1..]], a - b ++ \n] 

but does that replicate fail to meet your specification?
If not, you can replace it with another list comprehension
like this:

[a | b - [['a'| m - [1..n]] | n - [1..]], a - b ++ \n]

but at this point, comprehension is not what most people
would get from reading the code. I'd say it was clearer to
write

concat [replicate n 'a' ++ \n | n - [1..]]





-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Sugestion for a Haskell mascot

2009-03-12 Thread Jon Fairbairn
Joe Fredette jfred...@gmail.com writes:

 Hehe, I love it. Sloth is a synonym for Lazyness in English
 too, and they're so freaking cute... :)

I wouldn't say it was an exact synonym. Though the
dictionary definitions are similar, sloth has a more
negative connotation than laziness; the fourth deadly sin is
called sloth rather than laziness.

I think using it as a mascot is a bad idea: Haskell is so
slow, they even chose a sloth as the mascot.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: How to work with date?

2009-03-02 Thread Jon Fairbairn
Magicloud Magiclouds magicloud.magiclo...@gmail.com writes:

 Hi,
   I am working on some calendar GUI thing. And I cannot find a library
 to operate the date.
   Like, when `now - getZonedTime`, how could I get all the dates of
 the week. Or when I got `today`, how to get the date of 10 days ago?

This sort of thing (given now - getZonedTime):

take 10 $ map (addDays (-1)) $ repeat $ utctDay $ zonedTimeToUTC now

there's enough functions in that to be going on with, I
think.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: How to work with date?

2009-03-02 Thread Jon Fairbairn
Bulat Ziganshin bulat.zigans...@gmail.com writes:

 Hello Jon,

 Monday, March 2, 2009, 2:22:55 PM, you wrote:

 take 10 $ map (addDays (-1)) $ repeat $ utctDay $ zonedTimeToUTC now

 take 10 $ iterate (addDays (-1)) $ utctDay $ zonedTimeToUTC now

take anything I post before 14:00 with a pinch of salt. Or
something stronger.

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


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


[Haskell-cafe] Re: permuting a list

2009-02-16 Thread Jon Fairbairn
Paul Johnson p...@cogito.org.uk writes:

 See http://okmij.org/ftp/Haskell/perfect-shuffle.txt

I should have read that first time round!

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Low-level high-level languages?

2009-02-16 Thread Jon Fairbairn
Maurí­cio briqueabra...@yahoo.com writes:

 Hi,

 I've checked this 'BitC' language (www.bitc-lang.org). It
 uses some ideas we see in Haskell, although with different
 realization, and target mainly reliable low level code,
 like micro-kernels (although I think it could be used
 anywhere C is also used, including writing libraries Haskell
 could call with FFI).

 Do you guys know of other languages like that that I could
 check?

Hume http://www-fp.cs.st-andrews.ac.uk/hume/index.shtml
might be worth a look. I've never tried it, and since one of
the top chaps associated with it said to me that he loathes
Haskell, I'm not sure I should mention it here :-)

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: permuting a list

2009-02-15 Thread Jon Fairbairn
Heinrich Apfelmus apfel...@quantentunnel.de writes:

 The answer is a resounding yes and the main idea is that shuffling a
 list is *essentially the same* as sorting a list; the minor difference
 being that the former chooses a permutation at random while the latter
 chooses a very particular permutation, namely the one that sorts the input.

 For the full exposition, see

http://apfelmus.nfshost.com/random-permutations.html

I haven't been following the thread, but my initial reaction
would have been something like use System.Random.randoms to
get a list rs and then do (roughly)

randomPerm = map snd . sortBy (compare `on` fst) . zip rs

How bad is that? I mean, how unfair does it get?

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


[Haskell-cafe] Re: Existencial quantification and polymorphic datatypes

2009-01-20 Thread Jon Fairbairn
Mauricio briqueabra...@yahoo.com writes:

 I'm trying, without success, to understand the difference
 between existencial quantification and polymorphic
 datatypes.

Polymorphic types are universally quantified;

so id:: forall t. t - t

means that id works for every type t.  If haskell had a
symbol for existential quantification, 

  hid:: exists t. t - t

would mean that hid only works on some type t, but it
doesn't say what it is (so you could only ever apply hid to
undefined.

 Can you give me a hint

Because being on the left of an arrow works something like
negation, a type like (exists t. t - t) - bool can be
written as  forall t . (t - t) - bool



-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2008-04-26)

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


[Haskell-cafe] Re: Different return type?

2009-01-19 Thread Jon Fairbairn
John Ky newho...@gmail.com writes:

 Hi,

 Possibly a silly question but is it possible to have a function that has a
 different return type based on it's first argument?

Are you sure that's what you really want?

 For instance

 data Person = Person { name :: String, ... }
 data Business = Business { business_number :: Int, ...}

data Entity = Person {...} | Business {...}

 key person = name person
 key business = business_number business

data Key = PersonKey String | BusinessKey Int

It seems likely that you are at least sometimes going to
want to pass the result of key to some other function.

...?

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2008-04-26)

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


[Haskell-cafe] Re: Logos of Other Languages

2008-12-19 Thread Jon Fairbairn
Ashley Yakeley ash...@semantic.org writes:

 All of these get one thing right that the current and most
 of the proposed Haskell logos do not: they don't make any
 reference to the syntax of the language itself. Doing so
 seems to miss the point of a logo: it's supposed to appeal
 visually, rather than semantically. So I'd like to see some
 submissions that don't use lambdas.

Perhaps something elaborating on the general lines of this:
http://homepage.ntlworld.com/jon.fairbairn/Haskell-H-arrow.png?
(Also .svg if anyone wants to develop it; that's a very
quick sketch). It's simple, bold and forward looking ;-).
It would need careful choice of colours: make the H blue and
the Arrow red and it looks too British, make the H red and
the arrow black, and it looks fascist (I suppose there are
those who think that might be apposite). And it needs a much
friendlier choice of typeface.

That's a badge rather than a logo, but we certainly want one
of those. Just add the askell part to get a logo?

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2008-04-26)

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


[Haskell-cafe] Re: TimeDiff to Int?

2008-11-14 Thread Jon Fairbairn
Lyle Kopnicky [EMAIL PROTECTED] writes:

 Thanks, but that doesn't seem to work. I got an answer of -3. I tried it
 again a minute later and it was still -3. I tried again a minute later and
 it was -1. It's just after 9am here, so I have no idea what to make of
 those numbers.

That's most strange. The only difference between what I
wrote and what you had before was the way the conversion to
Integer was done.

 I have settled on this code:

 secondsSinceMidnight :: IO Int
 secondsSinceMidnight = do
   zonedTime - getZonedTime
   return $ floor $ toRational $ timeOfDayToTime $ localTimeOfDay $
 zonedTimeToLocalTime zonedTime

So what happens with

do now - getZonedTime; print $ (fromEnum $ timeOfDayToTime $ localTimeOfDay $ 
zonedTimeToLocalTime now)`div`fromEnum (secondsToDiffTime 1)

where you are?

-- 
Jón Fairbairn [EMAIL PROTECTED]

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


[Haskell-cafe] Re: TimeDiff to Int?

2008-11-13 Thread Jon Fairbairn
Lyle Kopnicky [EMAIL PROTECTED] writes:

 I had some code using the oldtime package, and want to convert it to use
 the time package.
 One of the things I need to do is calculate the number of seconds since
 midnight. The easy part is getting a TimeDiff result:

You mean DiffTime?

 utc - getCurrentTime
 tz - getCurrentTimeZone
 let td = timeOfDayToTime $ localTimeOfDay $ utcToLocalTime tz utc
 Now td is a TimeDiff representation of the number of seconds since
 midnight. It prints nicely, but I'm having a heck of a time figuring out
 how to truncate it to an Int.

You could do something like
fromEnum td `div` fromEnum (secondsToDiffTime 1)
which says that you are computing a whole number of seconds.

-- 
Jón Fairbairn [EMAIL PROTECTED]
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2008-04-26)

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


[Haskell-cafe] Re: Announcing OneTuple-0.1.0

2008-10-02 Thread Jon Fairbairn
Benjamin L.Russell [EMAIL PROTECTED] writes:

Note:  the singleton tuple does not support tuple syntax.

 What is the syntax for the singleton tuple? [...]
 the singleton syntax will be different from the non-singleton syntax,
 which is also syntactically inelegant.

 What is your solution?

Replace () in tuple syntax with ⟨⟩ (unicode 0x27e8 and 0x27e0).

I always wanted Haskell to be defined in terms of an
idealised syntax together with a (at the time ASCII) machine
representation that approximated it.  As time went by, we
could gradually have made the approximation approach the
ideal.  It would probably have been a mistake politically,
though (people would have muttered about APL). Nowadays it
might be more acceptable.

-- 
Jón Fairbairn [EMAIL PROTECTED]
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2008-04-26)

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


[Haskell-cafe] Re: Health effects

2008-10-01 Thread Jon Fairbairn
Adrian Neumann [EMAIL PROTECTED] writes:

 I often wonder how many cuts you need to divide a steak in n
 pieces.  You can obviously get n pieces with (sqrt n) cuts
 by cutting a grid.  But I'm sure some smart mathematician
 thought of a (log n) way.

Are you allowed to move the pieces between cuts?

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


[Haskell-cafe] Re: [m..n] question

2008-09-22 Thread Jon Fairbairn
Richard A. O'Keefe [EMAIL PROTECTED] writes:

 Erlang's equivalent of [m..n] is lists:seq(M, N),
 which is currently defined to raise an exception when N  M.
 In particular, lists:seq(1, N) returns a list of length N
 when N  0, but not when N = 0.
 I'm currently arguing that lists:seq(1, 0) should be [],
 not an exception.  Oddly enough, I'm being beaten over the
 head with Haskell, of all things.

 In Haskell,
 The sequence enumFromTo e1 e3 is the list [e1,e1+1,e1+2,...e3].
  The list is empty if e1  e3.

 It is being claimed that the reason for this is that exceptions
 are problematic in Hasell, so the Haskell designers went out of
 their way to make this function total whether it made sense or not.

I'm pretty sure that's not true.  I'd like to be able to say
I know, I was there, but although I was there it was so
long ago that my memory isn't clear.  But it's clearly the
case that [5 .. 6] is [5, 6] (length 2) and [5 .. 5] has to
be [5] (length 1), so it's not unreasonable to expect that
[5, 4] be [] (length 0) -- having the induction extend down
to there makes most sense.  I'm fairly certain it was
arguments about induction and what constituted sensible
behaviour rather than our admitted dislike for exceptions
that carried the argument.



-- 
Jón Fairbairn [EMAIL PROTECTED]


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


  1   2   3   >