diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -28,7 +28,7 @@
 import qualified Data.Map as Map
 import           Numeric (showHex)
 import           System.Directory (createDirectoryIfMissing)
-import           Text.Regex.Applicative
+import           Text.Regex.Applicative (RE, match, psym, string, sym)
 import           Text.Regex.Applicative.Common (hexadecimal)
 import           Util hiding (intercalate)
 
@@ -58,17 +58,16 @@
 ppRangeProps moduleName props = unlines $
   [ asum ["module ", moduleName, " (", intercalate ", " (("is" ++) <$> names), ") where"]
   , "import Data.Word"
-  , "import Foreign.C.Types"
   , "import Foreign.Ptr"
   , intercalate ", " (("is" ++) <$> names) ++ " :: Char -> Bool"
-  , "foreign import ccall unsafe \"range_search\" c_range_search :: Word32 -> Ptr () -> Word -> CInt"
+  , "foreign import ccall unsafe \"range_search\" c_range_search :: Word32 -> Ptr Word64 -> Word -> Ptr Word64"
   ] ++ toList (Map.mapWithKey genCode1 props)
   where
     names = Map.keys props
     genCode1 name ranges = (unlines . fmap asum)
-      [ ["is", name, " x = 0 /= c_range_search ((fromIntegral . fromEnum) x) data", name, " ", show (length ranges)]
+      [ ["is", name, " = \\ x -> nullPtr /= c_range_search ((fromIntegral . fromEnum) x) data", name, " ", show (length ranges)]
       , ["{-# INLINE is", name, " #-}"]
-      , ["foreign import ccall unsafe \"&", name, "\" data", name, " :: Ptr ()"]
+      , ["foreign import ccall unsafe \"&", name, "\" data", name, " :: Ptr Word64"]
       ]
 
 doRangeProps :: RangeProps Char -> [Char]
@@ -89,7 +88,7 @@
     generate1 :: (Char, Char, Bool) -> [Char]
     generate1 (x, y, isC)
       | abs d > 3 = error ("Difference too great: " ++ show (y, x))
-      | otherwise = "0x" ++ showHex (fromEnum x .|. shiftL (d .&. 7) 28 .|. bool 0 (bit 31) isC) ""
+      | otherwise = "0x" ++ showHex (fromEnum x .|. shiftL (d .&. 7) 29 .|. bool 0 (bit 28) isC) ""
       where d = fromEnum y - fromEnum x
 
     lineRE :: RE Char (Char, Char, Bool)
diff --git a/src/Data/Char/Properties/BidiBrackets.hs b/src/Data/Char/Properties/BidiBrackets.hs
--- a/src/Data/Char/Properties/BidiBrackets.hs
+++ b/src/Data/Char/Properties/BidiBrackets.hs
@@ -12,8 +12,8 @@
   deriving (Eq, Read, Show, Enum, Bounded)
 
 paired :: Char -> Maybe (Char, Type)
-paired x = (toEnum $ fromEnum x + d, bool O C $ testBit x' 31) <$ guard (d /= 0)
-  where
-    x' = c_bidi_brackets (fromIntegral (fromEnum x))
-    d = fromIntegral $ shiftR (fromIntegral (shiftL x' 1) :: Int32) 29
+paired = \ x ->
+    let x' = c_bidi_brackets (fromIntegral (fromEnum x))
+        d = fromEnum $ shiftR (fromIntegral x' :: Int32) 29
+    in (toEnum $ fromEnum x + d, bool O C $ testBit x' 28) <$ guard (d /= 0)
 {-# INLINE paired #-}
diff --git a/src/cbits/BidiBrackets.c b/src/cbits/BidiBrackets.c
--- a/src/cbits/BidiBrackets.c
+++ b/src/cbits/BidiBrackets.c
@@ -1,18 +1,17 @@
 #include <stdint.h>
-#include <stdio.h>
 #include "BidiBrackets.h"
 
 uint32_t bidi_brackets(uint32_t x) {
-    long length = sizeof(BidiBrackets) / sizeof(BidiBrackets[0]);
+    unsigned long length = sizeof(BidiBrackets) / sizeof(BidiBrackets[0]);
     const uint32_t *try, *base;
     base = BidiBrackets;
     while (length > 0) {
         try = &base[length/2];
-        uint32_t y = try[0] & 0x1FFFFF;
+        uint32_t r = try[0], y = r & 0x1FFFFF;
         switch ((x > y) - (x < y)) {
         case -1: length /= 2; break;
         case  1: base = try + 1; length -= length/2+1; break;
-        default: return try[0];
+        default: return r;
         }
     }
     return x;
diff --git a/src/cbits/range_search.c b/src/cbits/range_search.c
--- a/src/cbits/range_search.c
+++ b/src/cbits/range_search.c
@@ -5,7 +5,7 @@
     uint64_t c;
 } RangeU32;
 
-const uint64_t *range_search(uint32_t x, const uint64_t *base, long length) {
+const uint64_t *range_search(uint32_t x, const uint64_t *base, unsigned long length) {
     const uint64_t *try;
     while (length > 0) {
         try = &base[length/2];
diff --git a/ucd.cabal b/ucd.cabal
--- a/ucd.cabal
+++ b/ucd.cabal
@@ -1,6 +1,6 @@
-cabal-version:       2.2
+cabal-version:       3.0
 name:                ucd
-version:             0.0.1.3
+version:             0.0.1.4
 synopsis:            Unicode Character Database — Predicates on characters specified by Unicode
 --description:         
 homepage:            https://github.com/strake/ucd.hs
@@ -23,8 +23,7 @@
                      GHC == 8.8.1
 
 common c
-  build-depends:       base ^>= 4.11 || ^>= 4.12 || ^>= 4.13
-                     , util ^>= 0.1.14
+  build-depends:       base ^>= {4.11, 4.12, 4.13}
   ghc-options:         -Wall
                        -Wcompat
                        -Wredundant-constraints
@@ -87,8 +86,8 @@
 
 custom-setup
   setup-depends:       Cabal ^>= 3.0
-                     , base ^>= 4.11 || ^>= 4.12 || ^>= 4.13
-                     , containers ^>= 0.5 || ^>= 0.6
+                     , base ^>= {4.11, 4.12, 4.13}
+                     , containers ^>= {0.5, 0.6}
                      , directory ^>= 1.3
                      , regex-applicative ^>= 0.3.3
                      , util ^>= 0.1.14
