Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build with -integer-gmp #7

Merged
merged 2 commits into from
Nov 20, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Data/Hashabler/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ import GHC.Integer.GMP.Internals (BigNat(BN#))
#if MIN_VERSION_base(4,8,0)
import Data.Void (Void, absurd)
import GHC.Natural (Natural(..))
# ifdef MIN_VERSION_integer_gmp
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import was unused with the integer-gmp flag disabled.

import GHC.Exts (Word(..))
# endif
#endif

-- For WORD_SIZE_IN_BITS constant:
Expand Down Expand Up @@ -616,7 +618,8 @@ hash32BigNatByteArrayBytes h numLimbs ba =
instance Hashable Natural where
{-# INLINE hash #-}
hash h nat = case nat of
# if defined (MIN_VERSION_integer_gmp) && MIN_VERSION_integer_gmp(1,0,0)
# if defined (MIN_VERSION_integer_gmp)
# if MIN_VERSION_integer_gmp(1,0,0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to separate these 2 checks. Combining with && results in an error:

if defined X && X(1,0,0)

Consider the case where X is indeed not defined:

if defined && (1,0,0)

No you will get some error complaining about terniary operators.

-- For Word-size natural
(NatS# wd#) -> mixConstructor 0 $
# if WORD_SIZE_IN_BITS == 32
Expand All @@ -626,9 +629,13 @@ instance Hashable Natural where
# endif
-- Else using a BigNat (which instance calls required mixConstructor):
(NatJ# bn) -> hash h bn
# else
-- Natural represented with non-negative Integer:
n -> hash h $ toInteger n
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recommended interface to Natural is Numeric.Natural which does not expose a constructor. Without the integer-gmp flag I got an error because the Natural constructor was not in scope. So I used the Integral interface.

# endif
# else
-- Natural represented with non-negative Integer:
(Natural n) -> hash h n
n -> hash h $ toInteger n
# endif

-- This is the instance in void-0.7:
Expand Down