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
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
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
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
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,
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
|
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
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
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
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
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
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
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'
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
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
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
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
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
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
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
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
, 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
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
, 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
/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
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
this sort of pattern.)
Jon Cast
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe
in the middle of an expression.
snip
Jon Cast
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe
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
, 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
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
to be ``no''?
Thanks
Jon Cast
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe
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
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
this?
snip
Jon Cast
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe
elimination will be
performed.
--
Glynn Clements [EMAIL PROTECTED]
Jon Cast
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe
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
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
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
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
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
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
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
things any?
snip
Jon Cast
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe
' 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
, 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
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
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
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
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
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
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
Cheers
Benny
Jon Cast
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe
53 matches
Mail list logo