Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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. Overload ^ (trent shipley)
2. Re: Overload ^ (Paul)
----------------------------------------------------------------------
Message: 1
Date: Fri, 2 Mar 2018 23:24:28 -0700
From: trent shipley <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Overload ^
Message-ID:
<CAEFLyb+Jff8UuQ3RMj+n17WuvAnwaQGdJPXyG=hmdumbdzd...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
{-
I want to override Prelude.^ (as an academic exercise).
Can it be done? How?
Trent
-}
(^) :: Int -> Int -> Int
m ^ 0 = 1
m ^ n = m * (m ^ (n-1))
{-
Hutton, Graham. Programming in Haskell (p. 263). Cambridge University
Press. Kindle Edition. 2016.
-}
{-
Result
[1 of 1] Compiling Main ( ex6_3b.hs, interpreted )
ex6_3b.hs:3:16: error:
Ambiguous occurrence ‘^’
It could refer to either ‘Prelude.^’,
imported from ‘Prelude’ at ex6_3b.hs:1:1
(and originally defined in ‘GHC.Real’)
or ‘Main.^’, defined at ex6_3b.hs:2:3
|
3 | m ^ n = m * (m ^ (n-1)) | ^
Failed, no modules loaded.
-}
-- So I try
(^) :: Int -> Int -> Int
m Main.^ 0 = 1
m Main.^ n = m * (m Main.^ (n-1))
{-
Result
Prelude> :reload
ex6_3b.hs:2:3: error: Qualified name in binding position: Main.^
|
2 | m Main.^ 0 = 1 | ^^^^^^
[1 of 1] Compiling Main ( ex6_3b.hs, interpreted )
Failed, no modules loaded.
-}
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20180302/4b30bc68/attachment-0001.html>
------------------------------
Message: 2
Date: Sat, 3 Mar 2018 08:33:11 +0200
From: Paul <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of
primarilybeginner-level topics related to Haskell
<[email protected]>
Subject: Re: [Haskell-beginners] Overload ^
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
import Prelude hiding ((^))
See here: https://wiki.haskell.org/Import
Best regards,
Paul
От: trent shipley
Отправлено: 3 марта 2018 г. в 8:25
Кому: [email protected]
Тема: [Haskell-beginners] Overload ^
{-
I want to override Prelude.^ (as an academic exercise).
Can it be done? How?
Trent
-}
(^) :: Int -> Int -> Int
m ^ 0 = 1
m ^ n = m * (m ^ (n-1))
{-
Hutton, Graham. Programming in Haskell (p. 263). Cambridge University Press.
Kindle Edition. 2016.
-}
{-
Result
[1 of 1] Compiling Main ( ex6_3b.hs, interpreted )
ex6_3b.hs:3:16: error:
Ambiguous occurrence ‘^’
It could refer to either ‘Prelude.^’,
imported from ‘Prelude’ at ex6_3b.hs:1:1
(and originally defined in ‘GHC.Real’)
or ‘Main.^’, defined at ex6_3b.hs:2:3
|
3 | m ^ n = m * (m ^ (n-1)) | ^
Failed, no modules loaded.
-}
-- So I try
(^) :: Int -> Int -> Int
m Main.^ 0 = 1
m Main.^ n = m * (m Main.^ (n-1))
{-
Result
Prelude> :reload
ex6_3b.hs:2:3: error: Qualified name in binding position: Main.^
|
2 | m Main.^ 0 = 1 | ^^^^^^
[1 of 1] Compiling Main ( ex6_3b.hs, interpreted )
Failed, no modules loaded.
-}
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20180303/e4e6fa88/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 117, Issue 1
*****************************************