Skip to content

Commit 7d5024e

Browse files
committed
fix: add type signatures for zigZag and zagZig functions in Integer instance
1 parent e6b3ec9 commit 7d5024e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Data/ZigZag.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{-# LANGUAGE FunctionalDependencies #-}
33
{-# LANGUAGE MultiParamTypeClasses #-}
44
{-# LANGUAGE ScopedTypeVariables #-}
5+
{-# LANGUAGE InstanceSigs #-}
56

67
-- |<https://gist.github.com/mfuerstenau/ba870a29e16536fdbaba ZigZag encoding> of signed integrals.
78
module Data.ZigZag (ZigZag(..)) where
@@ -119,9 +120,11 @@ instance ZigZag Int32 Word32
119120
instance ZigZag Int64 Word64
120121

121122
instance ZigZag Integer Natural where
123+
zigZag :: Integer -> Natural
122124
zigZag x
123125
| x >= 0 = fromIntegral $ x `shiftL` 1
124126
| otherwise = fromIntegral $ negate (x `shiftL` 1) - 1
125127

128+
zagZig :: Natural -> Integer
126129
zagZig u = let s = fromIntegral u
127130
in ((s `shiftR` 1) `xor` negate (s .&. 1))

0 commit comments

Comments
 (0)