
chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- pappus 100 [1..10] ] The above is not right, as the comprehension syntax doesn't see the input range buried in an argument. What's the right way to express pap1 = translate x y $ color red $ Circle r where (x,y,r) = pappus 100 1 where 1 is [1..10] and I get a list of results? (pap1 does work as expected) (1) how can the list comprehension syntax manage it, (2) what's the recommended way to express that (not necessarily via list comprehension syntax) ? —John

What Is the the type of your pappus function?
Am 22.04.2014 10:01 schrieb "John M. Dlugosz"
chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- pappus 100 [1..10] ]
The above is not right, as the comprehension syntax doesn't see the input range buried in an argument.
What's the right way to express
pap1 = translate x y $ color red $ Circle r where (x,y,r) = pappus 100 1
where 1 is [1..10] and I get a list of results? (pap1 does work as expected)
(1) how can the list comprehension syntax manage it, (2) what's the recommended way to express that (not necessarily via list comprehension syntax) ?
—John
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 4/22/2014 3:17 AM, Norbert Melzer wrote:
What Is the the type of your pappus function?
I've not specified a type sig, so it figures out some particular subdomain of numeric types. Whatever that is, it takes two numbers and returns a tuple of three floating-point numbers pappus r n = (x-0.5,y,rn) where blah= n**2*(1-r)**2+r x = (r*(1+r)) / (2*blah) y = (n*r*(1-r)) / blah rn = ((1-r)*r)/(2*blah)

On Tuesday 22 April 2014, 03:00:20, John M. Dlugosz wrote:
chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- pappus 100 [1..10] ]
The above is not right, as the comprehension syntax doesn't see the input range buried in an argument.
What's the right way to express
pap1 = translate x y $ color red $ Circle r where (x,y,r) = pappus 100 1
where 1 is [1..10] and I get a list of results? (pap1 does work as expected)
(1) how can the list comprehension syntax manage it,
If I guess your intentions right: chain1 = [ translate x y $ color red $ Circle r | (x,y,z) <- map (pappus 100) [1 .. 10]]

On 2014-04-22 10:00, John M. Dlugosz wrote:
chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- pappus 100 [1..10] ]
The above is not right, as the comprehension syntax doesn't see the input range buried in an argument.
[..]
(1) how can the list comprehension syntax manage it,
I suspect chain1 = [ translate x y $ color red $ Circle r | i <- [1..10], (x,y,r) <- pappus 100 i ] would be one way to do what you want. -- Frerich Raabe - raabe@froglogic.com www.froglogic.com - Multi-Platform GUI Testing

This one doesn't work, since pappus doesn't return a list
Am 22.04.2014 10:47 schrieb "Frerich Raabe"
On 2014-04-22 10:00, John M. Dlugosz wrote:
chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- pappus 100 [1..10] ]
The above is not right, as the comprehension syntax doesn't see the input range buried in an argument.
[..]
(1) how can the list comprehension syntax manage it,
I suspect
chain1 = [ translate x y $ color red $ Circle r | i <- [1..10], (x,y,r) <- pappus 100 i ]
would be one way to do what you want.
-- Frerich Raabe - raabe@froglogic.com www.froglogic.com - Multi-Platform GUI Testing _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 2014-04-22 10:49, Norbert Melzer wrote:
This one doesn't work, since pappus doesn't return a list
Ah, right, I forgot to adjust that part. How about chain1 = [ translate x y $ color red $ Circle r | i <- [1..10], let (x,y,r) = pappus 100 i ] ...though I'm not too fond of 'let' declarations in list comprehensions. -- Frerich Raabe - raabe@froglogic.com www.froglogic.com - Multi-Platform GUI Testing

That's why I think Daniel Fischers solution is the one.
Am 22.04.2014 10:59 schrieb "Frerich Raabe"
On 2014-04-22 10:49, Norbert Melzer wrote:
This one doesn't work, since pappus doesn't return a list
Ah, right, I forgot to adjust that part. How about
chain1 = [ translate x y $ color red $ Circle r | i <- [1..10], let (x,y,r) = pappus 100 i ]
...though I'm not too fond of 'let' declarations in list comprehensions.
-- Frerich Raabe - raabe@froglogic.com www.froglogic.com - Multi-Platform GUI Testing _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 4/22/2014 3:47 AM, Frerich Raabe wrote:
chain1 = [ translate x y $ color red $ Circle r | i <- [1..10], (x,y,r) <- pappus 100 i ]
would be one way to do what you want.
Yes, that's along the lines of what I was thinking — the 1..10 needs to be bound by itself to trigger the looping behavior, but didn't know how to then continue to generate (x,y,r). I thought the comma there was followed by a "guard", which constrains which values of i are taken or skipped. Ah, you have a <- there too. Hmm, but normally a second <- is another iteration that's done first/loops faster. So what's the syntax here? I must be getting things mixed up. —John

