futhark-data 1.1.2.0 → 1.1.3.0
raw patch · 4 files changed
+27/−3 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Futhark.Data: instance Futhark.Data.GetValue GHC.Num.Integer.Integer
+ Futhark.Data: instance Futhark.Data.GetValue GHC.Types.Int
Files
- CHANGELOG.md +4/−0
- futhark-data.cabal +1/−1
- src/Futhark/Data.hs +19/−1
- tests/Tests.hs +3/−1
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for futhark-data +## 1.1.3.0++* `GetValue` instances for `Int` and `Integer` as a convenience.+ ## 1.1.2.0 * In the text representation, the type suffix of the first element now also
futhark-data.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: futhark-data-version: 1.1.2.0+version: 1.1.3.0 synopsis: An implementation of the Futhark data format. description: The Futhark compiler and its tools uses a simple external
src/Futhark/Data.hs view
@@ -322,7 +322,7 @@ slices mk vs = [ mk (SVec.fromList ns) $ SVec.slice (k * i) k vs- | i <- [0 .. n - 1]+ | i <- [0 .. n - 1] ] in case v of I8Value _ vs -> slices I8Value vs@@ -403,6 +403,24 @@ | [] <- SVec.toList shape = Just $ vs SVec.! 0 getValue _ = Nothing++-- | A convenience instance that accepts any integer type.+instance GetValue Integer where+ getValue v =+ msum+ [ fmap toInteger (getValue v :: Maybe Int8),+ fmap toInteger (getValue v :: Maybe Int16),+ fmap toInteger (getValue v :: Maybe Int32),+ fmap toInteger (getValue v :: Maybe Int64),+ fmap toInteger (getValue v :: Maybe Word8),+ fmap toInteger (getValue v :: Maybe Word16),+ fmap toInteger (getValue v :: Maybe Word32),+ fmap toInteger (getValue v :: Maybe Word64)+ ]++-- | A convenience instance that accepts any integer type.+instance GetValue Int where+ getValue v = fmap fromInteger (getValue v :: Maybe Integer) -- | A class for Haskell values that can be converted to 'Value'. -- This is a convenience facility - don't expect it to be fast.
tests/Tests.hs view
@@ -155,7 +155,9 @@ testGroup "GetValue" [ test (putValue1 (1 :: Int32)) (Nothing :: Maybe [Word8]),- test (putValue1 (1 :: Int32)) (Just (1 :: Int32))+ test (putValue1 (1 :: Int32)) (Just (1 :: Int32)),+ test (putValue1 (1 :: Int32)) (Just (1 :: Integer)),+ test (putValue1 (42 :: Int64)) (Just (42 :: Int)) ] where test v expected =