Re: [Haskell-cafe] Parsers are monadic?

2007-07-01 Thread Jon Cast
On Saturday 30 June 2007, Claus Reinke wrote: The standard, naïve approach to monadic parsing is very nice, but inefficient. So *please read* some material based on HuttonMeijer approach, but don't stay there, read something more modern, since we thereby seem to have left the phase of simple

Re: [Haskell-cafe] Abstraction leak

2007-06-29 Thread Jon Cast
On Friday 29 June 2007, Andrew Coppin wrote: ...and again today I found myself trying to do something that would be very easy in an imperative language, but I cannot think of a single good way of doing it in Haskell. Hopfully somebody can give me some hints. snip long and helpful explanation

Re: [Haskell-cafe] Abstraction leak

2007-06-29 Thread Jon Cast
On Friday 29 June 2007, Jon Cast wrote: Here's my solution (drawn from a library I'll be posting Real Soon Now): snip solution I forgot to point out that this is 75-90% drawn from a library called Fudgets[1], which is probably the most extended practical meditation to date on programming

Re: [Haskell-cafe] Language semantics

2007-06-29 Thread Jon Cast
On Friday 29 June 2007, Andrew Coppin wrote: Jon Cast wrote: On Wednesday 27 June 2007, Andrew Coppin wrote: Wow, wait a sec - case expressions are allowed to have guards too?? Yes. I guess I assumed you knew that, sorry. The only syntactic (or semantic) difference between function

Re: [Haskell-cafe] Language semantics

2007-06-27 Thread Jon Cast
On Wednesday 27 June 2007, Andrew Coppin wrote: I have a tricky little question... Suppose I write a function like this: foo pattern1 | gard1 = ... | gard2 = ... foo pattern2 | gard3 = ... | gard4 = ... According to one tutorial I read, if pattern1 matches,

Re: [Haskell-cafe] Language semantics

2007-06-27 Thread Jon Cast
On Wednesday 27 June 2007, Andrew Coppin wrote: Stefan O'Rear wrote: On Wed, Jun 27, 2007 at 09:46:41PM +0100, Andrew Coppin wrote: I have a tricky little question... Suppose I write a function like this: foo pattern1 | gard1 = ... | gard2 = ... foo pattern2 |

[Haskell-cafe] Yet another implementation of cond

2007-06-27 Thread Jon Cast
I discovered this trick the other day, and didn't remember seeing it anywhere as a cond implementation: head $ [ e1 | cond1 ] ++ [ e2 | cond2 ] ++ [ e3 | cond3 ] etc. You can even use full pattern guards (more powerful than GHC's) in your conditions! Jonathan Cast

Re: [Haskell-cafe] Tools for Haskell and COM

2007-06-27 Thread Jon Cast
On Wednesday 27 June 2007, Andrew Coppin wrote: J. Garrett Morris wrote: Microsoft's Component Object Model. http://en.wikipedia.org/wiki/Component_Object_Model ...still left feeling unenlightened. COM documentation does seem to have that effect on people. . . Jonathan Cast

Re: [Haskell-cafe] Language semantics

2007-06-27 Thread Jon Cast
On Wednesday 27 June 2007, you wrote: Andrew: Try using catchalls in your guards pattern1 | guard1 = | guard2 = | otherwise = This makes it much easier to use pattern guards. otherwise is a reserved word used for this stuff in ghc. Since we're quoting the standard and all, my inner

Re: [Haskell-cafe] Practical Haskell question.

2007-06-25 Thread Jon Cast
On Monday 25 June 2007, Michael T. Richter wrote: On Mon, 2007-25-06 at 01:05 -0500, Jon Cast wrote: What exactly are you trying to do? I'm trying to model a transactional system which could fail mid-transaction without an easy rollback on conditions which could be checked in advance. snip

Re: [Haskell-cafe] Re: Haskell serialisation, was: To yi or not to yi...

2007-06-21 Thread Jon Cast
On Thursday 21 June 2007, Tom Schrijvers wrote: That wouldn't make a difference. If, from the pure Haskell point of view we can't tell the difference between two expressions that denote the same function, then operations in the IO monad should not be able to do so either. This doesn't make

Re: [Haskell-cafe] ReadS with Maybe

2005-01-05 Thread Jon Cast
Henning Thielemann [EMAIL PROTECTED] wrote: What is the reason for the definition ReadS a = [(a, String)] not being ReadS a = Maybe (a, String) ? The latter one reflects that either one or no value is read, whereas the first definition allows an arbitrary number of read values which

Re: [Haskell-cafe] local loops

