Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Can't compile Diagrams tutorial example (Roger Mason)
2. Re: Can't compile Diagrams tutorial example (Roger Mason)
3. Feature request: anonymous arguments (Julius Gedvilas)
4. Re: Feature request: anonymous arguments (Lyndon Maydwell)
5. Re: Feature request: anonymous arguments (Karl Voelker)
6. Re: Feature request: anonymous arguments (Julius Gedvilas)
----------------------------------------------------------------------
Message: 1
Date: Fri, 29 Aug 2014 17:07:39 -0230
From: Roger Mason <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Can't compile Diagrams tutorial example
Message-ID: <[email protected]>
Content-Type: text/plain
Hello,
I have the following code from the Diagrams package tutorial:
> {-# LANGUAGE NoMonomorphismRestriction #-}
>
> import Diagrams.Prelude
> import Diagrams.Backend.SVG.CmdLine
> main = mainWith (example :: Diagram B R2)
> example = circle 1 # fc blue
> # lw veryThick
> # lc purple
> # dashing [0.2,0.05] 0
I get the following error on compilation using GHC 7.6.3:
ghc --make DiagramsTutorial-2.lhs
[1 of 1] Compiling Main ( DiagramsTutorial-2.lhs,
DiagramsTutorial-2.o )
DiagramsTutorial-2.lhs:10:33:
Could not deduce (Fractional (Measure R2))
arising from the literal `0.2'
from the context (TrailLike b,
Transformable b,
HasStyle b,
V b ~ R2)
bound by the inferred type of
example :: (TrailLike b, Transformable b, HasStyle b, V b ~ R2)
=>
b
at DiagramsTutorial-2.lhs:(7,3)-(10,43)
Possible fix:
add an instance declaration for (Fractional (Measure R2))
In the expression: 0.2
In the first argument of `dashing', namely `[0.2, 0.05]'
In the second argument of `(#)', namely `dashing [0.2, 0.05] 0'
DiagramsTutorial-2.lhs:10:43:
Could not deduce (Num (Measure R2)) arising from the literal `0'
from the context (TrailLike b,
Transformable b,
HasStyle b,
V b ~ R2)
bound by the inferred type of
example :: (TrailLike b, Transformable b, HasStyle b, V b ~ R2)
=>
b
at DiagramsTutorial-2.lhs:(7,3)-(10,43)
Possible fix: add an instance declaration for (Num (Measure R2))
In the second argument of `dashing', namely `0'
In the second argument of `(#)', namely `dashing [0.2, 0.05] 0'
In the expression:
circle 1 # fc blue # lw veryThick # lc purple
# dashing [0.2, 0.05] 0
Thanks for any help.
Roger
------------------------------
Message: 2
Date: Fri, 29 Aug 2014 17:34:42 -0230
From: Roger Mason <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Can't compile Diagrams tutorial
example
Message-ID: <[email protected]>
Content-Type: text/plain
Hello,
Roger Mason <[email protected]> writes:
> I have the following code from the Diagrams package tutorial:
>
>> {-# LANGUAGE NoMonomorphismRestriction #-}
>>
>> import Diagrams.Prelude
>> import Diagrams.Backend.SVG.CmdLine
>
>> main = mainWith (example :: Diagram B R2)
>> example = circle 1 # fc blue
>> # lw veryThick
>> # lc purple
>> # dashing [0.2,0.05] 0
>
> I get the following error on compilation using GHC 7.6.3:
Found the problem:
# dashing [0.2,0.05] 0
should read
# dashingG [0.2,0.05] 0
Sorry for the noise.
Roger
------------------------------
Message: 3
Date: Sat, 30 Aug 2014 10:21:22 +0300
From: Julius Gedvilas <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Feature request: anonymous arguments
Message-ID:
<CAOwifxJEi8X0vQ17rUdSB27AvjPe4fmJK0OWR+=8=p++ksw...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Anonymous argument (AA) is an argument without a name.
w/o AA:
func :: a -> a -> a -> a
func aa0 aa1 aa2 = aa0 `op` aa1 `op` aa2
\aa0 aa1 aa2 -> aa0 `op` aa1 `op` aa2
w/ AA:
func :: a -> a -> a -> a
func = \0 `op` \1 `op` \2
\-> \0 `op` \1 `op` \2
AA syntax: '\n', where n is one of the (0 1 2 3 4 5 6 7 8 9). 'n'
corresponds to the position of a parameter.
I think a language shouldn't force you to invent names for things that are
used only once, same philosophy as with an anonymous function.
Is this feature needed? Does something like this already exist?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140830/45f1ab4a/attachment-0001.html>
------------------------------
Message: 4
Date: Sat, 30 Aug 2014 18:08:44 +1000
From: Lyndon Maydwell <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Feature request: anonymous arguments
Message-ID:
<CAM5QZtwZLOu=qos5fddjahevvgixthpgoadvlestj__toid...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Often this is sidestepped by using partial application since most functions
are curried, although, I can still see this being useful.
Ex.
f a b c = a + b - c
g = ((-) .) . (+)
Clearly this isn't as intuitive a definition, but it does remove the
argument names.
I can't help but think that there must be some gnarly lens that solves
this, but I can't think of one :)
On Sat, Aug 30, 2014 at 5:21 PM, Julius Gedvilas <[email protected]> wrote:
> Anonymous argument (AA) is an argument without a name.
>
> w/o AA:
> func :: a -> a -> a -> a
> func aa0 aa1 aa2 = aa0 `op` aa1 `op` aa2
> \aa0 aa1 aa2 -> aa0 `op` aa1 `op` aa2
>
> w/ AA:
> func :: a -> a -> a -> a
> func = \0 `op` \1 `op` \2
> \-> \0 `op` \1 `op` \2
>
> AA syntax: '\n', where n is one of the (0 1 2 3 4 5 6 7 8 9). 'n'
> corresponds to the position of a parameter.
>
> I think a language shouldn't force you to invent names for things that are
> used only once, same philosophy as with an anonymous function.
>
> Is this feature needed? Does something like this already exist?
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140830/b27ee997/attachment-0001.html>
------------------------------
Message: 5
Date: Sat, 30 Aug 2014 01:31:09 -0700
From: Karl Voelker <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Feature request: anonymous arguments
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="us-ascii"
On Sat, Aug 30, 2014, at 12:21 AM, Julius Gedvilas wrote:
Anonymous argument (AA) is an argument without a name.
w/o AA:
func :: a -> a -> a -> a
func aa0 aa1 aa2 = aa0 `op` aa1 `op` aa2
\aa0 aa1 aa2 -> aa0 `op` aa1 `op` aa2
w/ AA:
func :: a -> a -> a -> a
func = \0 `op` \1 `op` \2
\-> \0 `op` \1 `op` \2
I think you have identified a real problem - sometimes, our
functions are so abstract that it is difficult to name the
parameters.
That said, I can think of a few cons to your proposal:
1. With lexically nested functions, you lose the ability to
refer to arguments of the outer function inside the inner
function if both functions use AA.
2. If you add a new parameter to a function anywhere other than
at the end, the effective "names" of all the following
parameters change. This is especially dangerous if many of the
parameters have the same types, since you could easily fail to
update some of the references to those arguments, and your
function would still
3. Reusing the backslash is not so simple. For example, "\0 ->
1" is a syntactically valid function in Haskell already.
4. It's not really any shorter than the alternative, which is
to just use very short variable names.
-Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140830/40e8e2b4/attachment-0001.html>
------------------------------
Message: 6
Date: Sat, 30 Aug 2014 12:32:10 +0300
From: Julius Gedvilas <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Feature request: anonymous arguments
Message-ID:
<CAOwifxJD3KEhjrhg2Y1mVQ2H5+rUguyL9reKx9ivx=omzpn...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
0. And more specific functions hopefully has more specific types, which
even more reduce a need for an extra name in a namespace.
1. I do not suggest to replace named arguments entirely. Anonymous
functions more so does not replace their named counterparts, but find their
place in a language (... in the logo (\);).
2. Adding parameters is a sub-process of a larger refactoring rather then
an "edit on the fly", or so do I think ...
3. Is it? *GHCi *does not recognize it.
4. It is shorter, but most important it does reduce number of useless
things (like one letter arg names), for benefit of both writer and reader
(and compiler).
On Sat, Aug 30, 2014 at 11:31 AM, Karl Voelker <[email protected]> wrote:
> On Sat, Aug 30, 2014, at 12:21 AM, Julius Gedvilas wrote:
>
> Anonymous argument (AA) is an argument without a name.
>
> w/o AA:
> func :: a -> a -> a -> a
> func aa0 aa1 aa2 = aa0 `op` aa1 `op` aa2
> \aa0 aa1 aa2 -> aa0 `op` aa1 `op` aa2
>
> w/ AA:
> func :: a -> a -> a -> a
> func = \0 `op` \1 `op` \2
> \-> \0 `op` \1 `op` \2
>
>
> I think you have identified a real problem - sometimes, our functions are
> so abstract that it is difficult to name the parameters.
>
> That said, I can think of a few cons to your proposal:
>
> 1. With lexically nested functions, you lose the ability to refer to
> arguments of the outer function inside the inner function if both functions
> use AA.
>
> 2. If you add a new parameter to a function anywhere other than at the
> end, the effective "names" of all the following parameters change. This is
> especially dangerous if many of the parameters have the same types, since
> you could easily fail to update some of the references to those arguments,
> and your function would still
>
> 3. Reusing the backslash is not so simple. For example, "\0 -> 1" is a
> syntactically valid function in Haskell already.
>
> 4. It's not really any shorter than the alternative, which is to just use
> very short variable names.
>
> -Karl
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140830/5dac41f5/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 74, Issue 30
*****************************************