{-# LANGUAGE CPP, NoImplicitPrelude #-} #if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} #endif module Text.Read.Lex.Compat ( module Base , readBinP ) where import Text.Read.Lex as Base #if !(MIN_VERSION_base(4,16,0)) import Data.Char (ord) import Prelude import Text.ParserCombinators.ReadP (ReadP) #endif #if !(MIN_VERSION_base(4,16,0)) readBinP :: (Eq a, Num a) => ReadP a readBinP :: ReadP a readBinP = ReadP a forall a. (Eq a, Num a) => ReadP a readIntP'2 {-# SPECIALISE readBinP :: ReadP Integer #-} readIntP'2 :: (Eq a, Num a) => ReadP a readIntP'2 :: ReadP a readIntP'2 = a -> (Char -> Bool) -> (Char -> Int) -> ReadP a forall a. Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadP a readIntP a 2 Char -> Bool isDigit Char -> Int valDigit where isDigit :: Char -> Bool isDigit Char c = Bool -> (Int -> Bool) -> Maybe Int -> Bool forall b a. b -> (a -> b) -> Maybe a -> b maybe Bool False (Bool -> Int -> Bool forall a b. a -> b -> a const Bool True) (Char -> Maybe Int valDig2 Char c) valDigit :: Char -> Int valDigit Char c = Int -> (Int -> Int) -> Maybe Int -> Int forall b a. b -> (a -> b) -> Maybe a -> b maybe Int 0 Int -> Int forall a. a -> a id (Char -> Maybe Int valDig2 Char c) {-# SPECIALISE readIntP'2 :: ReadP Integer #-} valDig2 :: Char -> Maybe Int valDig2 :: Char -> Maybe Int valDig2 Char c | Char '0' Char -> Char -> Bool forall a. Ord a => a -> a -> Bool <= Char c Bool -> Bool -> Bool && Char c Char -> Char -> Bool forall a. Ord a => a -> a -> Bool <= Char '1' = Int -> Maybe Int forall a. a -> Maybe a Just (Char -> Int ord Char c Int -> Int -> Int forall a. Num a => a -> a -> a - Char -> Int ord Char '0') | Bool otherwise = Maybe Int forall a. Maybe a Nothing #endif