<div dir="ltr">Maybe one of the numeric literal extensions will help. The root problem is that, without parentheses or one of the extensions, this ends up defining something different than you intended: (-) with `encryptionResult` as a local binding.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 14, 2019 at 11:55 PM Vanessa McHale <<a href="mailto:vanessa.mchale@iohk.io">vanessa.mchale@iohk.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I have the following program:<br>
<br>
module Bug ( encryptionResult ) where<br>
<br>
data EncryptionResult = HasEncryption<br>
| EncryptionUnknown<br>
<br>
encryptionResult :: Int -> EncryptionResult<br>
encryptionResult 1 = HasEncryption<br>
encryptionResult -1 = EncryptionUnknown<br>
encryptionResult _ = error "Internal error."<br>
<br>
When I try to compile it with GHC I get<br>
<br>
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )<br>
<br>
Bug.hs:9:1: error:<br>
Multiple declarations of ‘encryptionResult’<br>
Declared at: Bug.hs:7:1<br>
Bug.hs:9:1<br>
|<br>
9 | encryptionResult _ = error "Internal error."<br>
| ^^^^^^^^^^^^^^^^<br>
<br>
I can replicate this in Hugs, viz.<br>
<br>
ERROR "Bug.hs":7 - "encryptionResult" multiply defined<br>
<br>
However, everything compiles fine when I write<br>
<br>
module Bug ( encryptionResult ) where<br>
<br>
data EncryptionResult = HasEncryption<br>
| EncryptionUnknown<br>
<br>
encryptionResult :: Int -> EncryptionResult<br>
encryptionResult 1 = HasEncryption<br>
encryptionResult -1 = EncryptionUnknown<br>
<br>
or<br>
<br>
module Bug ( encryptionResult ) where<br>
<br>
data EncryptionResult = HasEncryption<br>
| EncryptionUnknown<br>
<br>
encryptionResult :: Int -> EncryptionResult<br>
encryptionResult 1 = HasEncryption<br>
encryptionResult 0 = EncryptionUnknown<br>
encryptionResult _ = error "Internal error."<br>
<br>
Am I doing something obviously screwy? This seems like a pretty annoying<br>
feature on the language (to the point where I assumed it was a GHC bug<br>
until I got the same behavior with Hugs) and I can't figure out why it<br>
exists.<br>
<br>
Cheers,<br>
Vanessa McHale<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>brandon s allbery kf8nh</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a></div></div></div></div></div>