mirror of
https://github.com/composewell/streamly.git
synced 2024-09-11 11:37:22 +03:00
Add cautions about Unbox type class usage
This commit is contained in:
parent
61c4ea467e
commit
4969d04f13
@ -226,8 +226,9 @@ unpin arr@(MutableByteArray marr#) =
|
||||
-- deserializes the boxed type from the mutable byte array. The write operation
|
||||
-- 'pokeByteIndex' serializes the boxed type to the mutable byte array.
|
||||
--
|
||||
-- Instances can be derived via 'Generic'. Here is an example, for deriving an
|
||||
-- instance of this type class.
|
||||
-- Instances can be derived via 'Generic'. Note that the data type must be
|
||||
-- non-recursive. Here is an example, for deriving an instance of this type
|
||||
-- class.
|
||||
--
|
||||
-- >>> import GHC.Generics (Generic)
|
||||
-- >>> :{
|
||||
@ -237,6 +238,8 @@ unpin arr@(MutableByteArray marr#) =
|
||||
-- } deriving Generic
|
||||
-- :}
|
||||
--
|
||||
-- WARNING! Generic deriving hangs for recursive data types.
|
||||
--
|
||||
-- >>> import Streamly.Data.Array (Unbox(..))
|
||||
-- >>> instance Unbox Object
|
||||
--
|
||||
@ -255,7 +258,7 @@ unpin arr@(MutableByteArray marr#) =
|
||||
-- :}
|
||||
--
|
||||
class Unbox a where
|
||||
-- | Get the size.
|
||||
-- | Get the size. Size cannot be zero.
|
||||
sizeOf :: Proxy a -> Int
|
||||
|
||||
default sizeOf :: (SizeOfRep (Rep a)) => Proxy a -> Int
|
||||
|
Loading…
Reference in New Issue
Block a user