futhark-data 1.1.3.0 → 1.1.4.0
raw patch · 3 files changed
+47/−1 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Futhark.Data: instance Futhark.Data.GetValue GHC.Types.Double
+ Futhark.Data: instance Futhark.Data.GetValue GHC.Types.Float
+ Futhark.Data: instance Futhark.Data.GetValue Numeric.Half.Internal.Half
+ Futhark.Data: instance Futhark.Data.PutValue GHC.Types.Bool
+ Futhark.Data: instance Futhark.Data.PutValue GHC.Types.Double
+ Futhark.Data: instance Futhark.Data.PutValue GHC.Types.Float
+ Futhark.Data: instance Futhark.Data.PutValue Numeric.Half.Internal.Half
+ Futhark.Data: instance Futhark.Data.PutValue1 GHC.Types.Bool
+ Futhark.Data: instance Futhark.Data.PutValue1 GHC.Types.Double
+ Futhark.Data: instance Futhark.Data.PutValue1 GHC.Types.Float
+ Futhark.Data: instance Futhark.Data.PutValue1 Numeric.Half.Internal.Half
Files
- CHANGELOG.md +4/−0
- futhark-data.cabal +1/−1
- src/Futhark/Data.hs +42/−0
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for futhark-data +## 1.1.4.0++* `GetValue` and `PutValue` now has instances for all primitive types.+ ## 1.1.3.0 * `GetValue` instances for `Int` and `Integer` as a convenience.
futhark-data.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: futhark-data-version: 1.1.3.0+version: 1.1.4.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
@@ -422,12 +422,33 @@ instance GetValue Int where getValue v = fmap fromInteger (getValue v :: Maybe Integer) +instance GetValue Half where+ getValue (F16Value shape vs)+ | [] <- SVec.toList shape =+ Just $ vs SVec.! 0+ getValue _ = Nothing++instance GetValue Float where+ getValue (F32Value shape vs)+ | [] <- SVec.toList shape =+ Just $ vs SVec.! 0+ getValue _ = Nothing++instance GetValue Double where+ getValue (F64Value shape vs)+ | [] <- SVec.toList shape =+ Just $ vs SVec.! 0+ getValue _ = Nothing+ -- | A class for Haskell values that can be converted to 'Value'. -- This is a convenience facility - don't expect it to be fast. class PutValue t where -- | This may fail for cases such as irregular arrays. putValue :: t -> Maybe Value +instance PutValue Bool where+ putValue = Just . putValue1+ instance PutValue Int8 where putValue = Just . putValue1 @@ -452,6 +473,15 @@ instance PutValue Word64 where putValue = Just . putValue1 +instance PutValue Half where+ putValue = Just . putValue1++instance PutValue Float where+ putValue = Just . putValue1++instance PutValue Double where+ putValue = Just . putValue1+ instance PutValue [Value] where putValue [] = Nothing putValue (x : xs) = do@@ -501,6 +531,9 @@ class PutValue1 t where putValue1 :: t -> Value +instance PutValue1 Bool where+ putValue1 = BoolValue mempty . SVec.singleton+ instance PutValue1 Int8 where putValue1 = I8Value mempty . SVec.singleton @@ -524,6 +557,15 @@ instance PutValue1 Word64 where putValue1 = U64Value mempty . SVec.singleton++instance PutValue1 Half where+ putValue1 = F16Value mempty . SVec.singleton++instance PutValue1 Float where+ putValue1 = F32Value mempty . SVec.singleton++instance PutValue1 Double where+ putValue1 = F64Value mempty . SVec.singleton instance PutValue1 T.Text where putValue1 = putValue1 . T.encodeUtf8