packages feed

binrep 1.0.0 → 1.1.0

raw patch · 18 files changed

+98/−99 lines, 18 filesdep −strongweakdep ~rerefinedPVP ok

version bump matches the API change (PVP)

Dependencies removed: strongweak

Dependency ranges changed: rerefined

API changes (from Hackage documentation)

- Binrep.Example.Tga: HasColorMap :: ColorMapType
- Binrep.Example.Tga: Header :: SW s Word8 -> ColorMapType -> ImageType -> Header (s :: Strength) (a :: k)
- Binrep.Example.Tga: NoColorMap :: ColorMapType
- Binrep.Example.Tga: NoImageData :: ImageType
- Binrep.Example.Tga: RLEBW :: ImageType
- Binrep.Example.Tga: RLEColorMapped :: ImageType
- Binrep.Example.Tga: RLETrueColor :: ImageType
- Binrep.Example.Tga: UncompBW :: ImageType
- Binrep.Example.Tga: UncompColorMapped :: ImageType
- Binrep.Example.Tga: UncompTrueColor :: ImageType
- Binrep.Example.Tga: [colorMapType] :: Header (s :: Strength) (a :: k) -> ColorMapType
- Binrep.Example.Tga: [idLen] :: Header (s :: Strength) (a :: k) -> SW s Word8
- Binrep.Example.Tga: [imageType] :: Header (s :: Strength) (a :: k) -> ImageType
- Binrep.Example.Tga: data ColorMapType
- Binrep.Example.Tga: data Header (s :: Strength) (a :: k)
- Binrep.Example.Tga: data ImageType
- Binrep.Get: instance (Raehik.Compat.Data.Primitive.Types.Prim' a, Raehik.Compat.Data.Primitive.Types.Endian.ByteSwap a) => Binrep.Get.Get (Raehik.Compat.Data.Primitive.Types.Endian.ByteOrdered 'GHC.ByteOrder.BigEndian a)
- Binrep.Get: instance (Raehik.Compat.Data.Primitive.Types.Prim' a, Raehik.Compat.Data.Primitive.Types.Endian.ByteSwap a) => Binrep.Get.Get (Raehik.Compat.Data.Primitive.Types.Endian.ByteOrdered 'GHC.ByteOrder.LittleEndian a)
- Binrep.Get: instance Binrep.Get.Get a => Binrep.Get.Get (Data.Functor.Identity.Identity a)
- Binrep.Get: instance Raehik.Compat.Data.Primitive.Types.Prim' a => Binrep.Get.Get (Binrep.Common.Via.Prim.ViaPrim a)
- Binrep.Get.Struct: instance Binrep.Get.Struct.GetC a => Binrep.Get.Struct.GetC (Data.Functor.Identity.Identity a)
- Binrep.Put: instance Binrep.Put.Put a => Binrep.Put.Put (Data.Functor.Identity.Identity a)
- Binrep.Put.Struct: instance Binrep.Put.Struct.PutC a => Binrep.Put.Struct.PutC (Data.Functor.Identity.Identity a)
- Binrep.Type.Magic: instance forall k (a :: k). Strongweak.Strengthen.Strengthen (Binrep.Type.Magic.Magic a)
- Binrep.Type.Magic: instance forall k (a :: k). Strongweak.Weaken.Weaken (Binrep.Type.Magic.Magic a)
- Binrep.Type.Thin: instance Strongweak.Strengthen.Strengthen (Binrep.Type.Thin.Thin a)
- Binrep.Type.Thin: instance Strongweak.Weaken.Weaken (Binrep.Type.Thin.Thin a)
- Binrep.Util.ByteOrder: instance Strongweak.Strengthen.Strengthen a => Strongweak.Strengthen.Strengthen (Raehik.Compat.Data.Primitive.Types.Endian.ByteOrdered end a)
- Binrep.Util.ByteOrder: instance Strongweak.Weaken.Weaken a => Strongweak.Weaken.Weaken (Raehik.Compat.Data.Primitive.Types.Endian.ByteOrdered end a)
+ Binrep.Get: instance (Raehik.Compat.Data.Primitive.Types.Prim' a, Data.Typeable.Internal.Typeable a) => Binrep.Get.Get (Binrep.Common.Via.Prim.ViaPrim a)
+ Binrep.Get: instance (Raehik.Compat.Data.Primitive.Types.Prim' a, Raehik.Compat.Data.Primitive.Types.Endian.ByteSwap a, Data.Typeable.Internal.Typeable a) => Binrep.Get.Get (Raehik.Compat.Data.Primitive.Types.Endian.ByteOrdered 'GHC.ByteOrder.BigEndian a)
+ Binrep.Get: instance (Raehik.Compat.Data.Primitive.Types.Prim' a, Raehik.Compat.Data.Primitive.Types.Endian.ByteSwap a, Data.Typeable.Internal.Typeable a) => Binrep.Get.Get (Raehik.Compat.Data.Primitive.Types.Endian.ByteOrdered 'GHC.ByteOrder.LittleEndian a)
+ Binrep.Get: typeRep' :: forall {k} (a :: k). Typeable a => TypeRep
+ Raehik.Compat.FlatParse.Basic.Remaining: remaining :: forall (st :: ZeroBitType) e. ParserT st e Int
- Binrep.Get: getPrim :: Prim' a => Getter a
+ Binrep.Get: getPrim :: (Prim' a, Typeable a) => Getter a

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+## 1.1.0 (2025-03-11)+* remove strongweak integration+  * to be released in separate package binrep-instances+* update rerefined+ ## 1.0.0 (2024-10-03) * fix `NullTerminate` check being inverted (OOPS LOL) * fix `Get [a]` instance (list backwards xd)
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2022-2024 Ben Orchard (@raehik) <thefirstmuffinman@gmail.com>+Copyright (c) 2022-2025 Ben Orchard (@raehik) <thefirstmuffinman@gmail.com>  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
binrep.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           binrep-version:        1.0.0+version:        1.1.0 synopsis:       Encode precise binary representations directly in types description:    Please see README.md. category:       Data, Serialization, Generics@@ -68,6 +68,7 @@       Binrep.Util.Generic       Raehik.Compat.FlatParse.Basic.CutWithPos       Raehik.Compat.FlatParse.Basic.Prim+      Raehik.Compat.FlatParse.Basic.Remaining       Raehik.Compat.FlatParse.Basic.WithLength       Util.TypeNats   other-modules:@@ -85,7 +86,7 @@       TypeFamilies       DataKinds       MagicHash-  ghc-options: -Wall -Wno-unticked-promoted-constructors+  ghc-options: -fhide-source-paths -Wall   build-depends:       base >=4.18 && <5     , bytestring >=0.11 && <0.13@@ -98,8 +99,7 @@     , generic-type-functions >=0.1.0 && <0.2     , ghc-bignum ==1.3.*     , parser-combinators >=1.3.0 && <1.4-    , rerefined >=0.6.0 && <0.7-    , strongweak >=0.9.1 && <0.10+    , rerefined >=0.8.0 && <0.9     , text >=2.0 && <2.2     , text-builder-linear >=0.1.3 && <0.2     , type-level-bytestrings >=0.1.0 && <0.3@@ -131,7 +131,7 @@       TypeFamilies       DataKinds       MagicHash-  ghc-options: -Wall -Wno-unticked-promoted-constructors+  ghc-options: -fhide-source-paths -Wall   build-tool-depends:       hspec-discover:hspec-discover >=2.7 && <2.12   build-depends:@@ -151,8 +151,7 @@     , hspec >=2.7 && <2.12     , parser-combinators >=1.3.0 && <1.4     , quickcheck-instances >=0.3.26 && <0.4-    , rerefined >=0.6.0 && <0.7-    , strongweak >=0.9.1 && <0.10+    , rerefined >=0.8.0 && <0.9     , text >=2.0 && <2.2     , text-builder-linear >=0.1.3 && <0.2     , type-level-bytestrings >=0.1.0 && <0.3@@ -181,7 +180,7 @@       TypeFamilies       DataKinds       MagicHash-  ghc-options: -Wall -Wno-unticked-promoted-constructors+  ghc-options: -fhide-source-paths -Wall   build-depends:       base >=4.18 && <5     , binrep@@ -196,8 +195,7 @@     , generic-type-functions >=0.1.0 && <0.2     , ghc-bignum ==1.3.*     , parser-combinators >=1.3.0 && <1.4-    , rerefined >=0.6.0 && <0.7-    , strongweak >=0.9.1 && <0.10+    , rerefined >=0.8.0 && <0.9     , text >=2.0 && <2.2     , text-builder-linear >=0.1.3 && <0.2     , type-level-bytestrings >=0.1.0 && <0.3
src/Binrep/BLen.hs view
@@ -128,6 +128,8 @@ deriving via ViaCBLen  Int32 instance BLen  Int32 deriving via ViaCBLen Word64 instance BLen Word64 deriving via ViaCBLen  Int64 instance BLen  Int64++-- | Explicitness does not alter length. deriving via ViaCBLen (ByteOrdered end a)     instance KnownNat (CBLen a) => BLen (ByteOrdered end a) 
src/Binrep/CBLen.hs view
@@ -53,8 +53,8 @@ instance IsCBLen Word64 where type CBLen Word64 = 2^3 instance IsCBLen  Int64 where type CBLen  Int64 = 2^3 -instance IsCBLen a => IsCBLen (ByteOrdered end a) where-    type CBLen (ByteOrdered end a) = CBLen a+-- | Endianness does not alter constant length.+deriving via (a :: Type) instance IsCBLen a => IsCBLen (ByteOrdered end a)  -- | Reify a type's constant byte length to the term level. cblen :: forall a. KnownNat (CBLen a) => Int
src/Binrep/Example/Tga.hs view
@@ -1,6 +1,8 @@ module Binrep.Example.Tga where  {-++{- import Binrep import Binrep.Type.Derived.NullTermPadded import Binrep.Type.AsciiNat@@ -26,3 +28,5 @@   | RLEColorMapped   | RLETrueColor   | RLEBW++-}
src/Binrep/Get.hs view
@@ -9,9 +9,10 @@  import Binrep.Get.Error import Data.Text.Builder.Linear qualified as TBL+import GHC.Exts ( fromString ) import Binrep.Util.ByteOrder import Binrep.Common.Via.Prim ( ViaPrim(..) )-import Raehik.Compat.Data.Primitive.Types ( Prim' )+import Raehik.Compat.Data.Primitive.Types ( Prim', sizeOf ) import Raehik.Compat.Data.Primitive.Types.Endian ( ByteSwap )  import Binrep.Get.Struct ( GetC(getC), GetterC )@@ -22,6 +23,7 @@ import FlatParse.Basic qualified as FP import Raehik.Compat.FlatParse.Basic.Prim qualified as FP import Raehik.Compat.FlatParse.Basic.CutWithPos qualified as FP+import Raehik.Compat.FlatParse.Basic.Remaining qualified as FP  import Data.ByteString qualified as B @@ -41,13 +43,14 @@ import Data.Word import Data.Int import Data.Void-import Data.Functor.Identity import Binrep.Common.Via.Generically.NonSum  import Generic.Data.FOnCstr import Generic.Data.Function.Traverse.Constructor hiding ( ENoEmpty ) import GHC.Exts ( Proxy# ) +import Data.Typeable ( Typeable, TypeRep, typeRep, Proxy(Proxy) )+ type Getter = FP.Parser (ParseError FP.Pos TBL.Builder)  class Get a where@@ -216,8 +219,6 @@  -} -instance Get a => Get (Identity a) where get = Identity <$> get- -- | Unit type parses nothing. instance Get () where     {-# INLINE get #-}@@ -265,17 +266,32 @@ deriving via  Int8 instance Get (ByteOrdered end  Int8)  -- | Parse any 'Prim''.-getPrim :: forall a. Prim' a => Getter a-getPrim = FP.anyPrim `FP.cut'` parseError1 ["IDK"]+getPrim :: forall a. (Prim' a, Typeable a) => Getter a+getPrim = do+    lenAvail <- FP.remaining+    FP.anyPrim `cut1`+        [  "ran out of bytes while parsing " <> strTR+        <> ", needed "    <> strLenNeed+        <> ", remaining " <> TBL.fromDec lenAvail+        ]+  where+    strTR       = fromString (show (typeRep' @a))+    strLenNeed  = TBL.fromDec (sizeOf (undefined :: a)) -instance Prim' a => Get (ViaPrim a) where get = ViaPrim <$> getPrim+typeRep' :: forall a. Typeable a => TypeRep+typeRep' = typeRep (Proxy @a) +instance (Prim' a, Typeable a) => Get (ViaPrim a) where+    get = ViaPrim <$> getPrim+ -- ByteSwap is required on opposite endian platforms, but we're not checking -- here, so make sure to keep it on both.-deriving via ViaPrim (ByteOrdered 'LittleEndian a)-    instance (Prim' a, ByteSwap a) => Get (ByteOrdered 'LittleEndian a)-deriving via ViaPrim (ByteOrdered    'BigEndian a)-    instance (Prim' a, ByteSwap a) => Get (ByteOrdered    'BigEndian a)+deriving via ViaPrim (ByteOrdered LittleEndian a)+    instance (Prim' a, ByteSwap a, Typeable a)+      => Get (ByteOrdered LittleEndian a)+deriving via ViaPrim (ByteOrdered    BigEndian a)+    instance (Prim' a, ByteSwap a, Typeable a)+      => Get (ByteOrdered    BigEndian a)  instance Get (Refined pr (Refined pl a)) => Get (Refined (pl `And` pr) a) where     get = (unsafeRefine . unrefine @pl . unrefine @pr) <$> get
src/Binrep/Get/Struct.hs view
@@ -25,7 +25,6 @@ import Data.Word ( Word8 ) import Data.Int ( Int8 ) import Binrep.Util.ByteOrder-import Data.Functor.Identity import Raehik.Compat.Data.Primitive.Types.Endian ( ByteSwap )  import Data.ByteString qualified as B@@ -127,8 +126,6 @@     getC = ViaPrim <$> prim     {-# INLINE getC #-} -instance GetC a => GetC (Identity a) where getC = Identity <$> getC- deriving via ViaPrim Word8 instance GetC Word8 deriving via ViaPrim  Int8 instance GetC  Int8 deriving via Word8 instance GetC (ByteOrdered end Word8)@@ -136,23 +133,7 @@  -- ByteSwap is required on opposite endian platforms, but we're not checking -- here, so make sure to keep it on both.-deriving via ViaPrim (ByteOrdered 'LittleEndian a)-    instance (Prim' a, ByteSwap a) => GetC (ByteOrdered 'LittleEndian a)-deriving via ViaPrim (ByteOrdered    'BigEndian a)-    instance (Prim' a, ByteSwap a) => GetC (ByteOrdered    'BigEndian a)--{---instance TypeError ENoEmpty => PutC Void where putC = undefined-instance TypeError ENoSum => PutC (Either a b) where putC = undefined--instance PutC a => PutC (Identity a) where putC = putC . runIdentity--instance PutC PutterC where putC = id---- | Look weird? Yeah. But it's correct :)-instance (PutC l, KnownNat (CBLen l), PutC r) => PutC (l, r) where-    {-# INLINE putC #-}-    putC (l, r) = sequencePokes (putC l) (cblen @l) (putC r)---}+deriving via ViaPrim (ByteOrdered LittleEndian a)+    instance (Prim' a, ByteSwap a) => GetC (ByteOrdered LittleEndian a)+deriving via ViaPrim (ByteOrdered    BigEndian a)+    instance (Prim' a, ByteSwap a) => GetC (ByteOrdered    BigEndian a)
src/Binrep/Put.hs view
@@ -31,7 +31,6 @@ import Data.Word import Data.Int import Data.Void-import Data.Functor.Identity import Binrep.Common.Via.Generically.NonSum  type Putter = Poke RealWorld@@ -90,8 +89,6 @@ instance TypeError ENoEmpty => Put Void where put = undefined instance TypeError ENoSum => Put (Either a b) where put = undefined -instance Put a => Put (Identity a) where put = put . runIdentity- instance Put Putter where put = id  -- | Unit type serializes to nothing. How zen.@@ -128,10 +125,10 @@ -- ByteSwap is required on opposite endian platforms, but we're not checking -- here, so make sure to keep it on both. -- Stick with ViaPrim here because ByteOrdered is connected to it.-deriving via ViaPrim (ByteOrdered 'LittleEndian a)-    instance (Prim' a, ByteSwap a) => Put (ByteOrdered 'LittleEndian a)-deriving via ViaPrim (ByteOrdered    'BigEndian a)-    instance (Prim' a, ByteSwap a) => Put (ByteOrdered    'BigEndian a)+deriving via ViaPrim (ByteOrdered LittleEndian a)+    instance (Prim' a, ByteSwap a) => Put (ByteOrdered LittleEndian a)+deriving via ViaPrim (ByteOrdered    BigEndian a)+    instance (Prim' a, ByteSwap a) => Put (ByteOrdered    BigEndian a)  -- | Put types refined with multiple predicates by wrapping the left --   predicate with the right. LOL REALLY?
src/Binrep/Put/Struct.hs view
@@ -15,7 +15,6 @@ import Data.Word import Data.Int import Binrep.Util.ByteOrder-import Data.Functor.Identity import Raehik.Compat.Data.Primitive.Types.Endian ( ByteSwap )  import Binrep.Common.Class.TypeErrors ( ENoSum, ENoEmpty )@@ -74,8 +73,6 @@ instance TypeError ENoEmpty => PutC Void where putC = undefined instance TypeError ENoSum => PutC (Either a b) where putC = undefined -instance PutC a => PutC (Identity a) where putC = putC . runIdentity- instance PutC PutterC where putC = id  -- | Unit type serializes to nothing. How zen.@@ -104,7 +101,7 @@  -- ByteSwap is required on opposite endian platforms, but we're not checking -- here, so make sure to keep it on both.-deriving via ViaPrim (ByteOrdered 'LittleEndian a)-    instance (Prim' a, ByteSwap a) => PutC (ByteOrdered 'LittleEndian a)-deriving via ViaPrim (ByteOrdered    'BigEndian a)-    instance (Prim' a, ByteSwap a) => PutC (ByteOrdered    'BigEndian a)+deriving via ViaPrim (ByteOrdered LittleEndian a)+    instance (Prim' a, ByteSwap a) => PutC (ByteOrdered LittleEndian a)+deriving via ViaPrim (ByteOrdered    BigEndian a)+    instance (Prim' a, ByteSwap a) => PutC (ByteOrdered    BigEndian a)
src/Binrep/Type/AsciiNat.hs view
@@ -45,6 +45,18 @@  import Data.Text.Builder.Linear qualified as TBL +{- TODO 2024-10-15 raehik++Should this be a newtype over @a@ where we don't check for >0 ?+After doing some thinking about strongweak vs. generic coerce, I kind of want to+handle cases where we don't really do a check/make a value-level change.+This is the closest I have.++Maybe I want a @Tagged@-like newtype in strongweak that states "strengthen+through the given type as if it's a newtype (that can be coerced)". Maybe that+gets me what I want. @ByteOrdered@ would then use it too.+-}+ -- | A natural represented in binary as an ASCII string, where each character is --   a digit in the given base. --@@ -61,7 +73,7 @@  instance (KnownPredicateName (AsciiNat base), Num a, Ord a)   => Refine (AsciiNat base) a where-    validate = validateVia @(CompareValue GTE Pos 0)+    validate = validateVia @(CompareValue RelOpGTE Pos 0)  -- | Compare two 'AsciiNat's, ignoring base information. asciiNatCompare
src/Binrep/Type/Magic.hs view
@@ -26,7 +26,6 @@  import GHC.Generics ( Generic ) import Data.Data ( Data )-import Strongweak  import Binrep import Bytezap.Struct.TypeLits.Bytes ( ReifyBytesW64(reifyBytesW64) )@@ -48,14 +47,6 @@ -} data Magic a where Magic :: forall {k} (a :: k). Magic a     deriving stock (Generic, Data, Show, Eq)---- | Weaken a @'Magic' a@ to the unit '()'.-instance Weaken (Magic a) where-    type Weak (Magic a) = ()-    weaken Magic = ()---- | Strengthen the unit '()' to some @'Magic' a@.-instance Strengthen (Magic a) where strengthen () = Right Magic  -- | The byte length of a magic is known at compile time. instance IsCBLen (Magic a) where type CBLen (Magic a) = Length (MagicBytes a)
src/Binrep/Type/Text/Encoding/Utf16.hs view
@@ -15,11 +15,11 @@ instance Predicate (Utf16 end) where     type PredicateName d (Utf16 end) = "UTF-16" ++ EndianSuffix end +-- | Any 'Text' value is always valid UTF-16.+instance Refine (Utf16 end) Text where validate _ _ = Nothing+ instance Encode (Utf16 BE) where encode' = Text.encodeUtf16BE instance Encode (Utf16 LE) where encode' = Text.encodeUtf16LE  instance Decode (Utf16 BE) where decode = decodeText show $ wrapUnsafeDecoder Text.decodeUtf16BE instance Decode (Utf16 LE) where decode = decodeText show $ wrapUnsafeDecoder Text.decodeUtf16LE---- | Any 'Text' value is always valid UTF-16.-instance Refine (Utf16 end) Text where validate _ _ = Nothing
src/Binrep/Type/Text/Encoding/Utf32.hs view
@@ -15,11 +15,11 @@ instance Predicate (Utf32 end) where     type PredicateName d (Utf32 end) = "UTF-32" ++ EndianSuffix end +-- | Any 'Text' value is always valid UTF-32.+instance Refine (Utf32 end) Text where validate _ _ = Nothing+ instance Encode (Utf32 BE) where encode' = Text.encodeUtf32BE instance Encode (Utf32 LE) where encode' = Text.encodeUtf32LE  instance Decode (Utf32 BE) where decode = decodeText show $ wrapUnsafeDecoder Text.decodeUtf32BE instance Decode (Utf32 LE) where decode = decodeText show $ wrapUnsafeDecoder Text.decodeUtf32LE---- | Any 'Text' value is always valid UTF-32.-instance Refine (Utf32 end) Text where validate _ _ = Nothing
src/Binrep/Type/Text/Encoding/Utf8.hs view
@@ -10,8 +10,8 @@ data Utf8 instance Predicate Utf8 where type PredicateName d Utf8 = "UTF-8" -instance Encode Utf8 where encode' = Text.encodeUtf8-instance Decode Utf8 where decode  = decodeText show Text.decodeUtf8'- -- | Any 'Text' value is always valid UTF-8. instance Refine Utf8 Text where validate _ _ = Nothing++instance Encode Utf8 where encode' = Text.encodeUtf8+instance Decode Utf8 where decode  = decodeText show Text.decodeUtf8'
src/Binrep/Type/Thin.hs view
@@ -15,11 +15,8 @@ @  But this just doesn't fly, because it would invert the behaviour.- -} -{-# LANGUAGE UndecidableInstances #-} -- for strongweak derivingvia- module Binrep.Type.Thin where  import Binrep@@ -31,8 +28,6 @@ import GHC.Exts ( IsList ) import Data.String import Control.DeepSeq-import Data.Functor.Identity-import Strongweak  import Data.ByteString qualified as B @@ -44,8 +39,5 @@       , NFData, IsString, IsList -- weird       , BLen, Put -- binrep       ) via a--    -- at the end of the day, we are the identity functor-    deriving (Weaken, Strengthen) via Identity a  instance Get (Thin B.ByteString) where get = Thin <$> FP.takeRest
src/Binrep/Util/ByteOrder.hs view
@@ -1,5 +1,3 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}- module Binrep.Util.ByteOrder   ( ByteOrder(..), ByteOrdered(..), type EndianSuffix   , type LE, type BE, type Endian@@ -7,18 +5,13 @@  import Raehik.Compat.Data.Primitive.Types.Endian ( ByteOrdered(..) ) import GHC.ByteOrder ( ByteOrder(..) )-import Strongweak-import Data.Kind ( type Type ) import GHC.TypeLits ( type Symbol ) -deriving via (a :: Type) instance     Weaken a =>     Weaken (ByteOrdered end a)-deriving via (a :: Type) instance Strengthen a => Strengthen (ByteOrdered end a)- -- shorter names I originally used-type LE = 'LittleEndian-type BE =    'BigEndian+type LE = LittleEndian+type BE =    BigEndian type Endian = ByteOrdered  type family EndianSuffix (end :: ByteOrder) :: Symbol where-    EndianSuffix 'LittleEndian = "LE"-    EndianSuffix    'BigEndian = "BE"+    EndianSuffix LittleEndian = "LE"+    EndianSuffix    BigEndian = "BE"
+ src/Raehik/Compat/FlatParse/Basic/Remaining.hs view
@@ -0,0 +1,11 @@+{-# LANGUAGE PatternSynonyms #-}++module Raehik.Compat.FlatParse.Basic.Remaining where++import FlatParse.Basic.Parser ( ParserT(ParserT), pattern OK# )+import GHC.Exts ( minusAddr#, Int(I#) )++-- | Get the remaining length. May return 0.+remaining :: ParserT st e Int+remaining = ParserT $ \_fp eob s st -> OK# st (I# (minusAddr# eob s)) s+{-# inline remaining #-}