foundation 0.0.24 → 0.0.25
raw patch · 5 files changed
+22/−13 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Foundation/Network/IPv4.hs +9/−7
- Foundation/System/Entropy/Windows.hs +7/−1
- foundation.cabal +2/−2
- tests/Test/Foundation/Network/IPv4.hs +2/−0
- tests/Test/Foundation/Primitive/BlockN.hs +2/−3
Foundation/Network/IPv4.hs view
@@ -11,6 +11,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TypeApplications #-} module Foundation.Network.IPv4 ( IPv4@@ -20,7 +21,7 @@ , ipv4Parser ) where -import Prelude (fromIntegral,read)+import Prelude (fromIntegral) import Foundation.Class.Storable import Foundation.Hashing.Hashable@@ -31,8 +32,7 @@ import Basement.Bits import Foundation.Parser hiding (peek) import Foundation.Collection (Sequential, Element, elem)--import qualified Prelude (String)+import Text.Read (readMaybe) -- | IPv4 data type newtype IPv4 = IPv4 Word32@@ -107,8 +107,10 @@ return $ fromTuple (i1, i2, i3, i4) where takeAWord8 = do- n <- (read :: Prelude.String -> Integer) . toList <$> takeWhile isAsciiDecimal- if n > 256- then reportError $ Satisfy $ Just "expected smaller integer than 256"- else return (fromIntegral n)+ maybeN <- readMaybe @Integer . toList <$> takeWhile isAsciiDecimal+ case maybeN of+ Nothing -> reportError $ Satisfy $ Just "expected integer"+ Just n | n > 256 -> reportError $ Satisfy $ Just "expected smaller integer than 256"+ | otherwise -> pure (fromIntegral n)+ isAsciiDecimal = flip elem ['0'..'9']
Foundation/System/Entropy/Windows.hs view
@@ -92,6 +92,12 @@ cryptGenRandom :: CryptCtx -> Ptr Word8 -> Int -> IO Bool cryptGenRandom h buf n = toBool `fmap` c_cryptGenRandom h (Prelude.fromIntegral n) buf ++newtype WindowsRandomBackendError = WindowsRandomBackendError [Char]+ deriving (Show,Eq)++instance Exception WindowsRandomBackendError+ cryptReleaseCtx :: CryptCtx -> IO () cryptReleaseCtx h = do success <- toBool `fmap` c_cryptReleaseCtx h 0@@ -99,4 +105,4 @@ then return () else do lastError <- getLastError- fail $ "cryptReleaseCtx: error " <> show lastError+ throwIO (WindowsRandomBackendError $ show lastError)
foundation.cabal view
@@ -1,5 +1,5 @@ name: foundation-version: 0.0.24+version: 0.0.25 synopsis: Alternative prelude with batteries and no dependencies description: A custom prelude with no dependencies apart from base.@@ -196,7 +196,7 @@ BangPatterns DeriveDataTypeable - if impl(ghc < 8.0)+ if impl(ghc < 8.0) || impl(ghcjs) buildable: False else build-depends: base
tests/Test/Foundation/Network/IPv4.hs view
@@ -50,4 +50,6 @@ , testPropertyStorableFixed "StorableFixed" (Proxy :: Proxy IPv4) , Property "Word8 overflow is detected" $ forAll genOverflowingIPv4String $ \x -> isLeft $ parseOnly ipv4Parser x+ , Property "www.example.com" $+ isLeft $ parseOnly ipv4Parser ("www.example.com" :: String) ]
tests/Test/Foundation/Primitive/BlockN.hs view
@@ -23,9 +23,7 @@ ] testWithDifferentN =- Group "Multiple n" $ do- Foo n <- ns- [testBlock n]+ Group "Multiple n" $ fmap (\(Foo p) -> testBlock p) ns testBlock :: forall n . (KnownNat n, NatWithinBound (CountOf Int) n) => Proxy n -> Test testBlock nProxy =@@ -48,6 +46,7 @@ data Foo = forall a . (KnownNat a, NatWithinBound (CountOf Int) a) => Foo (Proxy a) +ns :: [Foo] ns = [ Foo (Proxy :: Proxy 0) , Foo (Proxy :: Proxy 1)