| I've heard Simon (Peyton-Jones) twice now mention the desire to be able
| to embed a monadic subexpression into a monad. That would be
| http://article.gmane.org/gmane.comp.lang.haskell.prime/2267 and in the
| recent OSCON video.
|
| I still think that this syntax extension has profound
Neil Mitchell wrote:
Hi Chris,
I've heard Simon (Peyton-Jones) twice now mention the desire to be able
to embed a monadic subexpression into a monad.
I think this is a fantastic idea, please do so!
$( expr ) -- conflicts with template haskell
( - expr ) -- makes sense, and I
See also this thread
http://www.haskell.org/pipermail/haskell-prime/2007-July/002269.html
Magnus made a TH library that does something similar, see
http://www.haskell.org/pipermail/haskell-prime/2007-July/002275.html
Nesting is important. Consider
do { a - f x
; b - g a
Chris Smith wrote:
I've heard Simon (Peyton-Jones) twice now mention the desire to be able
to embed a monadic subexpression into a monad. That would be
http://article.gmane.org/gmane.comp.lang.haskell.prime/2267 and in the
recent OSCON video.
I still think that this syntax extension has
On 03/08/07, Dave Bayer [EMAIL PROTECTED] wrote:
I'm actually calling
Markdown.pl on tiny files (source code of lengths a human would read), and
it is certainly sluggish enough to be a fair test.)
I had to do this recently, so you might be interested in my approach:
I've heard Simon (Peyton-Jones) twice now mention the desire to be able
to embed a monadic subexpression into a monad. That would be
http://article.gmane.org/gmane.comp.lang.haskell.prime/2267
..
Thoughts?
what is the problem you're trying to solve, and is it worth the
complication in
Hi
Perhaps we need to cool this thread down a little bit, and refocus. I
personally choose never to use ++ as anything but a statement, since
my brain works that way. Other people find different things natural,
so can pick what they choose. The one thing you can guarantee is that
discussing it
Dougal Stanton wrote:
I had to do this recently, so you might be interested in my approach:
http://193.219.108.225/code/blogpost/BlogPost.hs
The idea here is to run arbitrary text (blog posts) through Markdown
and Smartypants before sending them out to the wider world.
Pardon me while I
can you please rewrite *p++=*q++ in haskell?
assuming these operations
i :: V a - IO (V a) -- incr var addr, return old addr
r :: V a - IO a -- read var
w :: V a - a - IO () -- write var value
and this unfolded translation
do { qv - r q; w p qv; i p; i q }
assuming
Hi
Thinking on the semantic issue for the moment:
Can you use (-) outside of a do block?
b f (- a)
What are the semantics of
do b f (- a)
where does the evaluation of a get lifted to?
Given:
if (- a) then f (- b) else g (- c)
Do b and c both get monadic bindings regardless of a?
if (-
rewrite *p++=*q++ in haskell?
it's one of C idioms. probably, you don't have enough C experience to
understand it :)
Maybe, but how can *you* understand it, when the standard is vague about it?
It could be
A: *p=*q; p+=1; q+=1;
B: *p=*q; q+=1; p+=1;
C: tp=p; tq=q; p+=1; q+=1; *tp=*tq;
rewrite *p++=*q++ in haskell?
MR I always reject such codes when produced by my students. It is just
MR unreadable. I even do not understand what you are trying to achieve.
MR However, gcc seems it to compile to something like
MR *p = *(p+1) ; *q = *(q+1)
MR But for what is the '=' good for?
Hello Mirko,
Friday, August 3, 2007, 3:32:57 PM, you wrote:
rewrite *p++=*q++ in haskell?
I always reject such codes when produced by my students. It is just
unreadable.
it's one of C idioms. probably, you don't have enough C experience to
understand it :)
So rewriting it in Haskell (of
rewrite *p++=*q++ in haskell?
*p = *(p+1) ; *q = *(q+1)
If that's true then GCC has gone insane, because they are completely different.
Of course you are right, I just observed at the wrong place..., sorry
for that.
Though, as any C programmer knows, you really should be using
Neil Mitchell [EMAIL PROTECTED] wrote:
We started with 4 suggestions, and as far as I can tell, are
left with only one (- ...).
For the record, my comments on (- ...) where not objections, but
merely thoughts out loud, and I could certainly see myself using
that syntax in a day to day basis.
| Couldn't this be best done with McBride and Patterson's Applicative
| idiom notation?
|
| So the above would become
|
| [[l m (pure x) n (pure y)]] (or something like that)
|
| It would have the advantage of being usable with any Applicative, not
| just Monads.
Does anyone have a pointer
Bryan O'Sullivan bos at serpentine.com writes:
Pardon me while I veer off-topic, but you could also use Pandoc to do
this. No forking required.
http://sophos.berkeley.edu/macfarlane/pandoc/
What I'm doing is neither Haskell nor Markdown specific; I allow any HTML
markup filter that plays
Simon Peyton-Jones wrote:
Does anyone have a pointer to a stand-alone description of full-scale idiom
notation.
http://www.haskell.org/haskellwiki/Idiom_brackets
I think I've seen something more detailed but I don't know if it was in
one of Conor's papers, or if it was personal
to illustrate why some of us are concerned about this extension,
a few examples might help. consider:
f (g (- mx))
does this stand for
(a) mx = \x- f (g x)
(b) f (mx = \x- (g x))
(c) none of the above, because there's no do
(d) something else entirely
if (a/b), does the
apfelmus [EMAIL PROTECTED] wrote:
I still think that this syntax extension has profound impact and is a
bad idea. Simon's and Neill's use case was the dreaded name-supply monad
where the order of effects really doesn't matter up to alpha-conversion.
The objection to that use case is that
Jules Bean wrote:
do
a - m
b - n
l a x b y
becomes
l (- m) x (- n) y
...with, I suppose, left-to-right evaluation order. This looks 'almost
like substitution' which is the goal.
Having read the thread SPJ pointed to, I should point out that using a
mixture of Applicative and Monad
Neil Mitchell [EMAIL PROTECTED] wrote:
Thinking on the semantic issue for the moment:
Can you use (-) outside of a do block?
Good question, but my answer is a strong no! Syntactic sugar for monads
has always been tied to do blocks; promoting it outside of contexts
where do announces that
Dear devs,
is it possible to create a FCGI server that listens to a specific port using
the Haskell FCGI library?
The front end web server would then communicate with this back end FCGI
server through this port.
A small example would be really appreciated.
thanks,
George.
--
| f (g (- mx))
|
| does this stand for
|
| (a) mx = \x- f (g x)
| (b) f (mx = \x- (g x))
| (c) none of the above, because there's no do
| (d) something else entirely
For me the answer is definitely (c). Furthermore there must be no lambda
between the monadic splice and the
On 03/08/07, Bryan O'Sullivan [EMAIL PROTECTED] wrote:
Pardon me while I veer off-topic, but you could also use Pandoc to do
this. No forking required.
http://sophos.berkeley.edu/macfarlane/pandoc/
I'll add that to the list of things that must be done. That list
seems, necessarily, to be
Hi
Can you combine let and do?
do let x = (- a)
f x
Right. In effect, as a matter of fact, the notation
x - a
would become equivalent to
let x = (- a)
Hmm, interesting. Consider:
let x = 12
let x = (- x)
Currently, in let x = ... the x is in scope on the right hand
Is there a class property of the Control.Arrow class that represents the
evaluatation of an arrow:
eval :: (Arrow a)=a b c-b-c
I am writing some higher order code that I would like to work with either
functions or partial functions (implemented as balanced binary search trees)
and don't
Dan Piponi wrote:
On 8/3/07, Jules Bean [EMAIL PROTECTED] wrote:
do
a - m
b - n
l a x b y
becomes
l (- m) x (- n) y
Couldn't this be best done with McBride and Patterson's Applicative
idiom notation?
So the above would become
[[l m (pure x) n (pure y)]] (or something like
Hello apfelmus,
Friday, August 3, 2007, 12:05:22 PM, you wrote:
I still think that this syntax extension has profound impact and is a
bad idea.
can you please rewrite *p++=*q++ in haskell?
--
Best regards,
Bulatmailto:[EMAIL PROTECTED]
rewrite *p++=*q++ in haskell?
I always reject such codes when produced by my students. It is just
unreadable. I even do not understand what you are trying to achieve.
However, gcc seems it to compile to something like
*p = *(p+1) ; *q = *(q+1)
But for what is the '=' good for?
So
* Bulat Ziganshin wrote:
Hello apfelmus,
I still think that this syntax extension has profound impact and is a
bad idea.
can you please rewrite *p++=*q++ in haskell?
p = q
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
rewrite *p++=*q++ in haskell?
MR I always reject such codes when produced by my students.
I don't think it's a good idea to reject working code.
MR I even do not understand what you are trying to achieve.
Well, that just means that your students are a bit smarter than you.
And I'd like to
Simon Peyton-Jones [EMAIL PROTECTED] wrote:
Furthermore there must be no lambda between the monadic splice and the do.
I'm curious about this.
One could sugar:
do tax - getTax
return $ map (\price - price * (1 + tax)) bill
into:
do return $ map (\price - price * (1 + (-
Haskellians,
i am delighted to see vigorous exchange that actually resulted in change of
positions. i confess i was going to give up, but glad others stepped into
the breach. This is yet another indication of what an unusual community this
is.
Best wishes,
--greg
Date: Fri, 3 Aug 2007 13:43:32
On 03/08/07, apfelmus [EMAIL PROTECTED] wrote:
Chris Smith wrote:
Also, I got so frustrated that I ended up abandoning some code
recently because STM is, in the end, so darn hard to use as a
result of this issue. I'd love to see this solved, and I'm quite
eager to do it.
This sounds
Claus Reinke [EMAIL PROTECTED] wrote:
to illustrate why some of us are concerned about this extension,
a few examples might help.
Claus, I've been saving your message in order to respond to it when I
have the time to look over it in detail. I don't think there will be
forthcoming answers
On 8/3/07, Simon Peyton-Jones [EMAIL PROTECTED] wrote:
| Couldn't this be best done with McBride and Patterson's Applicative
| idiom notation?
Does anyone have a pointer to a stand-alone description of full-scale idiom
notation.
S
The full paper is here:
Hi
do { do { a; b}; c }
is still the same as
do { a; do { b; c } }
yes? no? perhaps? sometimes? how long did it take you?
I'm not entirely sure I understand the point here. The monad laws are
defined in terms of = and return. They have never had anything to do
with do,
mytransaction = do {
x0 - readTVar xvar0
x1 - readTVar xvar1
:
xn - readTVar xvarn
return $ foo x0 x1 .. xn
}
Versus
mytransaction = return $ foo $(readTVar xvar0) $(readTVar xvar1) ..
$(readTVar xvarn)
ah, a concrete example. but isn't that the typical use case for ap?
mytransaction =
On Fri, Aug 03, 2007 at 02:41:05PM +0200, Mirko Rahn wrote:
rewrite *p++=*q++ in haskell?
it's one of C idioms. probably, you don't have enough C experience to
understand it :)
Maybe, but how can *you* understand it, when the standard is vague about it?
It could be
A: *p=*q; p+=1;
On 8/3/07, Neil Mitchell [EMAIL PROTECTED] wrote:
This is how I understand it:
Can you use (-) outside of a do block?
b f (- a)
b do { ta -a; f ta }
or
b a = \ta - f ta
What are the semantics of
do b f (- a)
do b a = \ta - f ta
Given:
if (- a) then f (- b) else g (- c)
a = \ta -
Sorry for the double post, I posted with the wrong email address and
haskell-cafe rejected it.
On 8/3/07, Neil Mitchell [EMAIL PROTECTED] wrote:
Right. In effect, as a matter of fact, the notation
x - a
would become equivalent to
let x = (- a)
Hmm, interesting. Consider:
Neil Mitchell [EMAIL PROTECTED] wrote:
Right. In effect, as a matter of fact, the notation
x - a
would become equivalent to
let x = (- a)
Hmm, interesting. Consider:
let x = 12
let x = (- x)
Okay, so the desugaring process wouldn't terminate in that case! One
could
On 8/1/07, Jeff Polakow [EMAIL PROTECTED] wrote:
But what about an actual object of type 'IO
Int', say?
I usually describe the type resulting from applying a monad a computation.
Same here. If m is a monad, then m a is a computation. (Of course,
computations are first-class values, like
Hello Claus,
Friday, August 3, 2007, 8:12:13 PM, you wrote:
f (g (- mx))
does this stand for
(a) mx = \x- f (g x)
this variant. just like any imperative language (are you used any?).
idea of FORmula TRANslator is old and widely used enough to prevent
such questions
--
Best
Hello Chris,
Friday, August 3, 2007, 8:09:49 PM, you wrote:
foo = do b' - readTVar b
c' - readTVar c
d' - readTvar d
return (b' + c' / d')
It's true that order of effects *can* be important in monads like IO and
STM. It's also true, though, that probably 50% of
david48 [EMAIL PROTECTED] wrote:
On 8/3/07, Neil Mitchell [EMAIL PROTECTED] wrote:
Hmm, interesting. Consider:
let x = 12
let x = (- x)
Wouldn't that be forbidden ?
I'd expect the x in ( - x ) have to be of type m a.
Yes, unless of course you did:
instance (Monad m, Num n)
On 8/3/07, Chris Smith [EMAIL PROTECTED] wrote:
Neil Mitchell [EMAIL PROTECTED] wrote:
I'm not convinced either, a nice concrete example would let people
ponder this a bit more.
I tried to provide something in my response to Simon. Here it is again:
One could sugar:
do tax -
Chris Smith wrote:
I'm primarily interested in the two cases where one simply has no
choice about the use of monads: and those are IO and STM.
No, this is not purely functional programming then; but it has
some very compelling advantages to Haskell's implementation of
these, that I'm afraid
Jules Bean wrote:
do
a - m
b - n
l a x b y
becomes
l (- m) x (- n) y
...with, I suppose, left-to-right evaluation order. This looks 'almost
like substitution' which is the goal.
Almost?
So then (flip f) (- m) (- n) does *not* equal f (- n) (- m) ?
There goes any hope of my
I'll dig for it later if you like. The essence of the matter was a
bunch of functions that looked something like this:
foo = do b' - readTVar b
c' - readTVar c
d' - readTvar d
return (b' + c' / d')
In other words, a string of readTVar statements, followed by one
Hi
let x = 12
let x = (- x)
Okay, so the desugaring process wouldn't terminate in that case! One
could either: (a) try to retain the equivalence in theory, but make it
illegal to use x in a monadic subexpression when defining x; (b) we
could abandon my claim that they are equivalent.
Bulat Ziganshin [EMAIL PROTECTED] wrote:
assembler :) it's what our opponents propose - let's Haskell be like
assembler with its simple and concise execution model :)
I feel bad that portions of this thread have gotten a bit ugly. I don't
have any opponents, so far as I know. I am just
Hi
if you write :
let x = (-a):x
is it possible that is desugars into :
temp -a
let x = temp:x
that would'nt work ?
That would work, since 'a' doesn't refer to 'x'. I can't think of a
real example where it becomes an issue, but the scope within 'a' has
changed.
Also :
do case x of
On 8/3/07, Neil Mitchell [EMAIL PROTECTED] wrote:
temp - a
let x = temp
if you write :
let x = (-a):x
is it possible that is desugars into :
temp -a
let x = temp:x
that would'nt work ?
I realize I may be asking dumb questions but being dumb never harmed
anyone so :)
Also :
do case x of
Will be pushing out the refactored happs repos in the next 2 weeks. The
gist is:
* HAppS.IxSet provides efficient query operations on haskell sets.
* HAppS.State provides ACID, replicated, and soon sharded access to your
application state.
* HAppS.Network will provide server side
Hi
do case x of
[] - return 1
(y:ys) - g y = \temp - f temp
See the rule about always binding to the previous line of a do block.
This case then violates that.
I assumed that the example was equivalent to :
do case x of
[] - return 1
(y:ys)
So I stared at the documentation in Control-Concurrent, learned about
finally and MVar variables, and crossed the genes from the suggestions here
to come up with
runCommand :: String - String - IO (String,Bool)
runCommand cmd input = do
(inp,out,err,pid) - runInteractiveCommand
Have you looked at the HAppS.DBMS.IxSet? It gives you a type safe way
to query indexed collections.
-Alex-
Isto Aho wrote:
Hi,
I'd like to store small matrices into a db. Number of rows and columns
may vary in a way not
known in advance. One might use a relation (matrixId, col, row, value)
On Friday 03 August 2007, Sebastian Sylvan wrote:
On 03/08/07, Claus Reinke [EMAIL PROTECTED] wrote:
ah, a concrete example. but isn't that the typical use case for ap?
mytransaction = foo `liftM` r xvar0 `ap` r xvar1 ..
where r = readTVar
I really find it difficult to articulate
much snipping
Also, note, if you use the operators in Control.Applicative, then:
return $ foo $(bar1) $(bar2) $(bar3) ...
can be:
return foo * bar1 * bar2 * bar3 ...
or:
foo $ bar1 * bar2 * bar3
I don't (personally) see how that's any more cryptic than placing brackets
On Fri, Aug 03, 2007 at 05:48:18PM -0700, Brandon Michael Moore wrote:
General purpose brackets are overkill here. I would really like a simple
monadic case. What's so bad about
caseM mexpr of
p1 - branch1
p2 - branch2
(mexpr = \e - case e of
p1 - branch1
p2 - branch2)
On 8/3/07, Chris Smith [EMAIL PROTECTED] wrote:
Yes, unless of course you did:
instance (Monad m, Num n) = Num (m n)
or some such nonsense. :)
I decided to take this as a dare - at first I thought it would be easy
to declare (Monad m, Num n) = m n to be an instance of Num (just lift
or
Antoine Latter wrote:
On 8/3/07, Chris Smith [EMAIL PROTECTED] wrote:
Yes, unless of course you did:
instance (Monad m, Num n) = Num (m n)
or some such nonsense. :)
I decided to take this as a dare - at first I thought it would be easy
to declare (Monad m, Num n) = m n to be an
Hello apfelmus,
Saturday, August 4, 2007, 12:22:53 AM, you wrote:
avoid the small layer of imperative code, of course. But the more you
treat imperative code as somewhat pure, the greater the danger that the
purely functional logic will be buried inside a mess of imperative code.
In other
Hello Claus,
Friday, August 3, 2007, 7:29:32 PM, you wrote:
how about *Object.File.Line.CurPtr++ = *AnotherObject.File.Line.CurPtr++ ?
;)
what's the difference?-)
let p = Object.File.Line.CurPtr
let q = AnotherObject.File.Line.CurPtr
do { w p = r q; i p; i q }
back to the
66 matches
Mail list logo