2004-12-14 Thread Jon Cast
Per Larsson [EMAIL PROTECTED] wrote: I often use local loops in monadic code, e.g. main = do ... let loop = do ... if cond then loop else return () loop It seems that I can encode this idiom slightly more concise with the 'fix'

Re: [Haskell-cafe] The difference between ($) and application

2004-12-14 Thread Jon Cast
Derek Elkins [EMAIL PROTECTED] wrote: Personally, I would mind ($) being magical. One of the nice things about Haskell is there is practically no magic. The last thing I want is Haskerl (http://www.dcs.gla.ac.uk/~partain/haskerl.html). runST simply had a rank-2 type that is not

Re: [Haskell-cafe] Optmiization of recursion

2004-10-04 Thread Jon Cast
not be best. But it's really not that much easier to analyze performance or space usage under strict languages. In either case, the golden rule is: profile. Reading the source code will tell you very little. Jon Cast p.s. Of course, I know that reading the source code tells you very little about strict

Re: [Haskell-cafe] Fun with multi-parameter type classes

2004-08-19 Thread Jon Cast
This currently fails, because the type checker insists on trying to figure out what its type should be - even though it shouldn't be needed. The intermediate type /is/ needed---it's a (hidden) parameter to your `encode' and `decode' functions. Why do you think it shouldn't be? snip Jon Cast

Re: [Haskell-cafe] introspection | meta data

2004-08-05 Thread Jon Cast
this ? snip absolutely normal example So what is the general haskell approach to this type of introspection/meta data problem... ? Introspection in Haskell is provided by the Data.Generics module. Try `deriving Data' and go wild (everybody else has). Jon Cast

Re: [Haskell-cafe] humor

2004-07-30 Thread Jon Cast
that means I won't have written it, but I expect so). Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: humor

2004-07-30 Thread Jon Cast
for a newbie. He does like the '$' operator a bit much for my tastes though. Obviously you haven't realized the great beauty of $. You cannot like $ to much. foldr should be defined as follows: foldr f z [] = id $ z foldr f z (x:xn) = (f $ x) $ foldr f z xn etc. :) Jon Cast

Re: [Haskell-cafe] optimising for vector units

2004-07-26 Thread Jon Cast
expressions in paralllel, will outperform single threaded C code. (But it probably isn't that simple, or we would have it already :-) Nope. Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] optimising for vector units

2004-07-26 Thread Jon Cast
threads for each of the (infinitely many) cons cells in the list. I suspect I haven't fully understood the difficaulty in doing this, care to enlighten me? Certainly. See above. Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http

Re: [Haskell-cafe] Newbie: Is it possible to catch _|_ ?

2004-04-06 Thread Jon Cast
, so it won't catch all _|_s, nor will it give any guarantee as to which _|_ it will catch (for example, in error 3 + throw (DynException (toDynamic False)) it's indeterminate whether error's return value or throw's return value will ultimately be caught. Jon Cast

Re: looking for data structure advice

2003-12-15 Thread Jon Cast
about your choice of monoid than can be accounted for by a single class. snip Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: what's the deal with user error on fail?

2003-11-13 Thread Jon Cast
, this is indeed the case---every monad is after all a monad transformer applied to Haskell's identity monad, which supports errors (hence the existence of Haskell's `error' function :). So even if a monad designer doesn't explicitly add error support, the monad still supports errors. Jon Cast

Re: what's the deal with user error on fail?

2003-11-13 Thread Jon Cast
/in pure Haskell/. We can of course distinguish them in the IO monad (which perhaps ought to be re-named the SinBin monad, to be more honest...). So we can detect erroneous computations in any monad. Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED

Re: An IO Question from a Newbie

2003-09-22 Thread Jon Cast
to it. ^ Just thought I'd point out (in case it isn't clear) that this function is flushAfter h a = liftM2 const a (hFlush h). Not much of an improvement... Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo

Re: Monads and Maybe

2003-08-21 Thread Jon Cast
this sort of pattern.) Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: No safety in numbers

2003-08-21 Thread Jon Cast
in the middle of an expression. snip Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Another typing question

2003-08-14 Thread Jon Cast
at either beta or Sigma i::Int.beta. Clear? The alternative, btw., is to have both dependant sums and an undecidable type-checking problem. I think, sometimes they could be quite handy. Sure. Sarcastic comment censored. Jon Cast ___ Haskell-Cafe

Re: Another typing question

2003-08-06 Thread Jon Cast
, or for every polymorphic function there is a type it cannot be applied at. Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Explicit function call

2003-03-12 Thread Jon Cast
can say: do a - myFunc ... etc. If it doesn't, then you should probably re-think its definition. Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: is identity the only polymorphic function without typeclasses?