On Tue, Apr 22, 2014 at 3:00 PM, John M. Dlugosz
chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- pappus 100 [1..10] ]
What is translate? What is color? What is Circle? What is pappus? None of this is plain haskell. John, if you make your readers guess at undefined names, they'll go away and hangout somewhere friendlier! -- Kim-Ee

chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- [pappus 100 i
| i <- [1..10]] ]
better
chain1 = [transform $ pappus 100 i | i <- [1..10]]
where transform (x,y,r) = translate x y $ color red $ Circle r
2014-04-22 16:58 GMT+03:00 Kim-Ee Yeoh
On Tue, Apr 22, 2014 at 3:00 PM, John M. Dlugosz
wrote:
chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- pappus 100 [1..10] ]
What is translate? What is color? What is Circle? What is pappus?
None of this is plain haskell.
John, if you make your readers guess at undefined names, they'll go away and hangout somewhere friendlier!
-- Kim-Ee
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 4/22/2014 8:58 AM, Kim-Ee Yeoh wrote:
On Tue, Apr 22, 2014 at 3:00 PM, John M. Dlugosz
mailto:ngnr63q02@sneakemail.com> wrote: chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- pappus 100 [1..10] ]
What is translate? What is color? What is Circle? What is pappus?
None of this is plain haskell.
John, if you make your readers guess at undefined names, they'll go away and hangout somewhere friendlier!
-- Kim-Ee
Sorry — I thought showing a form that did work would be enough. The important part is that I have a input = map foo [0..10] and a bar (t1,t2,t3) = baz where baz returns a tuple, and the result of bar is the guts of another map. I didn't realize that using real words from a library instead of foo and bar was considered unfriendly!

Its considered unfriendly to not give important information. The minimum
information would have been the typesignature of every function you use.
Am 22.04.2014 20:38 schrieb "John M. Dlugosz"
On 4/22/2014 8:58 AM, Kim-Ee Yeoh wrote:
On Tue, Apr 22, 2014 at 3:00 PM, John M. Dlugosz < ngnr63q02@sneakemail.com mailto:ngnr63q02@sneakemail.com> wrote:
chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- pappus 100 [1..10] ]
What is translate? What is color? What is Circle? What is pappus?
None of this is plain haskell.
John, if you make your readers guess at undefined names, they'll go away and hangout somewhere friendlier!
-- Kim-Ee
Sorry — I thought showing a form that did work would be enough. The important part is that I have a input = map foo [0..10] and a bar (t1,t2,t3) = baz where baz returns a tuple, and the result of bar is the guts of another map.
I didn't realize that using real words from a library instead of foo and bar was considered unfriendly!
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

There is nothing wrong with using real functions from a library, but you
never said what library it was or even enough info to guess. Was it
diagrams? Gloss? FOV? Or something you wrote?
If the library doesn't matter, as it didn't in this case, you can just
specify the types like so
data Color = Color
translate :: Int -> Int -> ()
translate = undefined
color :: Color -> ()
color = undefined
red :: Color
red = undefined
so that at least your snippet compiles for others.
On Tue, Apr 22, 2014 at 2:37 PM, John M. Dlugosz
On 4/22/2014 8:58 AM, Kim-Ee Yeoh wrote:
On Tue, Apr 22, 2014 at 3:00 PM, John M. Dlugosz < ngnr63q02@sneakemail.com mailto:ngnr63q02@sneakemail.com> wrote:
chain1 = [ translate x y $ color red $ Circle r | (x,y,r) <- pappus 100 [1..10] ]
What is translate? What is color? What is Circle? What is pappus?
None of this is plain haskell.
John, if you make your readers guess at undefined names, they'll go away and hangout somewhere friendlier!
-- Kim-Ee
Sorry — I thought showing a form that did work would be enough. The important part is that I have a input = map foo [0..10] and a bar (t1,t2,t3) = baz where baz returns a tuple, and the result of bar is the guts of another map.
I didn't realize that using real words from a library instead of foo and bar was considered unfriendly!
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Wed, Apr 23, 2014 at 1:37 AM, John M. Dlugosz
I didn't realize that using real words from a library instead of foo and bar was considered unfriendly!
As everyone else has chimed in, signatures + succinct description is a minimum. Haskell usage is very, very diverse. You can't assume that everyone knows the specifics of a library you're using. E.g. graphics usage is scattered all over the place. Many (most?) haskellers hardly meddle with graphics in the slightest. -- Kim-Ee
participants (7)
-
Daniel Fischer
-
Daniel Hlynskyi
-
David McBride
-
Frerich Raabe
-
John M. Dlugosz
-
Kim-Ee Yeoh
-
Norbert Melzer