{-# LANGUAGE DataKinds, PolyKinds, TypeOperators, GADTs #-}
{-# LANGUAGE FlexibleInstances, FlexibleContexts, MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving, DeriveTraversable #-}
{-# LANGUAGE Safe #-}
module Data.Binary.Combinators
( Many(..)
, Some(..)
, CountedBy(..)
, SkipCount(..)
, SkipByte(..)
, MatchBytes
, matchBytes
, MatchByte
, MatchASCII
, matchASCII
, LE(..)
) where
import Control.Applicative
import Control.Monad
import Data.Binary
import Data.Binary.Get
import Data.Binary.Put
import Data.Char
import Data.Functor
import Data.Int
import Data.Kind
import Data.Proxy
import GHC.TypeLits
import Numeric
import Test.QuickCheck
newtype Many a = Many { Many a -> [a]
getMany :: [a] } deriving (Many a -> Many a -> Bool
(Many a -> Many a -> Bool)
-> (Many a -> Many a -> Bool) -> Eq (Many a)
forall a. Eq a => Many a -> Many a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Many a -> Many a -> Bool
$c/= :: forall a. Eq a => Many a -> Many a -> Bool
== :: Many a -> Many a -> Bool
$c== :: forall a. Eq a => Many a -> Many a -> Bool
Eq, Eq (Many a)
Eq (Many a)
-> (Many a -> Many a -> Ordering)
-> (Many a -> Many a -> Bool)
-> (Many a -> Many a -> Bool)
-> (Many a -> Many a -> Bool)
-> (Many a -> Many a -> Bool)
-> (Many a -> Many a -> Many a)
-> (Many a -> Many a -> Many a)
-> Ord (Many a)
Many a -> Many a -> Bool
Many a -> Many a -> Ordering
Many a -> Many a -> Many a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Many a)
forall a. Ord a => Many a -> Many a -> Bool
forall a. Ord a => Many a -> Many a -> Ordering
forall a. Ord a => Many a -> Many a -> Many a
min :: Many a -> Many a -> Many a
$cmin :: forall a. Ord a => Many a -> Many a -> Many a
max :: Many a -> Many a -> Many a
$cmax :: forall a. Ord a => Many a -> Many a -> Many a
>= :: Many a -> Many a -> Bool
$c>= :: forall a. Ord a => Many a -> Many a -> Bool
> :: Many a -> Many a -> Bool
$c> :: forall a. Ord a => Many a -> Many a -> Bool
<= :: Many a -> Many a -> Bool
$c<= :: forall a. Ord a => Many a -> Many a -> Bool
< :: Many a -> Many a -> Bool
$c< :: forall a. Ord a => Many a -> Many a -> Bool
compare :: Many a -> Many a -> Ordering
$ccompare :: forall a. Ord a => Many a -> Many a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Many a)
Ord, a -> Many b -> Many a
(a -> b) -> Many a -> Many b
(forall a b. (a -> b) -> Many a -> Many b)
-> (forall a b. a -> Many b -> Many a) -> Functor Many
forall a b. a -> Many b -> Many a
forall a b. (a -> b) -> Many a -> Many b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Many b -> Many a
$c<$ :: forall a b. a -> Many b -> Many a
fmap :: (a -> b) -> Many a -> Many b
$cfmap :: forall a b. (a -> b) -> Many a -> Many b
Functor, Many a -> Bool
(a -> m) -> Many a -> m
(a -> b -> b) -> b -> Many a -> b
(forall m. Monoid m => Many m -> m)
-> (forall m a. Monoid m => (a -> m) -> Many a -> m)
-> (forall m a. Monoid m => (a -> m) -> Many a -> m)
-> (forall a b. (a -> b -> b) -> b -> Many a -> b)
-> (forall a b. (a -> b -> b) -> b -> Many a -> b)
-> (forall b a. (b -> a -> b) -> b -> Many a -> b)
-> (forall b a. (b -> a -> b) -> b -> Many a -> b)
-> (forall a. (a -> a -> a) -> Many a -> a)
-> (forall a. (a -> a -> a) -> Many a -> a)
-> (forall a. Many a -> [a])
-> (forall a. Many a -> Bool)
-> (forall a. Many a -> Int)
-> (forall a. Eq a => a -> Many a -> Bool)
-> (forall a. Ord a => Many a -> a)
-> (forall a. Ord a => Many a -> a)
-> (forall a. Num a => Many a -> a)
-> (forall a. Num a => Many a -> a)
-> Foldable Many
forall a. Eq a => a -> Many a -> Bool
forall a. Num a => Many a -> a
forall a. Ord a => Many a -> a
forall m. Monoid m => Many m -> m
forall a. Many a -> Bool
forall a. Many a -> Int
forall a. Many a -> [a]
forall a. (a -> a -> a) -> Many a -> a
forall m a. Monoid m => (a -> m) -> Many a -> m
forall b a. (b -> a -> b) -> b -> Many a -> b
forall a b. (a -> b -> b) -> b -> Many a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Many a -> a
$cproduct :: forall a. Num a => Many a -> a
sum :: Many a -> a
$csum :: forall a. Num a => Many a -> a
minimum :: Many a -> a
$cminimum :: forall a. Ord a => Many a -> a
maximum :: Many a -> a
$cmaximum :: forall a. Ord a => Many a -> a
elem :: a -> Many a -> Bool
$celem :: forall a. Eq a => a -> Many a -> Bool
length :: Many a -> Int
$clength :: forall a. Many a -> Int
null :: Many a -> Bool
$cnull :: forall a. Many a -> Bool
toList :: Many a -> [a]
$ctoList :: forall a. Many a -> [a]
foldl1 :: (a -> a -> a) -> Many a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Many a -> a
foldr1 :: (a -> a -> a) -> Many a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Many a -> a
foldl' :: (b -> a -> b) -> b -> Many a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Many a -> b
foldl :: (b -> a -> b) -> b -> Many a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Many a -> b
foldr' :: (a -> b -> b) -> b -> Many a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Many a -> b
foldr :: (a -> b -> b) -> b -> Many a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Many a -> b
foldMap' :: (a -> m) -> Many a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Many a -> m
foldMap :: (a -> m) -> Many a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Many a -> m
fold :: Many m -> m
$cfold :: forall m. Monoid m => Many m -> m
Foldable, Functor Many
Foldable Many
Functor Many
-> Foldable Many
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Many a -> f (Many b))
-> (forall (f :: * -> *) a.
Applicative f =>
Many (f a) -> f (Many a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Many a -> m (Many b))
-> (forall (m :: * -> *) a. Monad m => Many (m a) -> m (Many a))
-> Traversable Many
(a -> f b) -> Many a -> f (Many b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Many (m a) -> m (Many a)
forall (f :: * -> *) a. Applicative f => Many (f a) -> f (Many a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Many a -> m (Many b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Many a -> f (Many b)
sequence :: Many (m a) -> m (Many a)
$csequence :: forall (m :: * -> *) a. Monad m => Many (m a) -> m (Many a)
mapM :: (a -> m b) -> Many a -> m (Many b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Many a -> m (Many b)
sequenceA :: Many (f a) -> f (Many a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Many (f a) -> f (Many a)
traverse :: (a -> f b) -> Many a -> f (Many b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Many a -> f (Many b)
$cp2Traversable :: Foldable Many
$cp1Traversable :: Functor Many
Traversable)
instance Show a => Show (Many a) where
show :: Many a -> String
show = [a] -> String
forall a. Show a => a -> String
show ([a] -> String) -> (Many a -> [a]) -> Many a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many a -> [a]
forall a. Many a -> [a]
getMany
instance Binary a => Binary (Many a) where
get :: Get (Many a)
get = [a] -> Many a
forall a. [a] -> Many a
Many ([a] -> Many a) -> Get [a] -> Get (Many a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get a -> Get [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many Get a
forall t. Binary t => Get t
get
put :: Many a -> Put
put = (a -> Put) -> [a] -> Put
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ a -> Put
forall t. Binary t => t -> Put
put ([a] -> Put) -> (Many a -> [a]) -> Many a -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many a -> [a]
forall a. Many a -> [a]
getMany
instance Arbitrary a => Arbitrary (Many a) where
arbitrary :: Gen (Many a)
arbitrary = [a] -> Many a
forall a. [a] -> Many a
Many ([a] -> Many a) -> Gen [a] -> Gen (Many a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [a]
forall a. Arbitrary a => Gen a
arbitrary
shrink :: Many a -> [Many a]
shrink (Many [a]
xs) = [a] -> Many a
forall a. [a] -> Many a
Many ([a] -> Many a) -> [[a]] -> [Many a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a] -> [[a]]
forall a. Arbitrary a => a -> [a]
shrink [a]
xs
newtype Some a = Some { Some a -> [a]
getSome :: [a] } deriving (Some a -> Some a -> Bool
(Some a -> Some a -> Bool)
-> (Some a -> Some a -> Bool) -> Eq (Some a)
forall a. Eq a => Some a -> Some a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Some a -> Some a -> Bool
$c/= :: forall a. Eq a => Some a -> Some a -> Bool
== :: Some a -> Some a -> Bool
$c== :: forall a. Eq a => Some a -> Some a -> Bool
Eq, Eq (Some a)
Eq (Some a)
-> (Some a -> Some a -> Ordering)
-> (Some a -> Some a -> Bool)
-> (Some a -> Some a -> Bool)
-> (Some a -> Some a -> Bool)
-> (Some a -> Some a -> Bool)
-> (Some a -> Some a -> Some a)
-> (Some a -> Some a -> Some a)
-> Ord (Some a)
Some a -> Some a -> Bool
Some a -> Some a -> Ordering
Some a -> Some a -> Some a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Some a)
forall a. Ord a => Some a -> Some a -> Bool
forall a. Ord a => Some a -> Some a -> Ordering
forall a. Ord a => Some a -> Some a -> Some a
min :: Some a -> Some a -> Some a
$cmin :: forall a. Ord a => Some a -> Some a -> Some a
max :: Some a -> Some a -> Some a
$cmax :: forall a. Ord a => Some a -> Some a -> Some a
>= :: Some a -> Some a -> Bool
$c>= :: forall a. Ord a => Some a -> Some a -> Bool
> :: Some a -> Some a -> Bool
$c> :: forall a. Ord a => Some a -> Some a -> Bool
<= :: Some a -> Some a -> Bool
$c<= :: forall a. Ord a => Some a -> Some a -> Bool
< :: Some a -> Some a -> Bool
$c< :: forall a. Ord a => Some a -> Some a -> Bool
compare :: Some a -> Some a -> Ordering
$ccompare :: forall a. Ord a => Some a -> Some a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Some a)
Ord, a -> Some b -> Some a
(a -> b) -> Some a -> Some b
(forall a b. (a -> b) -> Some a -> Some b)
-> (forall a b. a -> Some b -> Some a) -> Functor Some
forall a b. a -> Some b -> Some a
forall a b. (a -> b) -> Some a -> Some b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Some b -> Some a
$c<$ :: forall a b. a -> Some b -> Some a
fmap :: (a -> b) -> Some a -> Some b
$cfmap :: forall a b. (a -> b) -> Some a -> Some b
Functor, Some a -> Bool
(a -> m) -> Some a -> m
(a -> b -> b) -> b -> Some a -> b
(forall m. Monoid m => Some m -> m)
-> (forall m a. Monoid m => (a -> m) -> Some a -> m)
-> (forall m a. Monoid m => (a -> m) -> Some a -> m)
-> (forall a b. (a -> b -> b) -> b -> Some a -> b)
-> (forall a b. (a -> b -> b) -> b -> Some a -> b)
-> (forall b a. (b -> a -> b) -> b -> Some a -> b)
-> (forall b a. (b -> a -> b) -> b -> Some a -> b)
-> (forall a. (a -> a -> a) -> Some a -> a)
-> (forall a. (a -> a -> a) -> Some a -> a)
-> (forall a. Some a -> [a])
-> (forall a. Some a -> Bool)
-> (forall a. Some a -> Int)
-> (forall a. Eq a => a -> Some a -> Bool)
-> (forall a. Ord a => Some a -> a)
-> (forall a. Ord a => Some a -> a)
-> (forall a. Num a => Some a -> a)
-> (forall a. Num a => Some a -> a)
-> Foldable Some
forall a. Eq a => a -> Some a -> Bool
forall a. Num a => Some a -> a
forall a. Ord a => Some a -> a
forall m. Monoid m => Some m -> m
forall a. Some a -> Bool
forall a. Some a -> Int
forall a. Some a -> [a]
forall a. (a -> a -> a) -> Some a -> a
forall m a. Monoid m => (a -> m) -> Some a -> m
forall b a. (b -> a -> b) -> b -> Some a -> b
forall a b. (a -> b -> b) -> b -> Some a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Some a -> a
$cproduct :: forall a. Num a => Some a -> a
sum :: Some a -> a
$csum :: forall a. Num a => Some a -> a
minimum :: Some a -> a
$cminimum :: forall a. Ord a => Some a -> a
maximum :: Some a -> a
$cmaximum :: forall a. Ord a => Some a -> a
elem :: a -> Some a -> Bool
$celem :: forall a. Eq a => a -> Some a -> Bool
length :: Some a -> Int
$clength :: forall a. Some a -> Int
null :: Some a -> Bool
$cnull :: forall a. Some a -> Bool
toList :: Some a -> [a]
$ctoList :: forall a. Some a -> [a]
foldl1 :: (a -> a -> a) -> Some a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Some a -> a
foldr1 :: (a -> a -> a) -> Some a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Some a -> a
foldl' :: (b -> a -> b) -> b -> Some a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Some a -> b
foldl :: (b -> a -> b) -> b -> Some a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Some a -> b
foldr' :: (a -> b -> b) -> b -> Some a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Some a -> b
foldr :: (a -> b -> b) -> b -> Some a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Some a -> b
foldMap' :: (a -> m) -> Some a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Some a -> m
foldMap :: (a -> m) -> Some a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Some a -> m
fold :: Some m -> m
$cfold :: forall m. Monoid m => Some m -> m
Foldable, Functor Some
Foldable Some
Functor Some
-> Foldable Some
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Some a -> f (Some b))
-> (forall (f :: * -> *) a.
Applicative f =>
Some (f a) -> f (Some a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Some a -> m (Some b))
-> (forall (m :: * -> *) a. Monad m => Some (m a) -> m (Some a))
-> Traversable Some
(a -> f b) -> Some a -> f (Some b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Some (m a) -> m (Some a)
forall (f :: * -> *) a. Applicative f => Some (f a) -> f (Some a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Some a -> m (Some b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Some a -> f (Some b)
sequence :: Some (m a) -> m (Some a)
$csequence :: forall (m :: * -> *) a. Monad m => Some (m a) -> m (Some a)
mapM :: (a -> m b) -> Some a -> m (Some b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Some a -> m (Some b)
sequenceA :: Some (f a) -> f (Some a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Some (f a) -> f (Some a)
traverse :: (a -> f b) -> Some a -> f (Some b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Some a -> f (Some b)
$cp2Traversable :: Foldable Some
$cp1Traversable :: Functor Some
Traversable)
instance Show a => Show (Some a) where
show :: Some a -> String
show = [a] -> String
forall a. Show a => a -> String
show ([a] -> String) -> (Some a -> [a]) -> Some a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Some a -> [a]
forall a. Some a -> [a]
getSome
instance Binary a => Binary (Some a) where
get :: Get (Some a)
get = [a] -> Some a
forall a. [a] -> Some a
Some ([a] -> Some a) -> Get [a] -> Get (Some a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get a -> Get [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some Get a
forall t. Binary t => Get t
get
put :: Some a -> Put
put = (a -> Put) -> [a] -> Put
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ a -> Put
forall t. Binary t => t -> Put
put ([a] -> Put) -> (Some a -> [a]) -> Some a -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Some a -> [a]
forall a. Some a -> [a]
getSome
instance Arbitrary a => Arbitrary (Some a) where
arbitrary :: Gen (Some a)
arbitrary = [a] -> Some a
forall a. [a] -> Some a
Some ([a] -> Some a)
-> (NonEmptyList a -> [a]) -> NonEmptyList a -> Some a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmptyList a -> [a]
forall a. NonEmptyList a -> [a]
getNonEmpty (NonEmptyList a -> Some a) -> Gen (NonEmptyList a) -> Gen (Some a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (NonEmptyList a)
forall a. Arbitrary a => Gen a
arbitrary
shrink :: Some a -> [Some a]
shrink (Some [a]
xs) = [a] -> Some a
forall a. [a] -> Some a
Some ([a] -> Some a) -> [[a]] -> [Some a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ([a] -> Bool) -> [[a]] -> [[a]]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> ([a] -> Bool) -> [a] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) ([a] -> [[a]]
forall a. Arbitrary a => a -> [a]
shrink [a]
xs)
newtype CountedBy ty a = CountedBy { CountedBy ty a -> [a]
getCounted :: [a] } deriving (CountedBy ty a -> CountedBy ty a -> Bool
(CountedBy ty a -> CountedBy ty a -> Bool)
-> (CountedBy ty a -> CountedBy ty a -> Bool)
-> Eq (CountedBy ty a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (ty :: k) a.
Eq a =>
CountedBy ty a -> CountedBy ty a -> Bool
/= :: CountedBy ty a -> CountedBy ty a -> Bool
$c/= :: forall k (ty :: k) a.
Eq a =>
CountedBy ty a -> CountedBy ty a -> Bool
== :: CountedBy ty a -> CountedBy ty a -> Bool
$c== :: forall k (ty :: k) a.
Eq a =>
CountedBy ty a -> CountedBy ty a -> Bool
Eq, Eq (CountedBy ty a)
Eq (CountedBy ty a)
-> (CountedBy ty a -> CountedBy ty a -> Ordering)
-> (CountedBy ty a -> CountedBy ty a -> Bool)
-> (CountedBy ty a -> CountedBy ty a -> Bool)
-> (CountedBy ty a -> CountedBy ty a -> Bool)
-> (CountedBy ty a -> CountedBy ty a -> Bool)
-> (CountedBy ty a -> CountedBy ty a -> CountedBy ty a)
-> (CountedBy ty a -> CountedBy ty a -> CountedBy ty a)
-> Ord (CountedBy ty a)
CountedBy ty a -> CountedBy ty a -> Bool
CountedBy ty a -> CountedBy ty a -> Ordering
CountedBy ty a -> CountedBy ty a -> CountedBy ty a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall k (ty :: k) a. Ord a => Eq (CountedBy ty a)
forall k (ty :: k) a.
Ord a =>
CountedBy ty a -> CountedBy ty a -> Bool
forall k (ty :: k) a.
Ord a =>
CountedBy ty a -> CountedBy ty a -> Ordering
forall k (ty :: k) a.
Ord a =>
CountedBy ty a -> CountedBy ty a -> CountedBy ty a
min :: CountedBy ty a -> CountedBy ty a -> CountedBy ty a
$cmin :: forall k (ty :: k) a.
Ord a =>
CountedBy ty a -> CountedBy ty a -> CountedBy ty a
max :: CountedBy ty a -> CountedBy ty a -> CountedBy ty a
$cmax :: forall k (ty :: k) a.
Ord a =>
CountedBy ty a -> CountedBy ty a -> CountedBy ty a
>= :: CountedBy ty a -> CountedBy ty a -> Bool
$c>= :: forall k (ty :: k) a.
Ord a =>
CountedBy ty a -> CountedBy ty a -> Bool
> :: CountedBy ty a -> CountedBy ty a -> Bool
$c> :: forall k (ty :: k) a.
Ord a =>
CountedBy ty a -> CountedBy ty a -> Bool
<= :: CountedBy ty a -> CountedBy ty a -> Bool
$c<= :: forall k (ty :: k) a.
Ord a =>
CountedBy ty a -> CountedBy ty a -> Bool
< :: CountedBy ty a -> CountedBy ty a -> Bool
$c< :: forall k (ty :: k) a.
Ord a =>
CountedBy ty a -> CountedBy ty a -> Bool
compare :: CountedBy ty a -> CountedBy ty a -> Ordering
$ccompare :: forall k (ty :: k) a.
Ord a =>
CountedBy ty a -> CountedBy ty a -> Ordering
$cp1Ord :: forall k (ty :: k) a. Ord a => Eq (CountedBy ty a)
Ord, a -> CountedBy ty b -> CountedBy ty a
(a -> b) -> CountedBy ty a -> CountedBy ty b
(forall a b. (a -> b) -> CountedBy ty a -> CountedBy ty b)
-> (forall a b. a -> CountedBy ty b -> CountedBy ty a)
-> Functor (CountedBy ty)
forall k (ty :: k) a b. a -> CountedBy ty b -> CountedBy ty a
forall k (ty :: k) a b.
(a -> b) -> CountedBy ty a -> CountedBy ty b
forall a b. a -> CountedBy ty b -> CountedBy ty a
forall a b. (a -> b) -> CountedBy ty a -> CountedBy ty b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> CountedBy ty b -> CountedBy ty a
$c<$ :: forall k (ty :: k) a b. a -> CountedBy ty b -> CountedBy ty a
fmap :: (a -> b) -> CountedBy ty a -> CountedBy ty b
$cfmap :: forall k (ty :: k) a b.
(a -> b) -> CountedBy ty a -> CountedBy ty b
Functor, CountedBy ty a -> Bool
(a -> m) -> CountedBy ty a -> m
(a -> b -> b) -> b -> CountedBy ty a -> b
(forall m. Monoid m => CountedBy ty m -> m)
-> (forall m a. Monoid m => (a -> m) -> CountedBy ty a -> m)
-> (forall m a. Monoid m => (a -> m) -> CountedBy ty a -> m)
-> (forall a b. (a -> b -> b) -> b -> CountedBy ty a -> b)
-> (forall a b. (a -> b -> b) -> b -> CountedBy ty a -> b)
-> (forall b a. (b -> a -> b) -> b -> CountedBy ty a -> b)
-> (forall b a. (b -> a -> b) -> b -> CountedBy ty a -> b)
-> (forall a. (a -> a -> a) -> CountedBy ty a -> a)
-> (forall a. (a -> a -> a) -> CountedBy ty a -> a)
-> (forall a. CountedBy ty a -> [a])
-> (forall a. CountedBy ty a -> Bool)
-> (forall a. CountedBy ty a -> Int)
-> (forall a. Eq a => a -> CountedBy ty a -> Bool)
-> (forall a. Ord a => CountedBy ty a -> a)
-> (forall a. Ord a => CountedBy ty a -> a)
-> (forall a. Num a => CountedBy ty a -> a)
-> (forall a. Num a => CountedBy ty a -> a)
-> Foldable (CountedBy ty)
forall a. Eq a => a -> CountedBy ty a -> Bool
forall a. Num a => CountedBy ty a -> a
forall a. Ord a => CountedBy ty a -> a
forall m. Monoid m => CountedBy ty m -> m
forall a. CountedBy ty a -> Bool
forall a. CountedBy ty a -> Int
forall a. CountedBy ty a -> [a]
forall a. (a -> a -> a) -> CountedBy ty a -> a
forall k (ty :: k) a. Eq a => a -> CountedBy ty a -> Bool
forall k (ty :: k) a. Num a => CountedBy ty a -> a
forall k (ty :: k) a. Ord a => CountedBy ty a -> a
forall k (ty :: k) m. Monoid m => CountedBy ty m -> m
forall k (ty :: k) a. CountedBy ty a -> Bool
forall k (ty :: k) a. CountedBy ty a -> Int
forall k (ty :: k) a. CountedBy ty a -> [a]
forall k (ty :: k) a. (a -> a -> a) -> CountedBy ty a -> a
forall k (ty :: k) m a. Monoid m => (a -> m) -> CountedBy ty a -> m
forall k (ty :: k) b a. (b -> a -> b) -> b -> CountedBy ty a -> b
forall k (ty :: k) a b. (a -> b -> b) -> b -> CountedBy ty a -> b
forall m a. Monoid m => (a -> m) -> CountedBy ty a -> m
forall b a. (b -> a -> b) -> b -> CountedBy ty a -> b
forall a b. (a -> b -> b) -> b -> CountedBy ty a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: CountedBy ty a -> a
$cproduct :: forall k (ty :: k) a. Num a => CountedBy ty a -> a
sum :: CountedBy ty a -> a
$csum :: forall k (ty :: k) a. Num a => CountedBy ty a -> a
minimum :: CountedBy ty a -> a
$cminimum :: forall k (ty :: k) a. Ord a => CountedBy ty a -> a
maximum :: CountedBy ty a -> a
$cmaximum :: forall k (ty :: k) a. Ord a => CountedBy ty a -> a
elem :: a -> CountedBy ty a -> Bool
$celem :: forall k (ty :: k) a. Eq a => a -> CountedBy ty a -> Bool
length :: CountedBy ty a -> Int
$clength :: forall k (ty :: k) a. CountedBy ty a -> Int
null :: CountedBy ty a -> Bool
$cnull :: forall k (ty :: k) a. CountedBy ty a -> Bool
toList :: CountedBy ty a -> [a]
$ctoList :: forall k (ty :: k) a. CountedBy ty a -> [a]
foldl1 :: (a -> a -> a) -> CountedBy ty a -> a
$cfoldl1 :: forall k (ty :: k) a. (a -> a -> a) -> CountedBy ty a -> a
foldr1 :: (a -> a -> a) -> CountedBy ty a -> a
$cfoldr1 :: forall k (ty :: k) a. (a -> a -> a) -> CountedBy ty a -> a
foldl' :: (b -> a -> b) -> b -> CountedBy ty a -> b
$cfoldl' :: forall k (ty :: k) b a. (b -> a -> b) -> b -> CountedBy ty a -> b
foldl :: (b -> a -> b) -> b -> CountedBy ty a -> b
$cfoldl :: forall k (ty :: k) b a. (b -> a -> b) -> b -> CountedBy ty a -> b
foldr' :: (a -> b -> b) -> b -> CountedBy ty a -> b
$cfoldr' :: forall k (ty :: k) a b. (a -> b -> b) -> b -> CountedBy ty a -> b
foldr :: (a -> b -> b) -> b -> CountedBy ty a -> b
$cfoldr :: forall k (ty :: k) a b. (a -> b -> b) -> b -> CountedBy ty a -> b
foldMap' :: (a -> m) -> CountedBy ty a -> m
$cfoldMap' :: forall k (ty :: k) m a. Monoid m => (a -> m) -> CountedBy ty a -> m
foldMap :: (a -> m) -> CountedBy ty a -> m
$cfoldMap :: forall k (ty :: k) m a. Monoid m => (a -> m) -> CountedBy ty a -> m
fold :: CountedBy ty m -> m
$cfold :: forall k (ty :: k) m. Monoid m => CountedBy ty m -> m
Foldable, Functor (CountedBy ty)
Foldable (CountedBy ty)
Functor (CountedBy ty)
-> Foldable (CountedBy ty)
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CountedBy ty a -> f (CountedBy ty b))
-> (forall (f :: * -> *) a.
Applicative f =>
CountedBy ty (f a) -> f (CountedBy ty a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CountedBy ty a -> m (CountedBy ty b))
-> (forall (m :: * -> *) a.
Monad m =>
CountedBy ty (m a) -> m (CountedBy ty a))
-> Traversable (CountedBy ty)
(a -> f b) -> CountedBy ty a -> f (CountedBy ty b)
forall k (ty :: k). Functor (CountedBy ty)
forall k (ty :: k). Foldable (CountedBy ty)
forall k (ty :: k) (m :: * -> *) a.
Monad m =>
CountedBy ty (m a) -> m (CountedBy ty a)
forall k (ty :: k) (f :: * -> *) a.
Applicative f =>
CountedBy ty (f a) -> f (CountedBy ty a)
forall k (ty :: k) (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CountedBy ty a -> m (CountedBy ty b)
forall k (ty :: k) (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CountedBy ty a -> f (CountedBy ty b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
CountedBy ty (m a) -> m (CountedBy ty a)
forall (f :: * -> *) a.
Applicative f =>
CountedBy ty (f a) -> f (CountedBy ty a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CountedBy ty a -> m (CountedBy ty b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CountedBy ty a -> f (CountedBy ty b)
sequence :: CountedBy ty (m a) -> m (CountedBy ty a)
$csequence :: forall k (ty :: k) (m :: * -> *) a.
Monad m =>
CountedBy ty (m a) -> m (CountedBy ty a)
mapM :: (a -> m b) -> CountedBy ty a -> m (CountedBy ty b)
$cmapM :: forall k (ty :: k) (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CountedBy ty a -> m (CountedBy ty b)
sequenceA :: CountedBy ty (f a) -> f (CountedBy ty a)
$csequenceA :: forall k (ty :: k) (f :: * -> *) a.
Applicative f =>
CountedBy ty (f a) -> f (CountedBy ty a)
traverse :: (a -> f b) -> CountedBy ty a -> f (CountedBy ty b)
$ctraverse :: forall k (ty :: k) (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CountedBy ty a -> f (CountedBy ty b)
$cp2Traversable :: forall k (ty :: k). Foldable (CountedBy ty)
$cp1Traversable :: forall k (ty :: k). Functor (CountedBy ty)
Traversable)
instance Show a => Show (CountedBy ty a) where
show :: CountedBy ty a -> String
show = [a] -> String
forall a. Show a => a -> String
show ([a] -> String)
-> (CountedBy ty a -> [a]) -> CountedBy ty a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CountedBy ty a -> [a]
forall k (ty :: k) a. CountedBy ty a -> [a]
getCounted
instance (Integral ty, Binary ty, Binary a) => Binary (CountedBy ty a) where
get :: Get (CountedBy ty a)
get = do ty
cnt :: ty <- Get ty
forall t. Binary t => Get t
get
[a] -> CountedBy ty a
forall k (ty :: k) a. [a] -> CountedBy ty a
CountedBy ([a] -> CountedBy ty a) -> Get [a] -> Get (CountedBy ty a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Get a -> Get [a]
forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM (ty -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ty
cnt) Get a
forall t. Binary t => Get t
get
put :: CountedBy ty a -> Put
put (CountedBy [a]
xs) = ty -> Put
forall t. Binary t => t -> Put
put (Int -> ty
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> ty) -> Int -> ty
forall a b. (a -> b) -> a -> b
$ [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
xs :: ty) Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (a -> Put) -> [a] -> Put
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ a -> Put
forall t. Binary t => t -> Put
put [a]
xs
instance Arbitrary a => Arbitrary (CountedBy ty a) where
arbitrary :: Gen (CountedBy ty a)
arbitrary = [a] -> CountedBy ty a
forall k (ty :: k) a. [a] -> CountedBy ty a
CountedBy ([a] -> CountedBy ty a) -> Gen [a] -> Gen (CountedBy ty a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [a]
forall a. Arbitrary a => Gen a
arbitrary
shrink :: CountedBy ty a -> [CountedBy ty a]
shrink (CountedBy [a]
xs) = [a] -> CountedBy ty a
forall k (ty :: k) a. [a] -> CountedBy ty a
CountedBy ([a] -> CountedBy ty a) -> [[a]] -> [CountedBy ty a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a] -> [[a]]
forall a. Arbitrary a => a -> [a]
shrink [a]
xs
data SkipCount ty (n :: Nat) = SkipCount deriving (SkipCount ty n -> SkipCount ty n -> Bool
(SkipCount ty n -> SkipCount ty n -> Bool)
-> (SkipCount ty n -> SkipCount ty n -> Bool)
-> Eq (SkipCount ty n)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> Bool
/= :: SkipCount ty n -> SkipCount ty n -> Bool
$c/= :: forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> Bool
== :: SkipCount ty n -> SkipCount ty n -> Bool
$c== :: forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> Bool
Eq, Eq (SkipCount ty n)
Eq (SkipCount ty n)
-> (SkipCount ty n -> SkipCount ty n -> Ordering)
-> (SkipCount ty n -> SkipCount ty n -> Bool)
-> (SkipCount ty n -> SkipCount ty n -> Bool)
-> (SkipCount ty n -> SkipCount ty n -> Bool)
-> (SkipCount ty n -> SkipCount ty n -> Bool)
-> (SkipCount ty n -> SkipCount ty n -> SkipCount ty n)
-> (SkipCount ty n -> SkipCount ty n -> SkipCount ty n)
-> Ord (SkipCount ty n)
SkipCount ty n -> SkipCount ty n -> Bool
SkipCount ty n -> SkipCount ty n -> Ordering
SkipCount ty n -> SkipCount ty n -> SkipCount ty n
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall k (ty :: k) (n :: Nat). Eq (SkipCount ty n)
forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> Bool
forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> Ordering
forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> SkipCount ty n
min :: SkipCount ty n -> SkipCount ty n -> SkipCount ty n
$cmin :: forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> SkipCount ty n
max :: SkipCount ty n -> SkipCount ty n -> SkipCount ty n
$cmax :: forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> SkipCount ty n
>= :: SkipCount ty n -> SkipCount ty n -> Bool
$c>= :: forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> Bool
> :: SkipCount ty n -> SkipCount ty n -> Bool
$c> :: forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> Bool
<= :: SkipCount ty n -> SkipCount ty n -> Bool
$c<= :: forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> Bool
< :: SkipCount ty n -> SkipCount ty n -> Bool
$c< :: forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> Bool
compare :: SkipCount ty n -> SkipCount ty n -> Ordering
$ccompare :: forall k (ty :: k) (n :: Nat).
SkipCount ty n -> SkipCount ty n -> Ordering
$cp1Ord :: forall k (ty :: k) (n :: Nat). Eq (SkipCount ty n)
Ord, Int -> SkipCount ty n -> ShowS
[SkipCount ty n] -> ShowS
SkipCount ty n -> String
(Int -> SkipCount ty n -> ShowS)
-> (SkipCount ty n -> String)
-> ([SkipCount ty n] -> ShowS)
-> Show (SkipCount ty n)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (ty :: k) (n :: Nat). Int -> SkipCount ty n -> ShowS
forall k (ty :: k) (n :: Nat). [SkipCount ty n] -> ShowS
forall k (ty :: k) (n :: Nat). SkipCount ty n -> String
showList :: [SkipCount ty n] -> ShowS
$cshowList :: forall k (ty :: k) (n :: Nat). [SkipCount ty n] -> ShowS
show :: SkipCount ty n -> String
$cshow :: forall k (ty :: k) (n :: Nat). SkipCount ty n -> String
showsPrec :: Int -> SkipCount ty n -> ShowS
$cshowsPrec :: forall k (ty :: k) (n :: Nat). Int -> SkipCount ty n -> ShowS
Show)
instance (Num ty, Binary ty, KnownNat n) => Binary (SkipCount ty n) where
get :: Get (SkipCount ty n)
get = Int -> Get ty -> Get ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ (Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> Int) -> Integer -> Int
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n)) (Get ty
forall t. Binary t => Get t
get :: Get ty) Get () -> SkipCount ty n -> Get (SkipCount ty n)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> SkipCount ty n
forall k (ty :: k) (n :: Nat). SkipCount ty n
SkipCount
put :: SkipCount ty n -> Put
put SkipCount ty n
_ = Int -> Put -> Put
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ (Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> Int) -> Integer -> Int
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n)) (Put -> Put) -> Put -> Put
forall a b. (a -> b) -> a -> b
$ ty -> Put
forall t. Binary t => t -> Put
put (ty
0 :: ty)
instance Arbitrary (SkipCount ty n) where
arbitrary :: Gen (SkipCount ty n)
arbitrary = SkipCount ty n -> Gen (SkipCount ty n)
forall (f :: * -> *) a. Applicative f => a -> f a
pure SkipCount ty n
forall k (ty :: k) (n :: Nat). SkipCount ty n
SkipCount
data SkipByte (n :: Nat) = SkipByte deriving (SkipByte n -> SkipByte n -> Bool
(SkipByte n -> SkipByte n -> Bool)
-> (SkipByte n -> SkipByte n -> Bool) -> Eq (SkipByte n)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (n :: Nat). SkipByte n -> SkipByte n -> Bool
/= :: SkipByte n -> SkipByte n -> Bool
$c/= :: forall (n :: Nat). SkipByte n -> SkipByte n -> Bool
== :: SkipByte n -> SkipByte n -> Bool
$c== :: forall (n :: Nat). SkipByte n -> SkipByte n -> Bool
Eq, Eq (SkipByte n)
Eq (SkipByte n)
-> (SkipByte n -> SkipByte n -> Ordering)
-> (SkipByte n -> SkipByte n -> Bool)
-> (SkipByte n -> SkipByte n -> Bool)
-> (SkipByte n -> SkipByte n -> Bool)
-> (SkipByte n -> SkipByte n -> Bool)
-> (SkipByte n -> SkipByte n -> SkipByte n)
-> (SkipByte n -> SkipByte n -> SkipByte n)
-> Ord (SkipByte n)
SkipByte n -> SkipByte n -> Bool
SkipByte n -> SkipByte n -> Ordering
SkipByte n -> SkipByte n -> SkipByte n
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall (n :: Nat). Eq (SkipByte n)
forall (n :: Nat). SkipByte n -> SkipByte n -> Bool
forall (n :: Nat). SkipByte n -> SkipByte n -> Ordering
forall (n :: Nat). SkipByte n -> SkipByte n -> SkipByte n
min :: SkipByte n -> SkipByte n -> SkipByte n
$cmin :: forall (n :: Nat). SkipByte n -> SkipByte n -> SkipByte n
max :: SkipByte n -> SkipByte n -> SkipByte n
$cmax :: forall (n :: Nat). SkipByte n -> SkipByte n -> SkipByte n
>= :: SkipByte n -> SkipByte n -> Bool
$c>= :: forall (n :: Nat). SkipByte n -> SkipByte n -> Bool
> :: SkipByte n -> SkipByte n -> Bool
$c> :: forall (n :: Nat). SkipByte n -> SkipByte n -> Bool
<= :: SkipByte n -> SkipByte n -> Bool
$c<= :: forall (n :: Nat). SkipByte n -> SkipByte n -> Bool
< :: SkipByte n -> SkipByte n -> Bool
$c< :: forall (n :: Nat). SkipByte n -> SkipByte n -> Bool
compare :: SkipByte n -> SkipByte n -> Ordering
$ccompare :: forall (n :: Nat). SkipByte n -> SkipByte n -> Ordering
$cp1Ord :: forall (n :: Nat). Eq (SkipByte n)
Ord, Int -> SkipByte n -> ShowS
[SkipByte n] -> ShowS
SkipByte n -> String
(Int -> SkipByte n -> ShowS)
-> (SkipByte n -> String)
-> ([SkipByte n] -> ShowS)
-> Show (SkipByte n)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (n :: Nat). Int -> SkipByte n -> ShowS
forall (n :: Nat). [SkipByte n] -> ShowS
forall (n :: Nat). SkipByte n -> String
showList :: [SkipByte n] -> ShowS
$cshowList :: forall (n :: Nat). [SkipByte n] -> ShowS
show :: SkipByte n -> String
$cshow :: forall (n :: Nat). SkipByte n -> String
showsPrec :: Int -> SkipByte n -> ShowS
$cshowsPrec :: forall (n :: Nat). Int -> SkipByte n -> ShowS
Show)
instance (KnownNat n) => Binary (SkipByte n) where
get :: Get (SkipByte n)
get = do Word8
nextByte <- Get Word8 -> Get Word8
forall a. Get a -> Get a
lookAhead Get Word8
forall t. Binary t => Get t
get
if Word8
nextByte Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
/= Word8
expected
then SkipByte n -> Get (SkipByte n)
forall (f :: * -> *) a. Applicative f => a -> f a
pure SkipByte n
forall (n :: Nat). SkipByte n
SkipByte
else (Get Word8
forall t. Binary t => Get t
get :: Get Word8) Get Word8 -> Get (SkipByte n) -> Get (SkipByte n)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Get (SkipByte n)
forall t. Binary t => Get t
get
where
expected :: Word8
expected :: Word8
expected = Integer -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Integer -> Word8) -> Integer -> Word8
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n)
put :: SkipByte n -> Put
put SkipByte n
_ = () -> Put
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
instance Arbitrary (SkipByte n) where
arbitrary :: Gen (SkipByte n)
arbitrary = SkipByte n -> Gen (SkipByte n)
forall (f :: * -> *) a. Applicative f => a -> f a
pure SkipByte n
forall (n :: Nat). SkipByte n
SkipByte
data MatchBytes (ctx :: Symbol) (bytes :: [Nat]) :: Type where
ConsumeNil :: MatchBytes ctx '[]
ConsumeCons :: KnownNat n => Proxy n -> MatchBytes ctx ns -> MatchBytes ctx (n ': ns)
deriving instance Eq (MatchBytes s ns)
deriving instance Ord (MatchBytes s ns)
instance Binary (MatchBytes ctx '[]) where
get :: Get (MatchBytes ctx '[])
get = MatchBytes ctx '[] -> Get (MatchBytes ctx '[])
forall (f :: * -> *) a. Applicative f => a -> f a
pure MatchBytes ctx '[]
forall (ctx :: Symbol). MatchBytes ctx '[]
ConsumeNil
put :: MatchBytes ctx '[] -> Put
put MatchBytes ctx '[]
_ = () -> Put
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
instance (KnownSymbol ctx, KnownNat n, Binary (MatchBytes ctx ns)) => Binary (MatchBytes ctx (n : ns)) where
get :: Get (MatchBytes ctx (n : ns))
get = do Word8
byte <- Get Word8
forall t. Binary t => Get t
get
Bool -> Get () -> Get ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Word8
byte Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
/= Word8
expected) (Get () -> Get ()) -> Get () -> Get ()
forall a b. (a -> b) -> a -> b
$ String -> Get ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get ()) -> String -> Get ()
forall a b. (a -> b) -> a -> b
$ String
"Unexpected byte 0x" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Word8 -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex Word8
byte String
", expected 0x"
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Word8 -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex Word8
expected String
" when parsing "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Proxy ctx -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal (Proxy ctx
forall k (t :: k). Proxy t
Proxy :: Proxy ctx)
Proxy n -> MatchBytes ctx ns -> MatchBytes ctx (n : ns)
forall (n :: Nat) (ctx :: Symbol) (ns :: [Nat]).
KnownNat n =>
Proxy n -> MatchBytes ctx ns -> MatchBytes ctx (n : ns)
ConsumeCons Proxy n
forall k (t :: k). Proxy t
Proxy (MatchBytes ctx ns -> MatchBytes ctx (n : ns))
-> Get (MatchBytes ctx ns) -> Get (MatchBytes ctx (n : ns))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (MatchBytes ctx ns)
forall t. Binary t => Get t
get
where
expected :: Word8
expected :: Word8
expected = Integer -> Word8
forall a. Num a => Integer -> a
fromInteger (Integer -> Word8) -> Integer -> Word8
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall k (t :: k). Proxy t
Proxy :: Proxy n)
put :: MatchBytes ctx (n : ns) -> Put
put (ConsumeCons Proxy n
proxy MatchBytes ctx ns
ns) = Word8 -> Put
forall t. Binary t => t -> Put
put Word8
theByte Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> MatchBytes ctx ns -> Put
forall t. Binary t => t -> Put
put MatchBytes ctx ns
ns
where
theByte :: Word8
theByte :: Word8
theByte = Integer -> Word8
forall a. Num a => Integer -> a
fromInteger (Integer -> Word8) -> Integer -> Word8
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal Proxy n
proxy
instance Show (MatchBytes ctx ns) where
show :: MatchBytes ctx ns -> String
show MatchBytes ctx ns
bs = String
"Marker [ " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> MatchBytes ctx ns -> String
forall (ctx :: Symbol) (ns :: [Nat]). MatchBytes ctx ns -> String
go MatchBytes ctx ns
bs String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"]"
where
go :: MatchBytes ctx' ns' -> String
go :: MatchBytes ctx' ns' -> String
go MatchBytes ctx' ns'
ConsumeNil = String
""
go (ConsumeCons Proxy n
proxy MatchBytes ctx' ns
ns) = String
"0x" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Integer -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex (Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal Proxy n
proxy) String
" " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> MatchBytes ctx' ns -> String
forall (ctx :: Symbol) (ns :: [Nat]). MatchBytes ctx ns -> String
go MatchBytes ctx' ns
ns
class MatchBytesSing ctx ns where
matchBytesSing :: MatchBytes ctx ns
instance MatchBytesSing ctx '[] where
matchBytesSing :: MatchBytes ctx '[]
matchBytesSing = MatchBytes ctx '[]
forall (ctx :: Symbol). MatchBytes ctx '[]
ConsumeNil
instance (KnownNat n, MatchBytesSing ctx ns) => MatchBytesSing ctx (n ': ns) where
matchBytesSing :: MatchBytes ctx (n : ns)
matchBytesSing = Proxy n -> MatchBytes ctx ns -> MatchBytes ctx (n : ns)
forall (n :: Nat) (ctx :: Symbol) (ns :: [Nat]).
KnownNat n =>
Proxy n -> MatchBytes ctx ns -> MatchBytes ctx (n : ns)
ConsumeCons Proxy n
forall k (t :: k). Proxy t
Proxy MatchBytes ctx ns
forall (ctx :: Symbol) (ns :: [Nat]).
MatchBytesSing ctx ns =>
MatchBytes ctx ns
matchBytesSing
matchBytes :: MatchBytesSing ctx ns => MatchBytes ctx ns
matchBytes :: MatchBytes ctx ns
matchBytes = MatchBytes ctx ns
forall (ctx :: Symbol) (ns :: [Nat]).
MatchBytesSing ctx ns =>
MatchBytes ctx ns
matchBytesSing
instance MatchBytesSing ctx ns => Arbitrary (MatchBytes ctx ns) where
arbitrary :: Gen (MatchBytes ctx ns)
arbitrary = MatchBytes ctx ns -> Gen (MatchBytes ctx ns)
forall (f :: * -> *) a. Applicative f => a -> f a
pure MatchBytes ctx ns
forall (ctx :: Symbol) (ns :: [Nat]).
MatchBytesSing ctx ns =>
MatchBytes ctx ns
matchBytes
type MatchByte ctx byte = MatchBytes ctx '[ byte ]
data MatchASCII (ctx :: Symbol) (ascii :: Symbol) where
ConsumeASCII :: KnownSymbol ascii => MatchASCII ctx ascii
deriving instance Eq (MatchASCII s ns)
deriving instance Ord (MatchASCII s ns)
toBytes :: forall ctx ascii. MatchASCII ctx ascii -> [Word8]
toBytes :: MatchASCII ctx ascii -> [Word8]
toBytes MatchASCII ctx ascii
ConsumeASCII = (Char -> Word8) -> String -> [Word8]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word8) -> (Char -> Int) -> Char -> Word8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) (String -> [Word8]) -> String -> [Word8]
forall a b. (a -> b) -> a -> b
$ Proxy ascii -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal (Proxy ascii
forall k (t :: k). Proxy t
Proxy :: Proxy ascii)
instance (KnownSymbol ctx, KnownSymbol ascii) => Binary (MatchASCII ctx ascii) where
get :: Get (MatchASCII ctx ascii)
get = do [Word8]
bytes <- Int -> Get Word8 -> Get [Word8]
forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM ([Word8] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Word8]
expected) Get Word8
forall t. Binary t => Get t
get
Bool -> Get () -> Get ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ([Word8]
bytes [Word8] -> [Word8] -> Bool
forall a. Eq a => a -> a -> Bool
/= [Word8]
expected) (Get () -> Get ()) -> Get () -> Get ()
forall a b. (a -> b) -> a -> b
$ String -> Get ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get ()) -> String -> Get ()
forall a b. (a -> b) -> a -> b
$ String
"Unexpected bytes " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> [Word8] -> String
forall a. Show a => a -> String
show [Word8]
bytes
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" (or, as ASCII, `" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> (Int -> Char
chr (Int -> Char) -> (Word8 -> Int) -> Word8 -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word8 -> Char) -> [Word8] -> String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Word8]
bytes) String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"`)"
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" when parsing" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Proxy ctx -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal (Proxy ctx
forall k (t :: k). Proxy t
Proxy :: Proxy ctx)
MatchASCII ctx ascii -> Get (MatchASCII ctx ascii)
forall (f :: * -> *) a. Applicative f => a -> f a
pure MatchASCII ctx ascii
forall (ctx :: Symbol). MatchASCII ctx ascii
resSing
where
resSing :: MatchASCII ctx ascii
resSing = MatchASCII ctx ascii
forall (ascii :: Symbol) (ctx :: Symbol).
KnownSymbol ascii =>
MatchASCII ctx ascii
ConsumeASCII
expected :: [Word8]
expected = MatchASCII Any ascii -> [Word8]
forall (ctx :: Symbol) (ascii :: Symbol).
MatchASCII ctx ascii -> [Word8]
toBytes MatchASCII Any ascii
forall (ctx :: Symbol). MatchASCII ctx ascii
resSing
put :: MatchASCII ctx ascii -> Put
put = (Word8 -> Put) -> [Word8] -> Put
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Word8 -> Put
forall t. Binary t => t -> Put
put ([Word8] -> Put)
-> (MatchASCII ctx ascii -> [Word8]) -> MatchASCII ctx ascii -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MatchASCII ctx ascii -> [Word8]
forall (ctx :: Symbol) (ascii :: Symbol).
MatchASCII ctx ascii -> [Word8]
toBytes
instance Show (MatchASCII ctx ascii) where
show :: MatchASCII ctx ascii -> String
show MatchASCII ctx ascii
ConsumeASCII = String
"Marker [ " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Proxy ascii -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal (Proxy ascii
forall k (t :: k). Proxy t
Proxy :: Proxy ascii) String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" ]"
instance (KnownSymbol ctx, KnownSymbol ascii) => Arbitrary (MatchASCII ctx ascii) where
arbitrary :: Gen (MatchASCII ctx ascii)
arbitrary = MatchASCII ctx ascii -> Gen (MatchASCII ctx ascii)
forall (f :: * -> *) a. Applicative f => a -> f a
pure MatchASCII ctx ascii
forall (ctx :: Symbol) (ascii :: Symbol).
(KnownSymbol ctx, KnownSymbol ascii) =>
MatchASCII ctx ascii
matchASCII
matchASCII :: (KnownSymbol ctx, KnownSymbol ascii) => MatchASCII ctx ascii
matchASCII :: MatchASCII ctx ascii
matchASCII = MatchASCII ctx ascii
forall (ascii :: Symbol) (ctx :: Symbol).
KnownSymbol ascii =>
MatchASCII ctx ascii
ConsumeASCII
newtype LE a = LE { LE a -> a
getLE :: a } deriving (LE a -> LE a -> Bool
(LE a -> LE a -> Bool) -> (LE a -> LE a -> Bool) -> Eq (LE a)
forall a. Eq a => LE a -> LE a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LE a -> LE a -> Bool
$c/= :: forall a. Eq a => LE a -> LE a -> Bool
== :: LE a -> LE a -> Bool
$c== :: forall a. Eq a => LE a -> LE a -> Bool
Eq, Eq (LE a)
Eq (LE a)
-> (LE a -> LE a -> Ordering)
-> (LE a -> LE a -> Bool)
-> (LE a -> LE a -> Bool)
-> (LE a -> LE a -> Bool)
-> (LE a -> LE a -> Bool)
-> (LE a -> LE a -> LE a)
-> (LE a -> LE a -> LE a)
-> Ord (LE a)
LE a -> LE a -> Bool
LE a -> LE a -> Ordering
LE a -> LE a -> LE a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (LE a)
forall a. Ord a => LE a -> LE a -> Bool
forall a. Ord a => LE a -> LE a -> Ordering
forall a. Ord a => LE a -> LE a -> LE a
min :: LE a -> LE a -> LE a
$cmin :: forall a. Ord a => LE a -> LE a -> LE a
max :: LE a -> LE a -> LE a
$cmax :: forall a. Ord a => LE a -> LE a -> LE a
>= :: LE a -> LE a -> Bool
$c>= :: forall a. Ord a => LE a -> LE a -> Bool
> :: LE a -> LE a -> Bool
$c> :: forall a. Ord a => LE a -> LE a -> Bool
<= :: LE a -> LE a -> Bool
$c<= :: forall a. Ord a => LE a -> LE a -> Bool
< :: LE a -> LE a -> Bool
$c< :: forall a. Ord a => LE a -> LE a -> Bool
compare :: LE a -> LE a -> Ordering
$ccompare :: forall a. Ord a => LE a -> LE a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (LE a)
Ord)
instance Show a => Show (LE a) where
show :: LE a -> String
show = a -> String
forall a. Show a => a -> String
show (a -> String) -> (LE a -> a) -> LE a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LE a -> a
forall a. LE a -> a
getLE
instance Arbitrary a => Arbitrary (LE a) where
arbitrary :: Gen (LE a)
arbitrary = a -> LE a
forall a. a -> LE a
LE (a -> LE a) -> Gen a -> Gen (LE a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen a
forall a. Arbitrary a => Gen a
arbitrary
shrink :: LE a -> [LE a]
shrink (LE a
n) = a -> LE a
forall a. a -> LE a
LE (a -> LE a) -> [a] -> [LE a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> [a]
forall a. Arbitrary a => a -> [a]
shrink a
n
instance Binary (LE Word16) where
get :: Get (LE Word16)
get = Word16 -> LE Word16
forall a. a -> LE a
LE (Word16 -> LE Word16) -> Get Word16 -> Get (LE Word16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word16
getWord16le
put :: LE Word16 -> Put
put = Word16 -> Put
putWord16le (Word16 -> Put) -> (LE Word16 -> Word16) -> LE Word16 -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LE Word16 -> Word16
forall a. LE a -> a
getLE
instance Binary (LE Word32) where
get :: Get (LE Word32)
get = Word32 -> LE Word32
forall a. a -> LE a
LE (Word32 -> LE Word32) -> Get Word32 -> Get (LE Word32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word32
getWord32le
put :: LE Word32 -> Put
put = Word32 -> Put
putWord32le (Word32 -> Put) -> (LE Word32 -> Word32) -> LE Word32 -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LE Word32 -> Word32
forall a. LE a -> a
getLE
instance Binary (LE Word64) where
get :: Get (LE Word64)
get = Word64 -> LE Word64
forall a. a -> LE a
LE (Word64 -> LE Word64) -> Get Word64 -> Get (LE Word64)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word64
getWord64le
put :: LE Word64 -> Put
put = Word64 -> Put
putWord64le (Word64 -> Put) -> (LE Word64 -> Word64) -> LE Word64 -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LE Word64 -> Word64
forall a. LE a -> a
getLE
instance Binary (LE Int16) where
get :: Get (LE Int16)
get = Int16 -> LE Int16
forall a. a -> LE a
LE (Int16 -> LE Int16) -> Get Int16 -> Get (LE Int16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Int16
getInt16le
put :: LE Int16 -> Put
put = Int16 -> Put
putInt16le (Int16 -> Put) -> (LE Int16 -> Int16) -> LE Int16 -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LE Int16 -> Int16
forall a. LE a -> a
getLE
instance Binary (LE Int32) where
get :: Get (LE Int32)
get = Int32 -> LE Int32
forall a. a -> LE a
LE (Int32 -> LE Int32) -> Get Int32 -> Get (LE Int32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Int32
getInt32le
put :: LE Int32 -> Put
put = Int32 -> Put
putInt32le (Int32 -> Put) -> (LE Int32 -> Int32) -> LE Int32 -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LE Int32 -> Int32
forall a. LE a -> a
getLE
instance Binary (LE Int64) where
get :: Get (LE Int64)
get = Int64 -> LE Int64
forall a. a -> LE a
LE (Int64 -> LE Int64) -> Get Int64 -> Get (LE Int64)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Int64
getInt64le
put :: LE Int64 -> Put
put = Int64 -> Put
putInt64le (Int64 -> Put) -> (LE Int64 -> Int64) -> LE Int64 -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LE Int64 -> Int64
forall a. LE a -> a
getLE
instance Binary (LE Float) where
get :: Get (LE Float)
get = Float -> LE Float
forall a. a -> LE a
LE (Float -> LE Float) -> Get Float -> Get (LE Float)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Float
getFloatle
put :: LE Float -> Put
put = Float -> Put
putFloatle (Float -> Put) -> (LE Float -> Float) -> LE Float -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LE Float -> Float
forall a. LE a -> a
getLE
instance Binary (LE Double) where
get :: Get (LE Double)
get = Double -> LE Double
forall a. a -> LE a
LE (Double -> LE Double) -> Get Double -> Get (LE Double)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Double
getDoublele
put :: LE Double -> Put
put = Double -> Put
putDoublele (Double -> Put) -> (LE Double -> Double) -> LE Double -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LE Double -> Double
forall a. LE a -> a
getLE