2003-03-02 Thread Jon Cast
to be ``no''? Thanks Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: separate compilation [was Re: Global variables?]

2003-02-05 Thread Jon Cast
from a given module, that's a public change, no? And if you don't, why should re-compilation be needed? snip Cheers, Andrew Bromage Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: separate compilation [was Re: Global variables?]

2003-02-05 Thread Jon Cast
Andrew J Bromage [EMAIL PROTECTED] wrote: G'day all. On Wed, Feb 05, 2003 at 08:05:56PM -0600, Jon Cast wrote: I'm not sure I follow this. If you change the type of a value exported from a given module, that's a public change, no? And if you don't, why should re-compilation be needed

Re: Global variables?

2003-02-03 Thread Jon Cast
this? snip Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Global variables?

2003-01-31 Thread Jon Cast
elimination will be performed. -- Glynn Clements [EMAIL PROTECTED] Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Global variables?

2003-01-31 Thread Jon Cast
of the order of evaluation. There you go: the precondition of unsafePerformIO is satisfied, so the usage is safe. Cheers, Ralf Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Global variables?

2003-01-31 Thread Jon Cast
program which differentiates between what any compiler actually does and running the variable allocations before main. Vincenzo -- Fedeli alla linea, anche quando non c'š Quando l'imperatore š malato, quando muore,o š dubbioso, o š perplesso. Fedeli alla linea la linea non c'š. [CCCP] Jon

``Cannot instantiate a type variable with a forall-type''

2003-01-30 Thread Jon Cast
Why does GHC place this constraint? I would expect forall to be predicative, and a type variable to range over all types, but obviously I'm missing something. Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman

Re: A question about dynamic typing

2003-01-23 Thread Jon Cast
Nick Name [EMAIL PROTECTED] wrote: On Sun, 19 Jan 2003 16:02:41 -0600 Jon Cast [EMAIL PROTECTED] wrote: But, to fully exploit the power of a functionally-programmed desktop, the interface should allow the user to map an operation onto all the objects of the panel; in this case

Re: A question about dynamic typing

2003-01-19 Thread Jon Cast
wasn't coherent, I can try to explain it more. It's not a problem of functional programming: even in object oriented programming I see the same problem if one doesn't use some form of typecast. Where am I wrong? Are there alternatives? Vincenzo Jon Cast

Re: Question about sets

2002-08-20 Thread Jon Cast
really an issue. In axiomatic set theory, every set must be a subset of some other set, except for powersets and unions. Unions are implementable using Either, and powersets are implementable using Set (i.e., powerset :: Set a - Set (Set a)). Scott Jon Cast

Re: Question aboutthe use of an inner forall

2002-08-19 Thread Jon Cast
is the statement ST s a ? It's not a statement, and forall s. is not a logic quantifier. ST s a is a type, and forall s. is a type quantifier. Scott Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo

Re: Question aboutthe use of an inner forall

2002-08-19 Thread Jon Cast
things any? snip Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Question aboutthe use of an inner forall

2002-08-19 Thread Jon Cast
' are the basic names for this sort of thing in type theory. See the discussion of the Howard-Curry isomorphism for `forall'. You probably don't want to know about `Pi'. Scott Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org

Re: Question about the use of an inner forall

2002-08-19 Thread Jon Cast
, too many extensions are documented only in technical papers... Thx for all replies Scott Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Question aboutthe use of an inner forall

2002-08-18 Thread Jon Cast
for the possibility. Does that come close to answering your question? Regards, Scott Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Modification of State Transformer

2002-08-08 Thread Jon Cast
that is to instantiate `Eq (Tree a)', and it's the same thing here: instantiate `Monad (St s)'. Of course, you need to switch the order of the arguments to St first (as done above), so Haskell knows `s' is a the state type, not the result type. HTH Jon Cast ___ Haskell

Re: large binaries

2002-07-24 Thread Jon Cast
languages than just Haskell :) So don't blame code re-use for Haskell-specific (or non-specific) problems, because code re-use is not a Haskell-specific cause. Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo

Re: conditional

2002-07-22 Thread Jon Cast
and /expression/, not a statement. Therefore, you have to provide an `else' clause. Thanks. Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: large binaries

2002-07-18 Thread Jon Cast
to deal with those complications; multiply that by however many functions are called by putStr. Abe Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: type equivalency

2002-06-05 Thread Jon Cast
Cagdas Ozgenc [EMAIL PROTECTED] wrote: For example all functions with Int - Int are type equivalent, because structural equivalency is used. Most of the time the functions are not compatible because they have different pre/post conditions, even though they seem to have the same input output

Re: Help need Cannot use type synonym in instance head

2002-04-14 Thread Jon Cast
Cheers Benny Jon Cast ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe