From dd882da21a5a200429e79ab0ffc4ec997992a219 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 2 Nov 2021 18:01:12 -0400 Subject: [PATCH 1/2] Prim.Notations error --- .gitmodules | 3 + examples/bytestring/.gitignore | 2 + examples/bytestring/README.md | 3 + examples/bytestring/bytestring | 1 + examples/bytestring/edits | 63 + examples/bytestring/lib/Data/ByteString.h2ci | 1 + examples/bytestring/lib/Data/ByteString.v | 1797 ++++++++++++++++ .../lib/Data/ByteString/Builder.h2ci | 1 + .../bytestring/lib/Data/ByteString/Builder.v | 94 + .../lib/Data/ByteString/Builder/ASCII.h2ci | 1 + .../lib/Data/ByteString/Builder/ASCII.v | 308 +++ .../lib/Data/ByteString/Builder/Extra.h2ci | 12 + .../lib/Data/ByteString/Builder/Extra.v | 145 ++ .../lib/Data/ByteString/Builder/Internal.h2ci | 52 + .../lib/Data/ByteString/Builder/Internal.v | 243 +++ .../lib/Data/ByteString/Builder/Prim.h2ci | 1 + .../lib/Data/ByteString/Builder/Prim.v | 333 +++ .../Data/ByteString/Builder/Prim/ASCII.h2ci | 1 + .../lib/Data/ByteString/Builder/Prim/ASCII.v | 213 ++ .../Data/ByteString/Builder/Prim/Binary.h2ci | 1 + .../lib/Data/ByteString/Builder/Prim/Binary.v | 194 ++ .../ByteString/Builder/Prim/Internal.h2ci | 38 + .../Data/ByteString/Builder/Prim/Internal.v | 251 +++ .../Builder/Prim/Internal/Base16.h2ci | 8 + .../ByteString/Builder/Prim/Internal/Base16.v | 32 + .../Builder/Prim/Internal/Floating.h2ci | 1 + .../Builder/Prim/Internal/Floating.v | 62 + .../bytestring/lib/Data/ByteString/Char8.h2ci | 1 + .../bytestring/lib/Data/ByteString/Char8.v | 748 +++++++ .../lib/Data/ByteString/Internal.h2ci | 6 + .../bytestring/lib/Data/ByteString/Internal.v | 216 ++ .../bytestring/lib/Data/ByteString/Lazy.h2ci | 1 + .../bytestring/lib/Data/ByteString/Lazy.v | 1832 +++++++++++++++++ .../lib/Data/ByteString/Lazy/Char8.h2ci | 1 + .../lib/Data/ByteString/Lazy/Char8.v | 866 ++++++++ .../lib/Data/ByteString/Lazy/Internal.h2ci | 9 + .../lib/Data/ByteString/Lazy/Internal.v | 112 + .../Data/ByteString/Lazy/Internal/Deque.h2ci | 17 + .../lib/Data/ByteString/Lazy/Internal/Deque.v | 101 + .../bytestring/lib/Data/ByteString/Short.h2ci | 1 + .../bytestring/lib/Data/ByteString/Short.v | 17 + .../lib/Data/ByteString/Short/Internal.h2ci | 17 + .../lib/Data/ByteString/Short/Internal.v | 658 ++++++ .../lib/Data/ByteString/Unsafe.h2ci | 1 + .../bytestring/lib/Data/ByteString/Unsafe.v | 175 ++ examples/bytestring/lib/README.md | 2 + examples/bytestring/lib/_CoqProject | 6 + examples/bytestring/lib/edits | 1 + 48 files changed, 8649 insertions(+) create mode 100644 examples/bytestring/.gitignore create mode 100644 examples/bytestring/README.md create mode 160000 examples/bytestring/bytestring create mode 100644 examples/bytestring/edits create mode 100644 examples/bytestring/lib/Data/ByteString.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString.v create mode 100644 examples/bytestring/lib/Data/ByteString/Builder.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Builder.v create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/ASCII.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/ASCII.v create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Extra.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Extra.v create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Internal.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Internal.v create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim.v create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim/ASCII.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim/ASCII.v create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim/Binary.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim/Binary.v create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.v create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.v create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Floating.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Floating.v create mode 100644 examples/bytestring/lib/Data/ByteString/Char8.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Char8.v create mode 100644 examples/bytestring/lib/Data/ByteString/Internal.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Internal.v create mode 100644 examples/bytestring/lib/Data/ByteString/Lazy.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Lazy.v create mode 100644 examples/bytestring/lib/Data/ByteString/Lazy/Char8.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Lazy/Char8.v create mode 100644 examples/bytestring/lib/Data/ByteString/Lazy/Internal.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Lazy/Internal.v create mode 100644 examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.v create mode 100644 examples/bytestring/lib/Data/ByteString/Short.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Short.v create mode 100644 examples/bytestring/lib/Data/ByteString/Short/Internal.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Short/Internal.v create mode 100644 examples/bytestring/lib/Data/ByteString/Unsafe.h2ci create mode 100644 examples/bytestring/lib/Data/ByteString/Unsafe.v create mode 100644 examples/bytestring/lib/README.md create mode 100644 examples/bytestring/lib/_CoqProject create mode 120000 examples/bytestring/lib/edits diff --git a/.gitmodules b/.gitmodules index 5a7a3ab96..04c7429e1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,3 +28,6 @@ [submodule "examples/graph/graph"] path = examples/graph/graph url = https://github.com/haskell/fgl.git +[submodule "examples/bytestring/bytestring"] + path = examples/bytestring/bytestring + url = https://github.com/haskell/bytestring diff --git a/examples/bytestring/.gitignore b/examples/bytestring/.gitignore new file mode 100644 index 000000000..480bc6d52 --- /dev/null +++ b/examples/bytestring/.gitignore @@ -0,0 +1,2 @@ +*.vo +*.glob diff --git a/examples/bytestring/README.md b/examples/bytestring/README.md new file mode 100644 index 000000000..54ed87792 --- /dev/null +++ b/examples/bytestring/README.md @@ -0,0 +1,3 @@ +# `bytestring` + +`git submodule` corresponds to commit `11af63eab5945d2ac5aa39bcadc5f8bfa17f3a6d` as of this writing (nov-01-2021) diff --git a/examples/bytestring/bytestring b/examples/bytestring/bytestring new file mode 160000 index 000000000..11af63eab --- /dev/null +++ b/examples/bytestring/bytestring @@ -0,0 +1 @@ +Subproject commit 11af63eab5945d2ac5aa39bcadc5f8bfa17f3a6d diff --git a/examples/bytestring/edits b/examples/bytestring/edits new file mode 100644 index 000000000..525d0e2e9 --- /dev/null +++ b/examples/bytestring/edits @@ -0,0 +1,63 @@ +axiomatize module Data.ByteString.Builder.Internal +axiomatize module Data.ByteString.Builder.Prim.Internal.Base16 +axiomatize module Data.ByteString.Builder +axiomatize module Data.ByteString.Internal +axiomatize module Data.ByteString.Lazy.Internal + +axiomatize module Data.String + +skip module GHC.Ptr +skip module GHC.ForeignPtr +skip module GHC.IO.Handle.Types +skip module Foreign.Storable +skip module GHC.IO.IOMode +skip module GHC.IO.Exception +skip module GHC.IO.Handle.FD +skip module GHC.IO.Error +skip module Foreign.C.String +skip module Foreign.Marshal.Alloc +skip module GHC.IO.Unsafe +skip module Foreign.Concurrent +skip module ForeignPtr.Imp +skip module Control.Exception.Base +skip module Foreign.Marshal.Utils +skip module System.IO.Error +skip module System.IO + +skip module GHC.ST +skip module Foreign.ForeignPtr.Imp +skip module Foreign.C.Types +skip module Foreign.Marshal.Array +skip module GHC.Foreign +skip module GHC.IO.Buffer +skip module GHC.IO.Encoding +skip module GHC.IO.Handle.Text +skip module GHC.IO.Handle + +# xiomatize module GHC.Ptr +# xiomatize module GHC.ForeignPtr +# xiomatize module GHC.IO.Handle.Types +# xiomatize module Foreign.Storable +# xiomatize module GHC.IO.IOMode +# xiomatize module GHC.IO.Exception +# xiomatize module GHC.IO.Handle.FD +# xiomatize module GHC.IO.Error +# xiomatize module Foreign.C.String +# xiomatize module Foreign.Marshal.Alloc +# xiomatize module GHC.IO.Unsafe +# xiomatize module Foreign.Concurrent +# xiomatize module ForeignPtr.Imp +# xiomatize module Control.Exception.Base +# xiomatize module Foreign.Marshal.Utils +# xiomatize module System.IO.Error +# xiomatize module System.IO +# +# xiomatize module GHC.ST +# xiomatize module Foreign.ForeignPtr.Imp +# xiomatize module Foreign.C.Types +# xiomatize module Foreign.Marshal.Array +# xiomatize module GHC.Foreign +# xiomatize module GHC.IO.Buffer +# xiomatize module GHC.IO.Encoding +# xiomatize module GHC.IO.Handle.Text +# xiomatize module GHC.IO.Handle diff --git a/examples/bytestring/lib/Data/ByteString.h2ci b/examples/bytestring/lib/Data/ByteString.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString.v b/examples/bytestring/lib/Data/ByteString.v new file mode 100644 index 000000000..058d97f8e --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString.v @@ -0,0 +1,1797 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Coq.Init.Datatypes. +Require Coq.Lists.List. +Require Data.Bits. +Require Data.ByteString.Internal. +Require Data.ByteString.Unsafe. +Require Data.Functor. +Require Data.OldList. +Require Data.Tuple. +Require GHC.Base. +Require GHC.Enum. +Require GHC.Err. +Require GHC.List. +Require GHC.Num. +Require GHC.Real. +Import Data.Bits.Notations. +Import Data.Functor.Notations. +Import GHC.Base.Notations. +Import GHC.Num.Notations. +Import GHC.Real.Notations. + +(* No type declarations to convert. *) + +(* Converted value declarations: *) + +Definition empty : Data.ByteString.Internal.ByteString := + Data.ByteString.Internal.BS Data.ByteString.Internal.nullForeignPtr #0. + +Definition singleton : GHC.Word.Word8 -> Data.ByteString.Internal.ByteString := + fun c => + Data.ByteString.Internal.unsafeCreate #1 (fun p => Foreign.Storable.poke p c). + +Definition pack : list GHC.Word.Word8 -> Data.ByteString.Internal.ByteString := + Data.ByteString.Internal.packBytes. + +Definition foldr {a : Type} + : (GHC.Word.Word8 -> a -> a) -> + a -> Data.ByteString.Internal.ByteString -> a := + fun k z => + fun '(Data.ByteString.Internal.BS fp len) => + let ptr := GHC.ForeignPtr.unsafeForeignPtrToPtr fp in + let end := GHC.Ptr.plusPtr ptr len in + let fix go p + := if p GHC.Base.== end : bool then z else + let x := + Data.ByteString.Internal.accursedUnutterablePerformIO (Foreign.Storable.peek p + GHC.Base.>>= + (fun x' => + GHC.ForeignPtr.touchForeignPtr fp GHC.Base.>> + GHC.Base.return_ x')) in + k x (go (GHC.Ptr.plusPtr p #1)) in + go ptr. + +Definition unpackFoldr {a} + : Data.ByteString.Internal.ByteString -> + (GHC.Word.Word8 -> a -> a) -> a -> a := + fun bs k z => foldr k z bs. + +Definition unpack + : Data.ByteString.Internal.ByteString -> list GHC.Word.Word8 := + fun bs => GHC.Base.build' (fun _ => unpackFoldr bs). + +Definition fromFilePath + : GHC.Base.String -> GHC.Types.IO Data.ByteString.Internal.ByteString := + fun path => + GHC.IO.Encoding.getFileSystemEncoding GHC.Base.>>= + (fun enc => + GHC.Foreign.newCStringLen enc path GHC.Base.>>= + Data.ByteString.Unsafe.unsafePackMallocCStringLen). + +Definition useAsCString {a : Type} + : Data.ByteString.Internal.ByteString -> + (Foreign.C.String.CString -> GHC.Types.IO a) -> GHC.Types.IO a := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | Data.ByteString.Internal.BS fp l, action => + Foreign.Marshal.Alloc.allocaBytes (l GHC.Num.+ #1) (fun buf => + Foreign.ForeignPtr.Imp.withForeignPtr fp (fun p => + Data.ByteString.Internal.memcpy + buf p + (GHC.Real.fromIntegral + l) + GHC.Base.>> + (Foreign.Storable.pokeByteOff + buf l + (#0 : GHC.Word.Word8) + GHC.Base.>> + action + (GHC.Ptr.castPtr + buf)))) + end. + +Definition useAsCStringLen {a : Type} + : Data.ByteString.Internal.ByteString -> + (Foreign.C.String.CStringLen -> GHC.Types.IO a) -> GHC.Types.IO a := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | (Data.ByteString.Internal.BS _ l as p), f => + useAsCString p (fun cstr => f (pair cstr l)) + end. + +Definition toFilePath + : Data.ByteString.Internal.ByteString -> GHC.Types.IO GHC.Base.String := + fun path => + GHC.IO.Encoding.getFileSystemEncoding GHC.Base.>>= + (fun enc => useAsCStringLen path (GHC.Foreign.peekCStringLen enc)). + +Definition null : Data.ByteString.Internal.ByteString -> bool := + fun '(Data.ByteString.Internal.BS _ l) => + GHC.Base.assert (l GHC.Base.>= #0) (l GHC.Base.<= #0). + +Definition length : Data.ByteString.Internal.ByteString -> GHC.Num.Int := + fun '(Data.ByteString.Internal.BS _ l) => GHC.Base.assert (l GHC.Base.>= #0) l. + +Definition cons_ + : GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | c, Data.ByteString.Internal.BS x l => + Data.ByteString.Internal.unsafeCreate (l GHC.Num.+ #1) (fun p => + Data.ByteString.Internal.unsafeWithForeignPtr x + (fun f => + Foreign.Storable.poke p c GHC.Base.>> + Data.ByteString.Internal.memcpy (GHC.Ptr.plusPtr p + #1) + f (GHC.Real.fromIntegral l))) + end. + +Definition snoc + : Data.ByteString.Internal.ByteString -> + GHC.Word.Word8 -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | Data.ByteString.Internal.BS x l, c => + Data.ByteString.Internal.unsafeCreate (l GHC.Num.+ #1) (fun p => + Data.ByteString.Internal.unsafeWithForeignPtr x + (fun f => + Data.ByteString.Internal.memcpy p f + (GHC.Real.fromIntegral l) GHC.Base.>> + Foreign.Storable.poke (GHC.Ptr.plusPtr p l) c)) + end. + +Definition moduleErrorMsg + : GHC.Base.String -> GHC.Base.String -> GHC.Base.String := + fun fun_ msg => + Coq.Init.Datatypes.app (GHC.Base.hs_string__ "Data.ByteString.") + (Coq.Init.Datatypes.app fun_ (cons (GHC.Char.hs_char__ ":") (cons + (GHC.Char.hs_char__ " ") msg))). + +Definition moduleError {a} : GHC.Base.String -> GHC.Base.String -> a := + fun fun_ msg => GHC.Err.error (moduleErrorMsg fun_ msg). + +Definition errorEmptyList {a} : GHC.Base.String -> a := + fun fun_ => moduleError fun_ (GHC.Base.hs_string__ "empty ByteString"). + +Definition head : Data.ByteString.Internal.ByteString -> GHC.Word.Word8 := + fun '(Data.ByteString.Internal.BS x l) => + if l GHC.Base.<= #0 : bool + then errorEmptyList (GHC.Base.hs_string__ "head") else + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Foreign.Storable.peek p)). + +Definition tail + : Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun '(Data.ByteString.Internal.BS p l) => + if l GHC.Base.<= #0 : bool + then errorEmptyList (GHC.Base.hs_string__ "tail") else + Data.ByteString.Internal.BS (GHC.ForeignPtr.plusForeignPtr p #1) (l GHC.Num.- + #1). + +Definition uncons + : Data.ByteString.Internal.ByteString -> + option (GHC.Word.Word8 * Data.ByteString.Internal.ByteString)%type := + fun '(Data.ByteString.Internal.BS x l) => + if l GHC.Base.<= #0 : bool then None else + Some (pair (Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Foreign.Storable.peek p))) + (Data.ByteString.Internal.BS (GHC.ForeignPtr.plusForeignPtr x #1) (l GHC.Num.- + #1))). + +Definition last : Data.ByteString.Internal.ByteString -> GHC.Word.Word8 := + fun '((Data.ByteString.Internal.BS x l as ps)) => + if null ps : bool then errorEmptyList (GHC.Base.hs_string__ "last") else + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Foreign.Storable.peekByteOff p (l GHC.Num.- #1))). + +Definition init + : Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun '((Data.ByteString.Internal.BS p l as ps)) => + if null ps : bool then errorEmptyList (GHC.Base.hs_string__ "init") else + Data.ByteString.Internal.BS p (l GHC.Num.- #1). + +Definition unsnoc + : Data.ByteString.Internal.ByteString -> + option (Data.ByteString.Internal.ByteString * GHC.Word.Word8)%type := + fun '(Data.ByteString.Internal.BS x l) => + if l GHC.Base.<= #0 : bool then None else + Some (pair (Data.ByteString.Internal.BS x (l GHC.Num.- #1)) + (Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Foreign.Storable.peekByteOff p (l GHC.Num.- #1))))). + +Definition append + : Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + GHC.Base.mappend. + +Definition map + : (GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | f, Data.ByteString.Internal.BS fp len => + let m := + fun p1 p2 => + let map_ : GHC.Num.Int -> GHC.Types.IO unit := + fix map_ (n : GHC.Num.Int) : GHC.Types.IO unit + := if n GHC.Base.>= len : bool then GHC.Base.return_ tt else + Foreign.Storable.peekByteOff p1 n GHC.Base.>>= + (fun x => + Foreign.Storable.pokeByteOff p2 n (f x) GHC.Base.>> map_ (n GHC.Num.+ #1)) in + map_ #0 in + GHC.IO.Unsafe.unsafeDupablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp (fun srcPtr => + Data.ByteString.Internal.create len (fun dstPtr => + m srcPtr dstPtr))) + end. + +Definition reverse + : Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun '(Data.ByteString.Internal.BS x l) => + Data.ByteString.Internal.unsafeCreate l (fun p => + Data.ByteString.Internal.unsafeWithForeignPtr x (fun f => + Data.ByteString.Internal.c_reverse + p f + (GHC.Real.fromIntegral + l))). + +Definition intersperse + : GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | c, (Data.ByteString.Internal.BS x l as ps) => + if length ps GHC.Base.< #2 : bool then ps else + Data.ByteString.Internal.unsafeCreate ((#2 GHC.Num.* l) GHC.Num.- #1) (fun p => + Data.ByteString.Internal.unsafeWithForeignPtr + x (fun f => + Data.ByteString.Internal.c_intersperse + p f (GHC.Real.fromIntegral l) c)) + end. + +Definition transpose + : list Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString := + GHC.Base.map pack GHC.Base.∘ + (Data.OldList.transpose GHC.Base.∘ GHC.Base.map unpack). + +Definition foldl {a : Type} + : (a -> GHC.Word.Word8 -> a) -> + a -> Data.ByteString.Internal.ByteString -> a := + fun f z => + fun '(Data.ByteString.Internal.BS fp len) => + let end := + GHC.Ptr.plusPtr (GHC.ForeignPtr.unsafeForeignPtrToPtr fp) (GHC.Num.negate #1) in + let fix go p + := if p GHC.Base.== end : bool then z else + let x := + Data.ByteString.Internal.accursedUnutterablePerformIO (Foreign.Storable.peek p + GHC.Base.>>= + (fun x' => + GHC.ForeignPtr.touchForeignPtr fp GHC.Base.>> + GHC.Base.return_ x')) in + f (go (GHC.Ptr.plusPtr p (GHC.Num.negate #1))) x in + go (GHC.Ptr.plusPtr end len). + +Definition foldl' {a : Type} + : (a -> GHC.Word.Word8 -> a) -> + a -> Data.ByteString.Internal.ByteString -> a := + fun f v => + fun '(Data.ByteString.Internal.BS fp len) => + let g := + fun ptr => + let end := GHC.Ptr.plusPtr ptr len in + let fix go z p + := if p GHC.Base.== end : bool then GHC.Base.return_ z else + Foreign.Storable.peek p GHC.Base.>>= + (fun x => go (f z x) (GHC.Ptr.plusPtr p #1)) in + go v ptr in + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp g). + +Definition foldr' {a : Type} + : (GHC.Word.Word8 -> a -> a) -> + a -> Data.ByteString.Internal.ByteString -> a := + fun k v => + fun '(Data.ByteString.Internal.BS fp len) => + let g := + fun ptr => + let end := GHC.Ptr.plusPtr ptr (GHC.Num.negate #1) in + let fix go z p + := if p GHC.Base.== end : bool then GHC.Base.return_ z else + Foreign.Storable.peek p GHC.Base.>>= + (fun x => go (k x z) (GHC.Ptr.plusPtr p (GHC.Num.negate #1))) in + go v (GHC.Ptr.plusPtr end len) in + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp g). + +Definition foldl1 + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Internal.ByteString -> GHC.Word.Word8 := + fun f ps => + match uncons ps with + | None => errorEmptyList (GHC.Base.hs_string__ "foldl1") + | Some (pair h t) => foldl f h t + end. + +Definition foldl1' + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Internal.ByteString -> GHC.Word.Word8 := + fun f ps => + match uncons ps with + | None => errorEmptyList (GHC.Base.hs_string__ "foldl1'") + | Some (pair h t) => foldl' f h t + end. + +Definition foldr1 + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Internal.ByteString -> GHC.Word.Word8 := + fun f ps => + match unsnoc ps with + | None => errorEmptyList (GHC.Base.hs_string__ "foldr1") + | Some (pair b c) => foldr f c b + end. + +Definition foldr1' + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Internal.ByteString -> GHC.Word.Word8 := + fun f ps => + match unsnoc ps with + | None => errorEmptyList (GHC.Base.hs_string__ "foldr1'") + | Some (pair b c) => foldr' f c b + end. + +Definition concat + : list Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString := + GHC.Base.mconcat. + +Definition concatMap + : (GHC.Word.Word8 -> Data.ByteString.Internal.ByteString) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f => concat GHC.Base.∘ foldr (cons GHC.Base.∘ f) nil. + +Definition any + : (GHC.Word.Word8 -> bool) -> Data.ByteString.Internal.ByteString -> bool := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Internal.BS _ num_2__ => + if num_2__ GHC.Base.== #0 : bool then false else + match arg_0__, arg_1__ with + | f, Data.ByteString.Internal.BS x len => + let g := + fun ptr => + let end := GHC.Ptr.plusPtr ptr len in + let fix go p + := if p GHC.Base.== end : bool then GHC.Base.return_ false else + Foreign.Storable.peek p GHC.Base.>>= + (fun c => + if f c : bool + then GHC.Base.return_ true + else go (GHC.Ptr.plusPtr p #1)) in + go ptr in + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x g) + end + end. + +Definition anyByte + : GHC.Word.Word8 -> Data.ByteString.Internal.ByteString -> bool := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | c, Data.ByteString.Internal.BS x l => + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Data.ByteString.Internal.memchr p c (GHC.Real.fromIntegral l) + GHC.Base.>>= + (fun q => GHC.Base.return_ (q GHC.Base./= GHC.Ptr.nullPtr)))) + end. + +Definition all + : (GHC.Word.Word8 -> bool) -> Data.ByteString.Internal.ByteString -> bool := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Internal.BS _ num_2__ => + if num_2__ GHC.Base.== #0 : bool then true else + match arg_0__, arg_1__ with + | f, Data.ByteString.Internal.BS x len => + let g := + fun ptr => + let end := GHC.Ptr.plusPtr ptr len in + let fix go p + := if p GHC.Base.== end : bool then GHC.Base.return_ true else + Foreign.Storable.peek p GHC.Base.>>= + (fun c => + if f c : bool + then go (GHC.Ptr.plusPtr p #1) + else GHC.Base.return_ false) in + go ptr in + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x g) + end + end. + +Definition maximum : Data.ByteString.Internal.ByteString -> GHC.Word.Word8 := + fun '((Data.ByteString.Internal.BS x l as xs)) => + if null xs : bool then errorEmptyList (GHC.Base.hs_string__ "maximum") else + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Data.ByteString.Internal.c_maximum p (GHC.Real.fromIntegral l))). + +Definition minimum : Data.ByteString.Internal.ByteString -> GHC.Word.Word8 := + fun '((Data.ByteString.Internal.BS x l as xs)) => + if null xs : bool then errorEmptyList (GHC.Base.hs_string__ "minimum") else + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Data.ByteString.Internal.c_minimum p (GHC.Real.fromIntegral l))). + +Definition mapAccumL {acc : Type} + : (acc -> GHC.Word.Word8 -> (acc * GHC.Word.Word8)%type) -> + acc -> + Data.ByteString.Internal.ByteString -> + (acc * Data.ByteString.Internal.ByteString)%type := + fun f acc => + fun '(Data.ByteString.Internal.BS fp len) => + GHC.IO.Unsafe.unsafeDupablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp (fun a => + Data.ByteString.Internal.mallocByteString len GHC.Base.>>= + (fun gp => + let go := + fun src dst => + let fix mapAccumL_ s n + := if n GHC.Base.>= len : bool + then GHC.Base.return_ s else + Foreign.Storable.peekByteOff src n GHC.Base.>>= + (fun x => + let 'pair s' y := f s x in + Foreign.Storable.pokeByteOff dst n y GHC.Base.>> + mapAccumL_ s' (n GHC.Num.+ #1)) in + mapAccumL_ acc #0 in + Data.ByteString.Internal.unsafeWithForeignPtr gp (go a) + GHC.Base.>>= + (fun acc' => + GHC.Base.return_ (pair acc' (Data.ByteString.Internal.BS + gp len)))))). + +Definition mapAccumR {acc : Type} + : (acc -> GHC.Word.Word8 -> (acc * GHC.Word.Word8)%type) -> + acc -> + Data.ByteString.Internal.ByteString -> + (acc * Data.ByteString.Internal.ByteString)%type := + fun f acc => + fun '(Data.ByteString.Internal.BS fp len) => + GHC.IO.Unsafe.unsafeDupablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp (fun a => + Data.ByteString.Internal.mallocByteString len GHC.Base.>>= + (fun gp => + let go := + fun src dst => + let fix mapAccumR_ arg_1__ arg_2__ + := match arg_1__, arg_2__ with + | s, num_3__ => + if num_3__ GHC.Base.== #1 : bool + then GHC.Base.return_ s else + match arg_1__, arg_2__ with + | s, n => + Foreign.Storable.peekByteOff src n + GHC.Base.>>= + (fun x => + let 'pair s' y := f s x in + Foreign.Storable.pokeByteOff dst n y + GHC.Base.>> + mapAccumR_ s' (n GHC.Num.- #1)) + end + end in + mapAccumR_ acc (len GHC.Num.- #1) in + Data.ByteString.Internal.unsafeWithForeignPtr gp (go a) + GHC.Base.>>= + (fun acc' => + GHC.Base.return_ (pair acc' (Data.ByteString.Internal.BS + gp len)))))). + +Definition scanl + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f v => + fun '(Data.ByteString.Internal.BS fp len) => + GHC.IO.Unsafe.unsafeDupablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp (fun a => + Data.ByteString.Internal.create (len GHC.Num.+ #1) (fun q => + Foreign.Storable.poke + q v + GHC.Base.>> + (let go := + fun src + dst => + let fix scanl_ + z n + := if n + GHC.Base.>= + len : bool + then GHC.Base.return_ + tt else + Foreign.Storable.peekByteOff + src + n + GHC.Base.>>= + (fun x => + let z' := + f + z + x in + Foreign.Storable.pokeByteOff + dst + n + z' + GHC.Base.>> + scanl_ + z' + (n + GHC.Num.+ + #1)) in + scanl_ + v + #0 in + go a + (GHC.Ptr.plusPtr + q + #1))))). + +Definition scanl1 + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f ps => + match uncons ps with + | None => empty + | Some (pair h t) => scanl f h t + end. + +Definition scanr + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f v => + fun '(Data.ByteString.Internal.BS fp len) => + GHC.IO.Unsafe.unsafeDupablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp (fun a => + Data.ByteString.Internal.create (len GHC.Num.+ #1) (fun b => + Foreign.Storable.poke + (GHC.Ptr.plusPtr + b len) v + GHC.Base.>> + (let go := + fun p + q => + let fix scanr_ + z n + := if n + GHC.Base.< + #0 : bool + then GHC.Base.return_ + tt else + Foreign.Storable.peekByteOff + p + n + GHC.Base.>>= + (fun x => + let z' := + f + x + z in + Foreign.Storable.pokeByteOff + q + n + z' + GHC.Base.>> + scanr_ + z' + (n + GHC.Num.- + #1)) in + scanr_ + v + (len + GHC.Num.- + #1) in + go a + b)))). + +Definition scanr1 + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f ps => + match unsnoc ps with + | None => empty + | Some (pair b c) => scanr f c b + end. + +Definition replicate + : GHC.Num.Int -> GHC.Word.Word8 -> Data.ByteString.Internal.ByteString := + fun w c => + if w GHC.Base.<= #0 : bool then empty else + Data.ByteString.Internal.unsafeCreate w (fun ptr => + Data.Functor.void (Data.ByteString.Internal.memset ptr c + (GHC.Real.fromIntegral + w))). + +Definition unfoldrN {a : Type} + : GHC.Num.Int -> + (a -> option (GHC.Word.Word8 * a)%type) -> + a -> (Data.ByteString.Internal.ByteString * option a)%type := + fun i f x0 => + let go := + fun p x n => + let fix go' x' n' + := if n' GHC.Base.== i : bool + then GHC.Base.return_ (pair (pair #0 n') (Some x')) else + match f x' with + | None => GHC.Base.return_ (pair (pair #0 n') None) + | Some (pair w x'') => + Foreign.Storable.pokeByteOff p n' w GHC.Base.>> go' x'' (n' GHC.Num.+ #1) + end in + go' x n in + if i GHC.Base.< #0 : bool then pair empty (Some x0) else + GHC.IO.Unsafe.unsafePerformIO (Data.ByteString.Internal.createAndTrim' i + (fun p => go p x0 #0)). + +Definition unfoldr {a : Type} + : (a -> option (GHC.Word.Word8 * a)%type) -> + a -> Data.ByteString.Internal.ByteString := + fun f => + let fix unfoldChunk n n' x + := match unfoldrN n f x with + | pair s None => cons s nil + | pair s (Some x') => cons s (unfoldChunk n' (n GHC.Num.+ n') x') + end in + concat GHC.Base.∘ unfoldChunk #32 #64. + +Definition take + : GHC.Num.Int -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | n, (Data.ByteString.Internal.BS x l as ps) => + if n GHC.Base.<= #0 : bool then empty else + if n GHC.Base.>= l : bool then ps else + Data.ByteString.Internal.BS x n + end. + +Definition takeEnd + : GHC.Num.Int -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | n, (Data.ByteString.Internal.BS x len as ps) => + if n GHC.Base.>= len : bool then ps else + if n GHC.Base.<= #0 : bool then empty else + Data.ByteString.Internal.BS (GHC.ForeignPtr.plusForeignPtr x (len GHC.Num.- n)) + n + end. + +Definition drop + : GHC.Num.Int -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | n, (Data.ByteString.Internal.BS x l as ps) => + if n GHC.Base.<= #0 : bool then ps else + if n GHC.Base.>= l : bool then empty else + Data.ByteString.Internal.BS (GHC.ForeignPtr.plusForeignPtr x n) (l GHC.Num.- n) + end. + +Definition dropEnd + : GHC.Num.Int -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | n, (Data.ByteString.Internal.BS x len as ps) => + if n GHC.Base.<= #0 : bool then ps else + if n GHC.Base.>= len : bool then empty else + Data.ByteString.Internal.BS x (len GHC.Num.- n) + end. + +Definition splitAt + : GHC.Num.Int -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | n, (Data.ByteString.Internal.BS x l as ps) => + if n GHC.Base.<= #0 : bool then pair empty ps else + if n GHC.Base.>= l : bool then pair ps empty else + pair (Data.ByteString.Internal.BS x n) (Data.ByteString.Internal.BS + (GHC.ForeignPtr.plusForeignPtr x n) (l GHC.Num.- n)) + end. + +Definition takeWhile + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f ps => + Data.ByteString.Unsafe.unsafeTake (Data.ByteString.Internal.findIndexOrLength + (negb GHC.Base.∘ f) ps) ps. + +Fixpoint findFromEndUntil (arg_0__ : (GHC.Word.Word8 -> bool)) (arg_1__ + : Data.ByteString.Internal.ByteString) : GHC.Num.Int + := match arg_0__, arg_1__ with + | f, (Data.ByteString.Internal.BS _ l as ps) => + match unsnoc ps with + | None => #0 + | Some (pair b c) => if f c : bool then l else findFromEndUntil f b + end + end. + +Definition takeWhileEnd + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f ps => + Data.ByteString.Unsafe.unsafeDrop (findFromEndUntil (negb GHC.Base.∘ f) ps) ps. + +Definition dropWhile + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f ps => + Data.ByteString.Unsafe.unsafeDrop (Data.ByteString.Internal.findIndexOrLength + (negb GHC.Base.∘ f) ps) ps. + +Definition dropWhileEnd + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f ps => + Data.ByteString.Unsafe.unsafeTake (findFromEndUntil (negb GHC.Base.∘ f) ps) ps. + +Definition break + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun p ps => + let 'n := Data.ByteString.Internal.findIndexOrLength p ps in + pair (Data.ByteString.Unsafe.unsafeTake n ps) (Data.ByteString.Unsafe.unsafeDrop + n ps). + +Definition elemIndex + : GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> option GHC.Num.Int := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | c, Data.ByteString.Internal.BS x l => + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Data.ByteString.Internal.memchr p c (GHC.Real.fromIntegral l) + GHC.Base.>>= + (fun q => + GHC.Base.return_ (if q GHC.Base.== GHC.Ptr.nullPtr : bool + then None + else Some (GHC.Ptr.minusPtr q p))))) + end. + +Definition breakByte + : GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun c p => + match elemIndex c p with + | None => pair p empty + | Some n => + pair (Data.ByteString.Unsafe.unsafeTake n p) (Data.ByteString.Unsafe.unsafeDrop + n p) + end. + +Definition breakEnd + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun p ps => splitAt (findFromEndUntil p ps) ps. + +Definition span + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun p => break (negb GHC.Base.∘ p). + +Definition spanByte + : GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | c, (Data.ByteString.Internal.BS x l as ps) => + let g := + fun p => + let fix go i + := if i GHC.Base.>= l : bool then GHC.Base.return_ (pair ps empty) else + Foreign.Storable.peekByteOff p i GHC.Base.>>= + (fun c' => + if c GHC.Base./= c' : bool + then GHC.Base.return_ (pair (Data.ByteString.Unsafe.unsafeTake i ps) + (Data.ByteString.Unsafe.unsafeDrop i ps)) + else go (i GHC.Num.+ #1)) in + go #0 in + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x g) + end. + +Definition spanEnd + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun p ps => splitAt (findFromEndUntil (negb GHC.Base.∘ p) ps) ps. + +Definition splitWith + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Internal.BS _ num_2__ => + if num_2__ GHC.Base.== #0 : bool then nil else + match arg_0__, arg_1__ with + | predicate, Data.ByteString.Internal.BS fp len => + let splitWith0 := + fix splitLoop (p : GHC.Ptr.Ptr GHC.Word.Word8) (idx2 off' len' : GHC.Num.Int) + (fp' : GHC.ForeignPtr.ForeignPtr GHC.Word.Word8) : GHC.Types.IO (list + Data.ByteString.Internal.ByteString) + := let fix go idx' + := if idx' GHC.Base.>= len' : bool + then GHC.Base.return_ (cons (Data.ByteString.Internal.BS + (GHC.ForeignPtr.plusForeignPtr fp' off') idx') nil) else + Foreign.Storable.peekElemOff p (off' GHC.Num.+ idx') GHC.Base.>>= + (fun w => + if predicate w : bool + then GHC.Base.return_ (cons (Data.ByteString.Internal.BS + (GHC.ForeignPtr.plusForeignPtr fp' off') idx') (splitWith0 + ((off' GHC.Num.+ idx') GHC.Num.+ #1) ((len' GHC.Num.- idx') + GHC.Num.- + #1) fp')) + else go (idx' GHC.Num.+ #1)) in + go idx2 + with splitWith0 off' len' fp' + := Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp (fun p => + splitLoop p #0 off' len' fp')) for splitWith0 in + let splitLoop + : GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Num.Int -> + GHC.Num.Int -> + GHC.Num.Int -> + GHC.ForeignPtr.ForeignPtr GHC.Word.Word8 -> + GHC.Types.IO (list Data.ByteString.Internal.ByteString) := + fix splitLoop (p : GHC.Ptr.Ptr GHC.Word.Word8) (idx2 off' len' : GHC.Num.Int) + (fp' : GHC.ForeignPtr.ForeignPtr GHC.Word.Word8) : GHC.Types.IO (list + Data.ByteString.Internal.ByteString) + := let fix go idx' + := if idx' GHC.Base.>= len' : bool + then GHC.Base.return_ (cons (Data.ByteString.Internal.BS + (GHC.ForeignPtr.plusForeignPtr fp' off') idx') nil) else + Foreign.Storable.peekElemOff p (off' GHC.Num.+ idx') GHC.Base.>>= + (fun w => + if predicate w : bool + then GHC.Base.return_ (cons (Data.ByteString.Internal.BS + (GHC.ForeignPtr.plusForeignPtr fp' off') idx') (splitWith0 + ((off' GHC.Num.+ idx') GHC.Num.+ #1) ((len' GHC.Num.- idx') + GHC.Num.- + #1) fp')) + else go (idx' GHC.Num.+ #1)) in + go idx2 + with splitWith0 off' len' fp' + := Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp (fun p => + splitLoop p #0 off' len' fp')) for splitLoop in + splitWith0 #0 len fp + end + end. + +Definition split + : GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Internal.BS _ num_2__ => + if num_2__ GHC.Base.== #0 : bool then nil else + match arg_0__, arg_1__ with + | w, Data.ByteString.Internal.BS x l => + let fix loop n + := let q := + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Data.ByteString.Internal.memchr (GHC.Ptr.plusPtr p + n) + w (GHC.Real.fromIntegral (l GHC.Num.- n)))) in + if q GHC.Base.== GHC.Ptr.nullPtr : bool + then cons (Data.ByteString.Internal.BS (GHC.ForeignPtr.plusForeignPtr x n) (l + GHC.Num.- + n)) nil + else let i := GHC.Ptr.minusPtr q (GHC.ForeignPtr.unsafeForeignPtrToPtr x) in + cons (Data.ByteString.Internal.BS (GHC.ForeignPtr.plusForeignPtr x n) (i + GHC.Num.- + n)) (loop (i GHC.Num.+ + #1)) in + loop #0 + end + end. + +Fixpoint group (xs : Data.ByteString.Internal.ByteString) : list + Data.ByteString.Internal.ByteString + := match uncons xs with + | None => nil + | Some (pair h _) => let 'pair ys zs := spanByte h xs in cons ys (group zs) + end. + +Fixpoint groupBy (k : GHC.Word.Word8 -> GHC.Word.Word8 -> bool) (xs + : Data.ByteString.Internal.ByteString) : list + Data.ByteString.Internal.ByteString + := match uncons xs with + | None => nil + | Some (pair h t) => + let n := + #1 GHC.Num.+ + Data.ByteString.Internal.findIndexOrLength (negb GHC.Base.∘ k h) t in + cons (Data.ByteString.Unsafe.unsafeTake n xs) (groupBy k + (Data.ByteString.Unsafe.unsafeDrop n xs)) + end. + +Definition intercalate + : Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString := + fun s => concat GHC.Base.∘ Data.OldList.intersperse s. + +Definition intercalateWithByte + : GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ arg_2__ => + match arg_0__, arg_1__, arg_2__ with + | c + , (Data.ByteString.Internal.BS ffp l as f) + , (Data.ByteString.Internal.BS fgp m as g) => + let len := (length f GHC.Num.+ length g) GHC.Num.+ #1 in + Data.ByteString.Internal.unsafeCreate len (fun ptr => + Data.ByteString.Internal.unsafeWithForeignPtr ffp (fun fp => + Data.ByteString.Internal.unsafeWithForeignPtr + fgp (fun gp => + Data.ByteString.Internal.memcpy + ptr fp + (GHC.Real.fromIntegral + l) + GHC.Base.>> + (Foreign.Storable.poke + (GHC.Ptr.plusPtr + ptr + l) c + GHC.Base.>> + Data.ByteString.Internal.memcpy + (GHC.Ptr.plusPtr + ptr + (l + GHC.Num.+ + #1)) + gp + (GHC.Real.fromIntegral + m))))) + end. + +Definition index + : Data.ByteString.Internal.ByteString -> GHC.Num.Int -> GHC.Word.Word8 := + fun ps n => + if n GHC.Base.< #0 : bool + then moduleError (GHC.Base.hs_string__ "index") (Coq.Init.Datatypes.app + (GHC.Base.hs_string__ "negative index: ") (GHC.Show.show n)) else + if n GHC.Base.>= length ps : bool + then moduleError (GHC.Base.hs_string__ "index") (Coq.Init.Datatypes.app + (GHC.Base.hs_string__ "index too large: ") (Coq.Init.Datatypes.app + (GHC.Show.show n) (Coq.Init.Datatypes.app (GHC.Base.hs_string__ + ", length = ") + (GHC.Show.show (length + ps))))) else + Data.ByteString.Unsafe.unsafeIndex ps n. + +Definition indexMaybe + : Data.ByteString.Internal.ByteString -> + GHC.Num.Int -> option GHC.Word.Word8 := + fun ps n => + if n GHC.Base.< #0 : bool then None else + if n GHC.Base.>= length ps : bool then None else + Some (Data.ByteString.Unsafe.unsafeIndex ps n). + +Definition op_znz3fU__ + : Data.ByteString.Internal.ByteString -> + GHC.Num.Int -> option GHC.Word.Word8 := + indexMaybe. + +Notation "'_!?_'" := (op_znz3fU__). + +Infix "!?" := (_!?_) (at level 99). + +Definition findIndexEnd + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> option GHC.Num.Int := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | k, Data.ByteString.Internal.BS x l => + let g := + fun ptr => + let fix go n + := if n GHC.Base.< #0 : bool then GHC.Base.return_ None else + Foreign.Storable.peekByteOff ptr n GHC.Base.>>= + (fun w => + if k w : bool + then GHC.Base.return_ (Some n) + else go (n GHC.Num.- #1)) in + go (l GHC.Num.- #1) in + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x g) + end. + +Definition elemIndexEnd + : GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> option GHC.Num.Int := + findIndexEnd GHC.Base.∘ _GHC.Base.==_. + +Definition elemIndices + : GHC.Word.Word8 -> Data.ByteString.Internal.ByteString -> list GHC.Num.Int := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | w, Data.ByteString.Internal.BS x l => + let fix loop n + := Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Data.ByteString.Internal.memchr (GHC.Ptr.plusPtr p n) w + (GHC.Real.fromIntegral (l GHC.Num.- n)) GHC.Base.>>= + (fun q => + if q GHC.Base.== GHC.Ptr.nullPtr : bool + then GHC.Base.return_ nil + else let i := GHC.Ptr.minusPtr q p in + GHC.Base.return_ (cons i (loop (i GHC.Num.+ + #1)))))) in + loop #0 + end. + +Definition count + : GHC.Word.Word8 -> Data.ByteString.Internal.ByteString -> GHC.Num.Int := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | w, Data.ByteString.Internal.BS x m => + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + GHC.Real.fromIntegral Data.Functor.<$> + Data.ByteString.Internal.c_count p (GHC.Real.fromIntegral m) + w)) + end. + +Definition findIndex + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> option GHC.Num.Int := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | k, Data.ByteString.Internal.BS x l => + let g := + fun ptr => + let fix go n + := if n GHC.Base.>= l : bool then GHC.Base.return_ None else + Foreign.Storable.peek (GHC.Ptr.plusPtr ptr n) GHC.Base.>>= + (fun w => + if k w : bool + then GHC.Base.return_ (Some n) + else go (n GHC.Num.+ #1)) in + go #0 in + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x g) + end. + +Definition findIndices + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> list GHC.Num.Int := + fun p => + let fix loop n qs + := match findIndex p qs with + | Some i => + let j := n GHC.Num.+ i in + cons j (loop (j GHC.Num.+ #1) (Data.ByteString.Unsafe.unsafeDrop (i GHC.Num.+ + #1) qs)) + | None => nil + end in + loop #0. + +Definition elem + : GHC.Word.Word8 -> Data.ByteString.Internal.ByteString -> bool := + fun c ps => match elemIndex c ps with | None => false | _ => true end. + +Definition notElem + : GHC.Word.Word8 -> Data.ByteString.Internal.ByteString -> bool := + fun c ps => negb (elem c ps). + +Definition filter + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun k => + fun '((Data.ByteString.Internal.BS x l as ps)) => + if null ps : bool + then ps + else GHC.IO.Unsafe.unsafePerformIO (Data.ByteString.Internal.createAndTrim l + (fun pOut => + Data.ByteString.Internal.unsafeWithForeignPtr + x (fun pIn => + let go' := + fun pf pt => + let end := + GHC.Ptr.plusPtr pf l in + let fix go f t + := if f GHC.Base.== + end : bool + then GHC.Base.return_ + t else + Foreign.Storable.peek + f GHC.Base.>>= + (fun w => + if k w : bool + then Foreign.Storable.poke + t w + GHC.Base.>> + go + (GHC.Ptr.plusPtr + f #1) + (GHC.Ptr.plusPtr + t #1) + else go + (GHC.Ptr.plusPtr + f #1) t) in + go pf pt in + go' pIn pOut GHC.Base.>>= + (fun t => + GHC.Base.return_ + (GHC.Ptr.minusPtr t + pOut))))). + +Definition find + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> option GHC.Word.Word8 := + fun f p => + match findIndex f p with + | Some n => Some (Data.ByteString.Unsafe.unsafeIndex p n) + | _ => None + end. + +Definition partition + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun f s => + let decr := (fun arg_0__ => GHC.Ptr.plusPtr arg_0__ (GHC.Num.negate #1)) in + let incr := (fun arg_2__ => GHC.Ptr.plusPtr arg_2__ #1) in + let fix rev p1 p2 + := if p1 GHC.Base.>= p2 : bool then GHC.Base.return_ tt else + Foreign.Storable.peek p1 GHC.Base.>>= + (fun a => + Foreign.Storable.peek p2 GHC.Base.>>= + (fun b => + Foreign.Storable.poke p1 b GHC.Base.>> + (Foreign.Storable.poke p2 a GHC.Base.>> rev (incr p1) (decr p2)))) in + let len := length s in + let fix sep i p1 p2 + := let w := Data.ByteString.Unsafe.unsafeIndex s i in + if i GHC.Base.== len : bool then GHC.Base.return_ p1 else + if f w : bool + then Foreign.Storable.poke p1 w GHC.Base.>> + sep (i GHC.Num.+ #1) (incr p1) p2 else + Foreign.Storable.poke p2 w GHC.Base.>> sep (i GHC.Num.+ #1) p1 (decr p2) in + GHC.IO.Unsafe.unsafeDupablePerformIO (Data.ByteString.Internal.mallocByteString + len GHC.Base.>>= + (fun fp' => + Data.ByteString.Internal.unsafeWithForeignPtr fp' (fun p => + let end := + GHC.Ptr.plusPtr p + (len + GHC.Num.- + #1) in + sep #0 p end + GHC.Base.>>= + (fun mid => + rev mid end + GHC.Base.>> + (let i := + GHC.Ptr.minusPtr + mid p in + GHC.Base.return_ + (pair + (Data.ByteString.Internal.BS + fp' i) + (Data.ByteString.Internal.BS + (GHC.ForeignPtr.plusForeignPtr + fp' i) (len + GHC.Num.- + i)))))))). + +Definition isPrefixOf + : Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> bool := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | Data.ByteString.Internal.BS x1 l1, Data.ByteString.Internal.BS x2 l2 => + if l1 GHC.Base.== #0 : bool then true else + if l2 GHC.Base.< l1 : bool then false else + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x1 (fun p1 => + Data.ByteString.Internal.unsafeWithForeignPtr x2 (fun p2 => + Data.ByteString.Internal.memcmp + p1 p2 + (GHC.Real.fromIntegral + l1) + GHC.Base.>>= + (fun i => + GHC.Base.return_ + (i + GHC.Base.== + #0))))) + end. + +Definition stripPrefix + : Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> + option Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | (Data.ByteString.Internal.BS _ l1 as bs1), bs2 => + if isPrefixOf bs1 bs2 : bool + then Some (Data.ByteString.Unsafe.unsafeDrop l1 bs2) else + None + end. + +Definition isSuffixOf + : Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> bool := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | Data.ByteString.Internal.BS x1 l1, Data.ByteString.Internal.BS x2 l2 => + if l1 GHC.Base.== #0 : bool then true else + if l2 GHC.Base.< l1 : bool then false else + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x1 (fun p1 => + Data.ByteString.Internal.unsafeWithForeignPtr x2 (fun p2 => + Data.ByteString.Internal.memcmp + p1 + (GHC.Ptr.plusPtr + p2 (l2 + GHC.Num.- + l1)) + (GHC.Real.fromIntegral + l1) + GHC.Base.>>= + (fun i => + GHC.Base.return_ + (i + GHC.Base.== + #0))))) + end. + +Definition stripSuffix + : Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> + option Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | (Data.ByteString.Internal.BS _ l1 as bs1) + , (Data.ByteString.Internal.BS _ l2 as bs2) => + if isSuffixOf bs1 bs2 : bool + then Some (Data.ByteString.Unsafe.unsafeTake (l2 GHC.Num.- l1) bs2) else + None + end. + +Definition breakSubstring + : Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun pat => + let lp := length pat in + let unsafeSplitAt := + fun i s => + pair (Data.ByteString.Unsafe.unsafeTake i s) (Data.ByteString.Unsafe.unsafeDrop + i s) in + let karpRabin + : Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun src => + let get := + GHC.Real.fromIntegral GHC.Base.∘ Data.ByteString.Unsafe.unsafeIndex src in + let k := #2891336453 : GHC.Word.Word32 in + let rollingHash := + foldl' (fun h b => (h GHC.Num.* k) GHC.Num.+ GHC.Real.fromIntegral b) #0 in + let hp := rollingHash pat in + let m := k GHC.Real.^ lp in + let fix search hs i + := let hs' := + ((hs GHC.Num.* k) GHC.Num.+ get i) GHC.Num.- + (m GHC.Num.* get (i GHC.Num.- lp)) in + let '(pair _ b as u) := unsafeSplitAt (i GHC.Num.- lp) src in + if andb (hp GHC.Base.== hs) (pat GHC.Base.== + Data.ByteString.Unsafe.unsafeTake lp b) : bool + then u else + if length src GHC.Base.<= i : bool then pair src empty else + search hs' (i GHC.Num.+ #1) in + if length src GHC.Base.< lp : bool then pair src empty else + search (rollingHash (Data.ByteString.Unsafe.unsafeTake lp src)) lp in + let shift + : Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun src => + let mask := (Data.Bits.shiftL #1 (#8 GHC.Num.* lp)) GHC.Num.- #1 in + let intoWord : Data.ByteString.Internal.ByteString -> GHC.Num.Word := + foldl' (fun w b => + (Data.Bits.shiftL w #8) Data.Bits..|.(**) GHC.Real.fromIntegral b) #0 in + let wp := intoWord pat in + let fix search w i + := let b := GHC.Real.fromIntegral (Data.ByteString.Unsafe.unsafeIndex src i) in + let w' := + mask Data.Bits..&.(**) ((Data.Bits.shiftL w #8) Data.Bits..|.(**) b) in + if w GHC.Base.== wp : bool then unsafeSplitAt (i GHC.Num.- lp) src else + if length src GHC.Base.<= i : bool then pair src empty else + search w' (i GHC.Num.+ #1) in + if length src GHC.Base.< lp : bool then pair src empty else + search (intoWord (Data.ByteString.Unsafe.unsafeTake lp src)) lp in + let 'num_26__ := lp in + if num_26__ GHC.Base.== #0 : bool then fun arg_32__ => pair empty arg_32__ else + let 'num_27__ := lp in + if num_27__ GHC.Base.== #1 : bool + then breakByte (Data.ByteString.Unsafe.unsafeHead pat) else + if (lp GHC.Num.* #8) GHC.Base.<= + Data.Bits.finiteBitSize (#0 : GHC.Num.Word) : bool + then shift + else karpRabin. + +Definition isInfixOf + : Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> bool := + fun p s => orb (null p) (negb (null (Data.Tuple.snd (breakSubstring p s)))). + +Fixpoint zip (ps qs : Data.ByteString.Internal.ByteString) : list + (GHC.Word.Word8 * GHC.Word.Word8)%type + := match uncons ps with + | None => nil + | Some (pair psH psT) => + match uncons qs with + | None => nil + | Some (pair qsH qsT) => cons (pair psH qsH) (zip psT qsT) + end + end. + +Fixpoint zipWith {a : Type} (f : GHC.Word.Word8 -> GHC.Word.Word8 -> a) (ps qs + : Data.ByteString.Internal.ByteString) : list a + := match uncons ps with + | None => nil + | Some (pair psH psT) => + match uncons qs with + | None => nil + | Some (pair qsH qsT) => cons (f psH qsH) (zipWith f psT qsT) + end + end. + +Definition packZipWith + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ arg_2__ => + match arg_0__, arg_1__, arg_2__ with + | f, Data.ByteString.Internal.BS fp l, Data.ByteString.Internal.BS fq m => + let len := GHC.Base.min l m in + let go := + fun p1 p2 => + let zipWith_ : GHC.Num.Int -> GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO unit := + fix zipWith_ (n : GHC.Num.Int) (r : GHC.Ptr.Ptr GHC.Word.Word8) : GHC.Types.IO + unit + := if n GHC.Base.>= len : bool then GHC.Base.return_ tt else + Foreign.Storable.peekByteOff p1 n GHC.Base.>>= + (fun x => + Foreign.Storable.peekByteOff p2 n GHC.Base.>>= + (fun y => + Foreign.Storable.pokeByteOff r n (f x y) GHC.Base.>> + zipWith_ (n GHC.Num.+ #1) r)) in + zipWith_ #0 in + GHC.IO.Unsafe.unsafeDupablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp (fun a => + Data.ByteString.Internal.unsafeWithForeignPtr fq (fun b => + Data.ByteString.Internal.create + len (go a + b)))) + end. + +Definition unzip + : list (GHC.Word.Word8 * GHC.Word.Word8)%type -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun ls => + pair (pack (GHC.Base.map Data.Tuple.fst ls)) (pack (GHC.Base.map Data.Tuple.snd + ls)). + +Definition inits + : Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString := + fun '(Data.ByteString.Internal.BS x l) => + Coq.Lists.List.flat_map (fun n => cons (Data.ByteString.Internal.BS x n) nil) + (GHC.Enum.enumFromTo #0 l). + +Fixpoint tails (p : Data.ByteString.Internal.ByteString) : list + Data.ByteString.Internal.ByteString + := if null p : bool then cons empty nil else + cons p (tails (Data.ByteString.Unsafe.unsafeTail p)). + +Definition sort + : Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun '(Data.ByteString.Internal.BS input l) => + let countOccurrences + : GHC.Ptr.Ptr Foreign.C.Types.CSize -> + GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Num.Int -> GHC.Types.IO unit := + fun counts str len => + let fix go i + := if i GHC.Base.== len : bool then GHC.Base.return_ tt else + GHC.Base.fmap GHC.Real.fromIntegral (Foreign.Storable.peekElemOff str i) + GHC.Base.>>= + (fun k => + Foreign.Storable.peekElemOff counts k GHC.Base.>>= + (fun x => + Foreign.Storable.pokeElemOff counts k (x GHC.Num.+ #1) GHC.Base.>> + go (i GHC.Num.+ #1))) in + go #0 in + if l GHC.Base.<= #20 : bool + then Data.ByteString.Internal.unsafeCreate l (fun ptr => + Data.ByteString.Internal.unsafeWithForeignPtr input (fun inp => + Data.ByteString.Internal.memcpy + ptr inp + (GHC.Real.fromIntegral + l) + GHC.Base.>> + Data.ByteString.Internal.c_sort + ptr + (GHC.Real.fromIntegral + l))) else + Data.ByteString.Internal.unsafeCreate l (fun p => + Foreign.Marshal.Array.allocaArray #256 (fun arr => + Data.ByteString.Internal.memset + (GHC.Ptr.castPtr arr) #0 (#256 + GHC.Num.* + GHC.Real.fromIntegral + (Foreign.Storable.sizeOf + (GHC.Err.undefined : Foreign.C.Types.CSize))) + GHC.Base.>>= + (fun _ => + Data.ByteString.Internal.unsafeWithForeignPtr + input (fun x => + countOccurrences + arr x l) + GHC.Base.>> + (let fix go arg_7__ arg_8__ + := match arg_7__ + , arg_8__ with + | num_9__, _ => + if num_9__ + GHC.Base.== + #256 : bool + then GHC.Base.return_ + tt else + match arg_7__ + , arg_8__ with + | i, ptr => + Foreign.Storable.peekElemOff + arr i + GHC.Base.>>= + (fun n => + GHC.Base.when + (n + GHC.Base./= + #0) + (Data.Functor.void + (Data.ByteString.Internal.memset + ptr + (GHC.Real.fromIntegral + i) n)) + GHC.Base.>> + go (i + GHC.Num.+ + #1) + (GHC.Ptr.plusPtr + ptr + (GHC.Real.fromIntegral + n))) + end + end in + go #0 p)))). + +Definition moduleErrorIO {a} + : GHC.Base.String -> GHC.Base.String -> GHC.Types.IO a := + fun fun_ msg => + (GHC.IO.throwIO GHC.Base.∘ GHC.IO.Exception.userError) (moduleErrorMsg fun_ + msg). + +Definition packCStringLen + : Foreign.C.String.CStringLen -> + GHC.Types.IO Data.ByteString.Internal.ByteString := + fun arg_0__ => + let 'pair cstr len := arg_0__ in + if len GHC.Base.>= #0 : bool + then Data.ByteString.Internal.create len (fun p => + Data.ByteString.Internal.memcpy p (GHC.Ptr.castPtr cstr) + (GHC.Real.fromIntegral len)) else + let 'pair _ len := arg_0__ in + moduleErrorIO (GHC.Base.hs_string__ "packCStringLen") (Coq.Init.Datatypes.app + (GHC.Base.hs_string__ "negative length: ") (GHC.Show.show + len)). + +Definition packCString + : Foreign.C.String.CString -> + GHC.Types.IO Data.ByteString.Internal.ByteString := + fun cstr => + Data.ByteString.Internal.c_strlen cstr GHC.Base.>>= + (fun len => packCStringLen (pair cstr (GHC.Real.fromIntegral len))). + +Definition copy + : Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun '(Data.ByteString.Internal.BS x l) => + Data.ByteString.Internal.unsafeCreate l (fun p => + Data.ByteString.Internal.unsafeWithForeignPtr x (fun f => + Data.ByteString.Internal.memcpy + p f + (GHC.Real.fromIntegral + l))). + +Axiom hGetLine : forall {A : Type}, A. + +Definition getLine : GHC.Types.IO Data.ByteString.Internal.ByteString := + hGetLine GHC.IO.Handle.FD.stdin. + +(* Translating `hGetLine' failed: using a record pattern for the unknown + constructor `Handle__' unsupported [in definition Data.ByteString.hGetLine in + module Data.ByteString] *) + +Definition mkPS + : GHC.IO.Buffer.RawBuffer GHC.Word.Word8 -> + GHC.Num.Int -> + GHC.Num.Int -> GHC.Types.IO Data.ByteString.Internal.ByteString := + fun buf start end => + let len := end GHC.Num.- start in + Data.ByteString.Internal.create len (fun p => + GHC.IO.Buffer.withRawBuffer buf (fun pbuf => + Foreign.Marshal.Utils.copyBytes p + (GHC.Ptr.plusPtr pbuf start) len)). + +Definition mkBigPS + : GHC.Num.Int -> + list Data.ByteString.Internal.ByteString -> + GHC.Types.IO Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, cons ps nil => GHC.Base.return_ ps + | _, pss => GHC.Base.return_ (concat (GHC.List.reverse pss)) + end. + +Definition hPut + : GHC.IO.Handle.Types.Handle -> + Data.ByteString.Internal.ByteString -> GHC.Types.IO unit := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Internal.BS _ num_2__ => + if num_2__ GHC.Base.== #0 : bool then GHC.Base.return_ tt else + match arg_0__, arg_1__ with + | h, Data.ByteString.Internal.BS ps l => + Data.ByteString.Internal.unsafeWithForeignPtr ps (fun p => + GHC.IO.Handle.Text.hPutBuf h p l) + end + end. + +Definition hPutNonBlocking + : GHC.IO.Handle.Types.Handle -> + Data.ByteString.Internal.ByteString -> + GHC.Types.IO Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | h, (Data.ByteString.Internal.BS ps l as bs) => + Data.ByteString.Internal.unsafeWithForeignPtr ps (fun p => + GHC.IO.Handle.Text.hPutBufNonBlocking h p l) GHC.Base.>>= + (fun bytesWritten => GHC.Base.return_ (drop bytesWritten bs)) + end. + +Definition hPutStr + : GHC.IO.Handle.Types.Handle -> + Data.ByteString.Internal.ByteString -> GHC.Types.IO unit := + hPut. + +Definition putStr : Data.ByteString.Internal.ByteString -> GHC.Types.IO unit := + hPut GHC.IO.Handle.FD.stdout. + +Definition illegalBufferSize {a} + : GHC.IO.Handle.Types.Handle -> + GHC.Base.String -> GHC.Num.Int -> GHC.Types.IO a := + fun handle fn sz => + let msg := + Coq.Init.Datatypes.app fn (Coq.Init.Datatypes.app (GHC.Base.hs_string__ + ": illegal ByteString size ") (GHC.Show.showsPrec #9 sz + nil)) in + GHC.IO.Exception.ioError (System.IO.Error.mkIOError + System.IO.Error.illegalOperationErrorType msg (Some handle) None). + +Definition hGet + : GHC.IO.Handle.Types.Handle -> + GHC.Num.Int -> GHC.Types.IO Data.ByteString.Internal.ByteString := + fun h i => + if i GHC.Base.> #0 : bool + then Data.ByteString.Internal.createAndTrim i (fun p => + GHC.IO.Handle.Text.hGetBuf h p i) else + if i GHC.Base.== #0 : bool then GHC.Base.return_ empty else + illegalBufferSize h (GHC.Base.hs_string__ "hGet") i. + +Definition hGetNonBlocking + : GHC.IO.Handle.Types.Handle -> + GHC.Num.Int -> GHC.Types.IO Data.ByteString.Internal.ByteString := + fun h i => + if i GHC.Base.> #0 : bool + then Data.ByteString.Internal.createAndTrim i (fun p => + GHC.IO.Handle.Text.hGetBufNonBlocking h p i) else + if i GHC.Base.== #0 : bool then GHC.Base.return_ empty else + illegalBufferSize h (GHC.Base.hs_string__ "hGetNonBlocking") i. + +Definition hGetSome + : GHC.IO.Handle.Types.Handle -> + GHC.Num.Int -> GHC.Types.IO Data.ByteString.Internal.ByteString := + fun hh i => + if i GHC.Base.> #0 : bool + then Data.ByteString.Internal.createAndTrim i (fun p => + GHC.IO.Handle.Text.hGetBufSome hh p i) else + if i GHC.Base.== #0 : bool then GHC.Base.return_ empty else + illegalBufferSize hh (GHC.Base.hs_string__ "hGetSome") i. + +Definition hGetContentsSizeHint + : GHC.IO.Handle.Types.Handle -> + GHC.Num.Int -> + GHC.Num.Int -> GHC.Types.IO Data.ByteString.Internal.ByteString := + fun hnd => + let fix readChunks chunks sz sz' + := Data.ByteString.Internal.mallocByteString sz GHC.Base.>>= + (fun fp => + Data.ByteString.Internal.unsafeWithForeignPtr fp (fun buf => + GHC.IO.Handle.Text.hGetBuf hnd buf sz) GHC.Base.>>= + (fun readcount => + let chunk := Data.ByteString.Internal.BS fp readcount in + if andb (readcount GHC.Base.< sz) (sz GHC.Base.> #0) : bool + then GHC.Base.return_ (concat (GHC.List.reverse (cons chunk chunks))) + else readChunks (cons chunk chunks) sz' (GHC.Base.min (sz GHC.Num.+ sz') + #32752))) in + readChunks nil. + +Definition hGetContents + : GHC.IO.Handle.Types.Handle -> + GHC.Types.IO Data.ByteString.Internal.ByteString := + fun hnd => + Control.Exception.Base.finally (hGetContentsSizeHint hnd #1024 #2048) + (GHC.IO.Handle.hClose hnd) GHC.Base.>>= + (fun bs => + if length bs GHC.Base.< #900 : bool + then GHC.Base.return_ (copy bs) + else GHC.Base.return_ bs). + +Definition getContents : GHC.Types.IO Data.ByteString.Internal.ByteString := + hGetContents GHC.IO.Handle.FD.stdin. + +Definition interact + : (Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString) -> + GHC.Types.IO unit := + fun transformer => (putStr GHC.Base.∘ transformer) GHC.Base.=<< getContents. + +Definition readFile + : GHC.Base.String -> GHC.Types.IO Data.ByteString.Internal.ByteString := + fun f => + let useZeroIfNotRegularFile + : GHC.IO.Exception.IOException -> GHC.Types.IO GHC.Integer.Type.Integer := + fun arg_0__ => GHC.Base.return_ #0 in + System.IO.withBinaryFile f GHC.IO.IOMode.ReadMode (fun h => + GHC.IO.catch (GHC.IO.Handle.hFileSize h) + useZeroIfNotRegularFile GHC.Base.>>= + (fun filesz => + let readsz := + (GHC.Base.max (GHC.Real.fromIntegral filesz) #0) GHC.Num.+ + #1 in + hGetContentsSizeHint h readsz (GHC.Base.max readsz #255))). + +Definition modifyFile + : GHC.IO.IOMode.IOMode -> + GHC.Base.String -> Data.ByteString.Internal.ByteString -> GHC.Types.IO unit := + fun mode f txt => + System.IO.withBinaryFile f mode (fun arg_0__ => hPut arg_0__ txt). + +Definition writeFile + : GHC.Base.String -> + Data.ByteString.Internal.ByteString -> GHC.Types.IO unit := + modifyFile GHC.IO.IOMode.WriteMode. + +Definition appendFile + : GHC.Base.String -> + Data.ByteString.Internal.ByteString -> GHC.Types.IO unit := + modifyFile GHC.IO.IOMode.AppendMode. + +Module Notations. +Notation "'_Data.ByteString.!?_'" := (op_znz3fU__). +Infix "Data.ByteString.!?" := (_!?_) (at level 99). +End Notations. + +(* External variables: + None Some Type andb bool cons false list negb nil op_zt__ option orb pair true + tt unit Control.Exception.Base.finally Coq.Init.Datatypes.app + Coq.Lists.List.flat_map Data.Bits.finiteBitSize Data.Bits.op_zizazi__ + Data.Bits.op_zizbzi__ Data.Bits.shiftL Data.ByteString.Internal.BS + Data.ByteString.Internal.ByteString + Data.ByteString.Internal.accursedUnutterablePerformIO + Data.ByteString.Internal.c_count Data.ByteString.Internal.c_intersperse + Data.ByteString.Internal.c_maximum Data.ByteString.Internal.c_minimum + Data.ByteString.Internal.c_reverse Data.ByteString.Internal.c_sort + Data.ByteString.Internal.c_strlen Data.ByteString.Internal.create + Data.ByteString.Internal.createAndTrim Data.ByteString.Internal.createAndTrim' + Data.ByteString.Internal.findIndexOrLength + Data.ByteString.Internal.mallocByteString Data.ByteString.Internal.memchr + Data.ByteString.Internal.memcmp Data.ByteString.Internal.memcpy + Data.ByteString.Internal.memset Data.ByteString.Internal.nullForeignPtr + Data.ByteString.Internal.packBytes Data.ByteString.Internal.unsafeCreate + Data.ByteString.Internal.unsafeWithForeignPtr Data.ByteString.Unsafe.unsafeDrop + Data.ByteString.Unsafe.unsafeHead Data.ByteString.Unsafe.unsafeIndex + Data.ByteString.Unsafe.unsafePackMallocCStringLen + Data.ByteString.Unsafe.unsafeTail Data.ByteString.Unsafe.unsafeTake + Data.Functor.op_zlzdzg__ Data.Functor.void Data.OldList.intersperse + Data.OldList.transpose Data.Tuple.fst Data.Tuple.snd Foreign.C.String.CString + Foreign.C.String.CStringLen Foreign.C.Types.CSize + Foreign.ForeignPtr.Imp.withForeignPtr Foreign.Marshal.Alloc.allocaBytes + Foreign.Marshal.Array.allocaArray Foreign.Marshal.Utils.copyBytes + Foreign.Storable.peek Foreign.Storable.peekByteOff Foreign.Storable.peekElemOff + Foreign.Storable.poke Foreign.Storable.pokeByteOff Foreign.Storable.pokeElemOff + Foreign.Storable.sizeOf GHC.Base.String GHC.Base.assert GHC.Base.build' + GHC.Base.fmap GHC.Base.map GHC.Base.mappend GHC.Base.max GHC.Base.mconcat + GHC.Base.min GHC.Base.op_z2218U__ GHC.Base.op_zeze__ GHC.Base.op_zezlzl__ + GHC.Base.op_zg__ GHC.Base.op_zgze__ GHC.Base.op_zgzg__ GHC.Base.op_zgzgze__ + GHC.Base.op_zl__ GHC.Base.op_zlze__ GHC.Base.op_zsze__ GHC.Base.return_ + GHC.Base.when GHC.Enum.enumFromTo GHC.Err.error GHC.Err.undefined + GHC.Foreign.newCStringLen GHC.Foreign.peekCStringLen GHC.ForeignPtr.ForeignPtr + GHC.ForeignPtr.plusForeignPtr GHC.ForeignPtr.touchForeignPtr + GHC.ForeignPtr.unsafeForeignPtrToPtr GHC.IO.catch GHC.IO.throwIO + GHC.IO.Buffer.RawBuffer GHC.IO.Buffer.withRawBuffer + GHC.IO.Encoding.getFileSystemEncoding GHC.IO.Exception.IOException + GHC.IO.Exception.ioError GHC.IO.Exception.userError GHC.IO.Handle.hClose + GHC.IO.Handle.hFileSize GHC.IO.Handle.FD.stdin GHC.IO.Handle.FD.stdout + GHC.IO.Handle.Text.hGetBuf GHC.IO.Handle.Text.hGetBufNonBlocking + GHC.IO.Handle.Text.hGetBufSome GHC.IO.Handle.Text.hPutBuf + GHC.IO.Handle.Text.hPutBufNonBlocking GHC.IO.Handle.Types.Handle + GHC.IO.IOMode.AppendMode GHC.IO.IOMode.IOMode GHC.IO.IOMode.ReadMode + GHC.IO.IOMode.WriteMode GHC.IO.Unsafe.unsafeDupablePerformIO + GHC.IO.Unsafe.unsafePerformIO GHC.Integer.Type.Integer GHC.List.reverse + GHC.Num.Int GHC.Num.Word GHC.Num.fromInteger GHC.Num.negate GHC.Num.op_zm__ + GHC.Num.op_zp__ GHC.Num.op_zt__ GHC.Ptr.Ptr GHC.Ptr.castPtr GHC.Ptr.minusPtr + GHC.Ptr.nullPtr GHC.Ptr.plusPtr GHC.Real.fromIntegral GHC.Real.op_zc__ + GHC.Show.show GHC.Show.showsPrec GHC.Types.IO GHC.Word.Word32 GHC.Word.Word8 + System.IO.withBinaryFile System.IO.Error.illegalOperationErrorType + System.IO.Error.mkIOError +*) diff --git a/examples/bytestring/lib/Data/ByteString/Builder.h2ci b/examples/bytestring/lib/Data/ByteString/Builder.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString/Builder.v b/examples/bytestring/lib/Data/ByteString/Builder.v new file mode 100644 index 000000000..c30f5fdef --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder.v @@ -0,0 +1,94 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.ByteString.Builder.Internal. +Require Data.ByteString.Lazy.Internal. +Require GHC.Base. +Require GHC.Char. + +(* No type declarations to convert. *) + +(* Converted value declarations: *) + +(* Skipping all instances of class `GHC.Show.Show', including + `Data.ByteString.Builder.Show__Builder' *) + +Axiom toLazyByteString : Data.ByteString.Builder.Internal.Builder -> + Data.ByteString.Lazy.Internal.ByteString. + +Axiom hPutBuilder : GHC.IO.Handle.Types.Handle -> + Data.ByteString.Builder.Internal.Builder -> GHC.Types.IO unit. + +Axiom modifyFile : GHC.IO.IOMode.IOMode -> + GHC.Base.String -> + Data.ByteString.Builder.Internal.Builder -> GHC.Types.IO unit. + +Axiom writeFile : GHC.Base.String -> + Data.ByteString.Builder.Internal.Builder -> GHC.Types.IO unit. + +Axiom int8 : GHC.Int.Int8 -> Data.ByteString.Builder.Internal.Builder. + +Axiom word8 : GHC.Word.Word8 -> Data.ByteString.Builder.Internal.Builder. + +Axiom int16LE : GHC.Int.Int16 -> Data.ByteString.Builder.Internal.Builder. + +Axiom int32LE : GHC.Int.Int32 -> Data.ByteString.Builder.Internal.Builder. + +Axiom int64LE : GHC.Int.Int64 -> Data.ByteString.Builder.Internal.Builder. + +Axiom word16LE : GHC.Word.Word16 -> Data.ByteString.Builder.Internal.Builder. + +Axiom word32LE : GHC.Word.Word32 -> Data.ByteString.Builder.Internal.Builder. + +Axiom word64LE : GHC.Word.Word64 -> Data.ByteString.Builder.Internal.Builder. + +Axiom floatLE : GHC.Types.Float -> Data.ByteString.Builder.Internal.Builder. + +Axiom doubleLE : GHC.Types.Double -> Data.ByteString.Builder.Internal.Builder. + +Axiom int16BE : GHC.Int.Int16 -> Data.ByteString.Builder.Internal.Builder. + +Axiom int32BE : GHC.Int.Int32 -> Data.ByteString.Builder.Internal.Builder. + +Axiom int64BE : GHC.Int.Int64 -> Data.ByteString.Builder.Internal.Builder. + +Axiom word16BE : GHC.Word.Word16 -> Data.ByteString.Builder.Internal.Builder. + +Axiom word32BE : GHC.Word.Word32 -> Data.ByteString.Builder.Internal.Builder. + +Axiom word64BE : GHC.Word.Word64 -> Data.ByteString.Builder.Internal.Builder. + +Axiom floatBE : GHC.Types.Float -> Data.ByteString.Builder.Internal.Builder. + +Axiom doubleBE : GHC.Types.Double -> Data.ByteString.Builder.Internal.Builder. + +Axiom char7 : GHC.Char.Char -> Data.ByteString.Builder.Internal.Builder. + +Axiom string7 : GHC.Base.String -> Data.ByteString.Builder.Internal.Builder. + +Axiom char8 : GHC.Char.Char -> Data.ByteString.Builder.Internal.Builder. + +Axiom string8 : GHC.Base.String -> Data.ByteString.Builder.Internal.Builder. + +Axiom charUtf8 : GHC.Char.Char -> Data.ByteString.Builder.Internal.Builder. + +Axiom stringUtf8 : GHC.Base.String -> Data.ByteString.Builder.Internal.Builder. + +(* External variables: + unit Data.ByteString.Builder.Internal.Builder + Data.ByteString.Lazy.Internal.ByteString GHC.Base.String GHC.Char.Char + GHC.IO.Handle.Types.Handle GHC.IO.IOMode.IOMode GHC.Int.Int16 GHC.Int.Int32 + GHC.Int.Int64 GHC.Int.Int8 GHC.Types.Double GHC.Types.Float GHC.Types.IO + GHC.Word.Word16 GHC.Word.Word32 GHC.Word.Word64 GHC.Word.Word8 +*) diff --git a/examples/bytestring/lib/Data/ByteString/Builder/ASCII.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/ASCII.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/ASCII.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString/Builder/ASCII.v b/examples/bytestring/lib/Data/ByteString/Builder/ASCII.v new file mode 100644 index 000000000..db1b39b15 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/ASCII.v @@ -0,0 +1,308 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Coq.Init.Datatypes. +Require Data.ByteString.Builder.Internal. +Require Data.ByteString.Builder.Prim. +Require Data.ByteString.Builder.Prim.ASCII. +Require Data.ByteString.Builder.Prim.Internal. +Require Data.ByteString.Internal. +Require Data.ByteString.Lazy.Internal. +Require GHC.Base. +Require GHC.Err. +Require GHC.Num. +Require GHC.Real. +Import GHC.Base.Notations. +Import GHC.Num.Notations. +Import GHC.Real.Notations. + +(* No type declarations to convert. *) + +(* Converted value declarations: *) + +Definition string7 + : GHC.Base.String -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primMapListFixed + Data.ByteString.Builder.Prim.ASCII.char7. + +Definition int8Dec : GHC.Int.Int8 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.int8Dec. + +Definition int16Dec + : GHC.Int.Int16 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.int16Dec. + +Definition int32Dec + : GHC.Int.Int32 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.int32Dec. + +Definition int64Dec + : GHC.Int.Int64 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.int64Dec. + +Definition intDec : GHC.Num.Int -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.intDec. + +Definition word8Dec + : GHC.Word.Word8 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.word8Dec. + +Definition word16Dec + : GHC.Word.Word16 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.word16Dec. + +Definition word32Dec + : GHC.Word.Word32 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.word32Dec. + +Definition word64Dec + : GHC.Word.Word64 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.word64Dec. + +Definition wordDec : GHC.Num.Word -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.wordDec. + +Definition floatDec + : GHC.Types.Float -> Data.ByteString.Builder.Internal.Builder := + string7 GHC.Base.∘ GHC.Show.show. + +Definition doubleDec + : GHC.Types.Double -> Data.ByteString.Builder.Internal.Builder := + string7 GHC.Base.∘ GHC.Show.show. + +Definition word8Hex + : GHC.Word.Word8 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.word8Hex. + +Definition word16Hex + : GHC.Word.Word16 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.word16Hex. + +Definition word32Hex + : GHC.Word.Word32 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.word32Hex. + +Definition word64Hex + : GHC.Word.Word64 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.word64Hex. + +Definition wordHex : GHC.Num.Word -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.ASCII.wordHex. + +Definition int8HexFixed + : GHC.Int.Int8 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.ASCII.int8HexFixed. + +Definition int16HexFixed + : GHC.Int.Int16 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.ASCII.int16HexFixed. + +Definition int32HexFixed + : GHC.Int.Int32 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.ASCII.int32HexFixed. + +Definition int64HexFixed + : GHC.Int.Int64 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.ASCII.int64HexFixed. + +Definition word8HexFixed + : GHC.Word.Word8 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.ASCII.word8HexFixed. + +Definition word16HexFixed + : GHC.Word.Word16 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.ASCII.word16HexFixed. + +Definition word32HexFixed + : GHC.Word.Word32 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.ASCII.word32HexFixed. + +Definition word64HexFixed + : GHC.Word.Word64 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.ASCII.word64HexFixed. + +Definition floatHexFixed + : GHC.Types.Float -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.ASCII.floatHexFixed. + +Definition doubleHexFixed + : GHC.Types.Double -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.ASCII.doubleHexFixed. + +Definition byteStringHex + : Data.ByteString.Internal.ByteString -> + Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primMapByteStringFixed + Data.ByteString.Builder.Prim.ASCII.word8HexFixed. + +Definition lazyByteStringHex + : Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primMapLazyByteStringFixed + Data.ByteString.Builder.Prim.ASCII.word8HexFixed. + +Definition maxPow10 : GHC.Integer.Type.Integer := + GHC.Real.toInteger ((#10 : GHC.Num.Int) GHC.Real.^ + Data.ByteString.Builder.Prim.Internal.caseWordSize_32_64 (#9 : GHC.Num.Int) + #18). + +Definition intDecPadded + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Num.Int := + Data.ByteString.Builder.Prim.Internal.liftFixedToBounded + (Data.ByteString.Builder.Prim.Internal.caseWordSize_32_64 + (Data.ByteString.Builder.Prim.Internal.fixedPrim #9 (c_int_dec_padded9 + GHC.Base.∘ + GHC.Real.fromIntegral)) + (Data.ByteString.Builder.Prim.Internal.fixedPrim #18 + (c_long_long_int_dec_padded18 GHC.Base.∘ GHC.Real.fromIntegral))). + +Definition integerDec + : GHC.Integer.Type.Integer -> Data.ByteString.Builder.Internal.Builder := + fun i => + let putB : list GHC.Integer.Type.Integer -> list GHC.Num.Int := + fix putB (arg_0__ : list GHC.Integer.Type.Integer) : list GHC.Num.Int + := match arg_0__ with + | nil => nil + | cons n ns => + let 'pair q r := GHC.Real.quotRem n maxPow10 in + cons (GHC.Num.fromInteger q) (cons (GHC.Num.fromInteger r) (putB ns)) + end in + let errImpossible := + fun fun_ => + GHC.Err.error (Coq.Init.Datatypes.app (GHC.Base.hs_string__ "integerDec: ") + (Coq.Init.Datatypes.app fun_ (GHC.Base.hs_string__ + ": the impossible happened."))) in + let splitf + : GHC.Integer.Type.Integer -> + GHC.Integer.Type.Integer -> list GHC.Integer.Type.Integer := + fix splitf (pow10 n0 : GHC.Integer.Type.Integer) : list GHC.Integer.Type.Integer + := let fix splitb arg_7__ + := match arg_7__ with + | nil => nil + | cons n ns => + let 'pair q r := GHC.Real.quotRem n pow10 in + cons q (cons r (splitb ns)) + end in + let splith := + fun arg_13__ => + match arg_13__ with + | nil => errImpossible (GHC.Base.hs_string__ "splith") + | cons n ns => + let 'pair q r := GHC.Real.quotRem n pow10 in + if q GHC.Base.> #0 : bool then cons q (cons r (splitb ns)) else + cons r (splitb ns) + end in + if pow10 GHC.Base.> n0 : bool then cons n0 nil else + splith (splitf (pow10 GHC.Num.* pow10) n0) in + let putH : list GHC.Integer.Type.Integer -> list GHC.Num.Int := + fun arg_23__ => + match arg_23__ with + | nil => errImpossible (GHC.Base.hs_string__ "putH") + | cons n ns => + let 'pair x y := GHC.Real.quotRem n maxPow10 in + let r := GHC.Num.fromInteger y in + let q := GHC.Num.fromInteger x in + if q GHC.Base.> #0 : bool then cons q (cons r (putB ns)) else + cons r (putB ns) + end in + let go : GHC.Integer.Type.Integer -> Data.ByteString.Builder.Internal.Builder := + fun n => + if n GHC.Base.< maxPow10 : bool then intDec (GHC.Num.fromInteger n) else + match putH (splitf (maxPow10 GHC.Num.* maxPow10) n) with + | cons x xs => + GHC.Base.mappend (intDec x) (Data.ByteString.Builder.Prim.primMapListBounded + intDecPadded xs) + | nil => errImpossible (GHC.Base.hs_string__ "integerDec: go") + end in + let 'i' := GHC.Num.fromInteger i in + if GHC.Real.toInteger i' GHC.Base.== i : bool then intDec i' else + if i GHC.Base.< #0 : bool + then GHC.Base.mappend (Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.char8 (GHC.Char.hs_char__ "-")) (go (GHC.Num.negate + i)) else + go i. + +(* External variables: + bool c_int_dec_padded9 c_long_long_int_dec_padded18 cons list nil pair + Coq.Init.Datatypes.app Data.ByteString.Builder.Internal.Builder + Data.ByteString.Builder.Prim.char8 Data.ByteString.Builder.Prim.primBounded + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.primMapByteStringFixed + Data.ByteString.Builder.Prim.primMapLazyByteStringFixed + Data.ByteString.Builder.Prim.primMapListBounded + Data.ByteString.Builder.Prim.primMapListFixed + Data.ByteString.Builder.Prim.ASCII.char7 + Data.ByteString.Builder.Prim.ASCII.doubleHexFixed + Data.ByteString.Builder.Prim.ASCII.floatHexFixed + Data.ByteString.Builder.Prim.ASCII.int16Dec + Data.ByteString.Builder.Prim.ASCII.int16HexFixed + Data.ByteString.Builder.Prim.ASCII.int32Dec + Data.ByteString.Builder.Prim.ASCII.int32HexFixed + Data.ByteString.Builder.Prim.ASCII.int64Dec + Data.ByteString.Builder.Prim.ASCII.int64HexFixed + Data.ByteString.Builder.Prim.ASCII.int8Dec + Data.ByteString.Builder.Prim.ASCII.int8HexFixed + Data.ByteString.Builder.Prim.ASCII.intDec + Data.ByteString.Builder.Prim.ASCII.word16Dec + Data.ByteString.Builder.Prim.ASCII.word16Hex + Data.ByteString.Builder.Prim.ASCII.word16HexFixed + Data.ByteString.Builder.Prim.ASCII.word32Dec + Data.ByteString.Builder.Prim.ASCII.word32Hex + Data.ByteString.Builder.Prim.ASCII.word32HexFixed + Data.ByteString.Builder.Prim.ASCII.word64Dec + Data.ByteString.Builder.Prim.ASCII.word64Hex + Data.ByteString.Builder.Prim.ASCII.word64HexFixed + Data.ByteString.Builder.Prim.ASCII.word8Dec + Data.ByteString.Builder.Prim.ASCII.word8Hex + Data.ByteString.Builder.Prim.ASCII.word8HexFixed + Data.ByteString.Builder.Prim.ASCII.wordDec + Data.ByteString.Builder.Prim.ASCII.wordHex + Data.ByteString.Builder.Prim.Internal.BoundedPrim + Data.ByteString.Builder.Prim.Internal.caseWordSize_32_64 + Data.ByteString.Builder.Prim.Internal.fixedPrim + Data.ByteString.Builder.Prim.Internal.liftFixedToBounded + Data.ByteString.Internal.ByteString Data.ByteString.Lazy.Internal.ByteString + GHC.Base.String GHC.Base.mappend GHC.Base.op_z2218U__ GHC.Base.op_zeze__ + GHC.Base.op_zg__ GHC.Base.op_zl__ GHC.Err.error GHC.Int.Int16 GHC.Int.Int32 + GHC.Int.Int64 GHC.Int.Int8 GHC.Integer.Type.Integer GHC.Num.Int GHC.Num.Word + GHC.Num.fromInteger GHC.Num.negate GHC.Num.op_zt__ GHC.Real.fromIntegral + GHC.Real.op_zc__ GHC.Real.quotRem GHC.Real.toInteger GHC.Show.show + GHC.Types.Double GHC.Types.Float GHC.Word.Word16 GHC.Word.Word32 GHC.Word.Word64 + GHC.Word.Word8 +*) diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Extra.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Extra.h2ci new file mode 100644 index 000000000..d2e9573de --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Extra.h2ci @@ -0,0 +1,12 @@ +constructors: + Data.ByteString.Builder.Extra.Next: ! '[Qualified "Data.ByteString.Builder.Extra" + "Done",Qualified "Data.ByteString.Builder.Extra" "More",Qualified "Data.ByteString.Builder.Extra" + "Chunk"]' +constructorFields: + Data.ByteString.Builder.Extra.Done: NonRecordFields 0 + Data.ByteString.Builder.Extra.Chunk: NonRecordFields 2 + Data.ByteString.Builder.Extra.More: NonRecordFields 2 +constructorTypes: + Data.ByteString.Builder.Extra.Done: Qualified "Data.ByteString.Builder.Extra" "Next" + Data.ByteString.Builder.Extra.Chunk: Qualified "Data.ByteString.Builder.Extra" "Next" + Data.ByteString.Builder.Extra.More: Qualified "Data.ByteString.Builder.Extra" "Next" diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Extra.v b/examples/bytestring/lib/Data/ByteString/Builder/Extra.v new file mode 100644 index 000000000..0d73ab00c --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Extra.v @@ -0,0 +1,145 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.ByteString.Builder.Internal. +Require Data.ByteString.Builder.Prim. +Require Data.ByteString.Builder.Prim.Binary. +Require Data.ByteString.Internal. +Require GHC.Base. +Require GHC.Num. +Require HsToCoq.Err. +Import GHC.Base.Notations. + +(* Converted type declarations: *) + +Inductive Next : Type := + | Done : Next + | More + : GHC.Num.Int -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Num.Int -> GHC.Types.IO (GHC.Num.Int * Next)%type)%type -> + Next + | Chunk + : Data.ByteString.Internal.ByteString -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Num.Int -> GHC.Types.IO (GHC.Num.Int * Next)%type)%type -> + Next. + +Definition BufferWriter := + (GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Num.Int -> GHC.Types.IO (GHC.Num.Int * Next)%type)%type. + +Instance Default__Next : HsToCoq.Err.Default Next := + HsToCoq.Err.Build_Default _ Done. + +(* Converted value declarations: *) + +Definition runBuilder + : Data.ByteString.Builder.Internal.Builder -> BufferWriter := + let bytesWritten := fun startPtr endPtr => GHC.Ptr.minusPtr endPtr startPtr in + let run : Data.ByteString.Builder.Internal.BuildStep unit -> BufferWriter := + fix run (step : Data.ByteString.Builder.Internal.BuildStep unit) : BufferWriter + := fun buf len => + let br := + Data.ByteString.Builder.Internal.BufferRange buf (GHC.Ptr.plusPtr buf len) in + let insertChunkH := + fun endPtr bs step' => + let next := Chunk bs (run step') in + let wc := bytesWritten buf endPtr in GHC.Base.return_ (pair wc next) in + let bufferFullH := + fun endPtr minReq step' => + let next := More minReq (run step') in + let wc := bytesWritten buf endPtr in GHC.Base.return_ (pair wc next) in + let doneH := + fun arg_8__ arg_9__ => + match arg_8__, arg_9__ with + | endPtr, tt => + let next := Done in + let wc := bytesWritten buf endPtr in GHC.Base.return_ (pair wc next) + end in + Data.ByteString.Builder.Internal.fillWithBuildStep step doneH bufferFullH + insertChunkH br in + run GHC.Base.∘ Data.ByteString.Builder.Internal.runBuilder. + +Definition intHost : GHC.Num.Int -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.Binary.intHost. + +Definition int16Host + : GHC.Int.Int16 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.Binary.int16Host. + +Definition int32Host + : GHC.Int.Int32 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.Binary.int32Host. + +Definition int64Host + : GHC.Int.Int64 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.Binary.int64Host. + +Definition wordHost + : GHC.Num.Word -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.Binary.wordHost. + +Definition word16Host + : GHC.Word.Word16 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.Binary.word16Host. + +Definition word32Host + : GHC.Word.Word32 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.Binary.word32Host. + +Definition word64Host + : GHC.Word.Word64 -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.Binary.word64Host. + +Definition floatHost + : GHC.Types.Float -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.Binary.floatHost. + +Definition doubleHost + : GHC.Types.Double -> Data.ByteString.Builder.Internal.Builder := + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.Binary.doubleHost. + +(* External variables: + op_zt__ pair tt unit Data.ByteString.Builder.Internal.BufferRange + Data.ByteString.Builder.Internal.BuildStep + Data.ByteString.Builder.Internal.Builder + Data.ByteString.Builder.Internal.fillWithBuildStep + Data.ByteString.Builder.Internal.runBuilder + Data.ByteString.Builder.Prim.primFixed + Data.ByteString.Builder.Prim.Binary.doubleHost + Data.ByteString.Builder.Prim.Binary.floatHost + Data.ByteString.Builder.Prim.Binary.int16Host + Data.ByteString.Builder.Prim.Binary.int32Host + Data.ByteString.Builder.Prim.Binary.int64Host + Data.ByteString.Builder.Prim.Binary.intHost + Data.ByteString.Builder.Prim.Binary.word16Host + Data.ByteString.Builder.Prim.Binary.word32Host + Data.ByteString.Builder.Prim.Binary.word64Host + Data.ByteString.Builder.Prim.Binary.wordHost Data.ByteString.Internal.ByteString + GHC.Base.op_z2218U__ GHC.Base.return_ GHC.Int.Int16 GHC.Int.Int32 GHC.Int.Int64 + GHC.Num.Int GHC.Num.Word GHC.Ptr.Ptr GHC.Ptr.minusPtr GHC.Ptr.plusPtr + GHC.Types.Double GHC.Types.Float GHC.Types.IO GHC.Word.Word16 GHC.Word.Word32 + GHC.Word.Word64 GHC.Word.Word8 HsToCoq.Err.Build_Default HsToCoq.Err.Default +*) diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Internal.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Internal.h2ci new file mode 100644 index 000000000..c785978d4 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Internal.h2ci @@ -0,0 +1,52 @@ +constructors: + Data.ByteString.Builder.Internal.AllocationStrategy: ! '[Qualified "Data.ByteString.Builder.Internal" + "AllocationStrategy"]' + Data.ByteString.Builder.Internal.Builder: ! '[Qualified "Data.ByteString.Builder.Internal" + "Builder"]' + Data.ByteString.Builder.Internal.Buffer: ! '[Qualified "Data.ByteString.Builder.Internal" + "Buffer"]' + Data.ByteString.Builder.Internal.ChunkIOStream: ! '[Qualified "Data.ByteString.Builder.Internal" + "Finished",Qualified "Data.ByteString.Builder.Internal" "Yield1"]' + Data.ByteString.Builder.Internal.Put: ! '[Qualified "Data.ByteString.Builder.Internal" + "Put"]' + Data.ByteString.Builder.Internal.BufferRange: ! '[Qualified "Data.ByteString.Builder.Internal" + "BufferRange"]' + Data.ByteString.Builder.Internal.BuildSignal: ! '[Qualified "Data.ByteString.Builder.Internal" + "Done",Qualified "Data.ByteString.Builder.Internal" "BufferFull",Qualified "Data.ByteString.Builder.Internal" + "InsertChunk"]' +constructorFields: + Data.ByteString.Builder.Internal.AllocationStrategy: NonRecordFields 3 + Data.ByteString.Builder.Internal.Builder: NonRecordFields 1 + Data.ByteString.Builder.Internal.Finished: NonRecordFields 2 + Data.ByteString.Builder.Internal.Buffer: NonRecordFields 2 + Data.ByteString.Builder.Internal.BufferFull: NonRecordFields 3 + Data.ByteString.Builder.Internal.InsertChunk: NonRecordFields 3 + Data.ByteString.Builder.Internal.Yield1: NonRecordFields 2 + Data.ByteString.Builder.Internal.Put: RecordFields [Qualified "Data.ByteString.Builder.Internal" + "unPut"] + Data.ByteString.Builder.Internal.BufferRange: NonRecordFields 2 + Data.ByteString.Builder.Internal.Done: NonRecordFields 2 +recordFieldTypes: + Data.ByteString.Builder.Internal.unPut: Qualified "Data.ByteString.Builder.Internal" + "Put" +constructorTypes: + Data.ByteString.Builder.Internal.AllocationStrategy: Qualified "Data.ByteString.Builder.Internal" + "AllocationStrategy" + Data.ByteString.Builder.Internal.Builder: Qualified "Data.ByteString.Builder.Internal" + "Builder" + Data.ByteString.Builder.Internal.Finished: Qualified "Data.ByteString.Builder.Internal" + "ChunkIOStream" + Data.ByteString.Builder.Internal.Buffer: Qualified "Data.ByteString.Builder.Internal" + "Buffer" + Data.ByteString.Builder.Internal.BufferFull: Qualified "Data.ByteString.Builder.Internal" + "BuildSignal" + Data.ByteString.Builder.Internal.InsertChunk: Qualified "Data.ByteString.Builder.Internal" + "BuildSignal" + Data.ByteString.Builder.Internal.Yield1: Qualified "Data.ByteString.Builder.Internal" + "ChunkIOStream" + Data.ByteString.Builder.Internal.Put: Qualified "Data.ByteString.Builder.Internal" + "Put" + Data.ByteString.Builder.Internal.BufferRange: Qualified "Data.ByteString.Builder.Internal" + "BufferRange" + Data.ByteString.Builder.Internal.Done: Qualified "Data.ByteString.Builder.Internal" + "BuildSignal" diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Internal.v b/examples/bytestring/lib/Data/ByteString/Builder/Internal.v new file mode 100644 index 000000000..37c647be3 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Internal.v @@ -0,0 +1,243 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.ByteString.Internal. +Require Data.ByteString.Lazy.Internal. +Require Data.ByteString.Short.Internal. +Require GHC.Base. +Require GHC.Num. + +(* Converted type declarations: *) + +Inductive BufferRange : Type := + | BufferRange + : (GHC.Ptr.Ptr GHC.Word.Word8) -> (GHC.Ptr.Ptr GHC.Word.Word8) -> BufferRange. + +Inductive BuildSignal a : Type := + | Done : (GHC.Ptr.Ptr GHC.Word.Word8) -> a -> BuildSignal a + | BufferFull + : GHC.Num.Int -> + (GHC.Ptr.Ptr GHC.Word.Word8) -> + ((fun a_ => (BufferRange -> GHC.Types.IO (BuildSignal a_))%type) a) -> + BuildSignal a + | InsertChunk + : (GHC.Ptr.Ptr GHC.Word.Word8) -> + Data.ByteString.Internal.ByteString -> + ((fun a_ => (BufferRange -> GHC.Types.IO (BuildSignal a_))%type) a) -> + BuildSignal a. + +Definition BuildStep := + fun a_ => (BufferRange -> GHC.Types.IO (BuildSignal a_))%type. + +Inductive Builder : Type := + | Builder : (forall {r}, BuildStep r -> BuildStep r) -> Builder. + +Inductive Put a : Type := + | Put (unPut : forall {r}, (a -> BuildStep r) -> BuildStep r) : Put a. + +Inductive Buffer : Type := + | Buffer : (GHC.ForeignPtr.ForeignPtr GHC.Word.Word8) -> BufferRange -> Buffer. + +Inductive ChunkIOStream a : Type := + | Finished : Buffer -> a -> ChunkIOStream a + | Yield1 + : Data.ByteString.Internal.ByteString -> + (GHC.Types.IO (ChunkIOStream a)) -> ChunkIOStream a. + +Inductive AllocationStrategy : Type := + | AllocationStrategy + : (option (Buffer * GHC.Num.Int)%type -> GHC.Types.IO Buffer) -> + GHC.Num.Int -> (GHC.Num.Int -> GHC.Num.Int -> bool) -> AllocationStrategy. + +Arguments Done {_} _ _. + +Arguments BufferFull {_} _ _ _. + +Arguments InsertChunk {_} _ _ _. + +Arguments Put {_} _. + +Arguments Finished {_} _ _. + +Arguments Yield1 {_} _ _. + +Definition unPut {a} (arg_0__ : Put a) := + let 'Put unPut := arg_0__ in + unPut. + +(* Converted value declarations: *) + +Instance Semigroup__Builder : GHC.Base.Semigroup Builder. +Proof. +Admitted. + +Instance Monoid__Builder : GHC.Base.Monoid Builder. +Proof. +Admitted. + +Instance Functor__Put : GHC.Base.Functor Put. +Proof. +Admitted. + +Instance Applicative__Put : GHC.Base.Applicative Put. +Proof. +Admitted. + +Instance Monad__Put : GHC.Base.Monad Put. +Proof. +Admitted. + +Axiom bufferSize : Buffer -> GHC.Num.Int. + +Axiom newBuffer : GHC.Num.Int -> GHC.Types.IO Buffer. + +Axiom byteStringFromBuffer : Buffer -> Data.ByteString.Internal.ByteString. + +Axiom trimmedChunkFromBuffer : AllocationStrategy -> + Buffer -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString. + +Axiom yield1 : forall {a}, + Data.ByteString.Internal.ByteString -> + GHC.Types.IO (ChunkIOStream a) -> GHC.Types.IO (ChunkIOStream a). + +Axiom ciosUnitToLazyByteString : AllocationStrategy -> + Data.ByteString.Lazy.Internal.ByteString -> + ChunkIOStream unit -> Data.ByteString.Lazy.Internal.ByteString. + +Axiom ciosToLazyByteString : forall {a : Type}, + forall {b : Type}, + AllocationStrategy -> + (a -> (b * Data.ByteString.Lazy.Internal.ByteString)%type) -> + ChunkIOStream a -> (b * Data.ByteString.Lazy.Internal.ByteString)%type. + +Axiom done : forall {a : Type}, + GHC.Ptr.Ptr GHC.Word.Word8 -> a -> BuildSignal a. + +Axiom bufferFull : forall {a : Type}, + GHC.Num.Int -> GHC.Ptr.Ptr GHC.Word.Word8 -> BuildStep a -> BuildSignal a. + +Axiom insertChunk : forall {a : Type}, + GHC.Ptr.Ptr GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> BuildStep a -> BuildSignal a. + +Axiom fillWithBuildStep : forall {a : Type}, + forall {b : Type}, + BuildStep a -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> a -> GHC.Types.IO b) -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Num.Int -> BuildStep a -> GHC.Types.IO b) -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> BuildStep a -> GHC.Types.IO b) -> + BufferRange -> GHC.Types.IO b. + +Axiom builder : (forall {r : Type}, BuildStep r -> BuildStep r) -> Builder. + +Axiom finalBuildStep : BuildStep unit. + +Axiom runBuilder : Builder -> BuildStep unit. + +Axiom runBuilderWith : forall {a : Type}, Builder -> BuildStep a -> BuildStep a. + +Axiom empty : Builder. + +Axiom append : Builder -> Builder -> Builder. + +Axiom flush : Builder. + +Axiom put : forall {a : Type}, + (forall {r : Type}, (a -> BuildStep r) -> BuildStep r) -> Put a. + +Axiom runPut : forall {a : Type}, Put a -> BuildStep a. + +Axiom ap_l : forall {a} {b}, Put a -> Put b -> Put a. + +Axiom ap_r : forall {a} {b}, Put a -> Put b -> Put b. + +Axiom putBuilder : Builder -> Put unit. + +Axiom fromPut : Put unit -> Builder. + +Axiom hPut : forall {a : Type}, + GHC.IO.Handle.Types.Handle -> Put a -> GHC.Types.IO a. + +Axiom putToLazyByteString : forall {a : Type}, + Put a -> (a * Data.ByteString.Lazy.Internal.ByteString)%type. + +Axiom putToLazyByteStringWith : forall {a : Type}, + forall {b : Type}, + AllocationStrategy -> + (a -> (b * Data.ByteString.Lazy.Internal.ByteString)%type) -> + Put a -> (b * Data.ByteString.Lazy.Internal.ByteString)%type. + +Axiom ensureFree : GHC.Num.Int -> Builder. + +Axiom wrappedBytesCopyStep : forall {a}, + BufferRange -> BuildStep a -> BuildStep a. + +Axiom byteStringThreshold : GHC.Num.Int -> + Data.ByteString.Internal.ByteString -> Builder. + +Axiom byteStringCopy : Data.ByteString.Internal.ByteString -> Builder. + +Axiom byteStringCopyStep : forall {a}, + Data.ByteString.Internal.ByteString -> BuildStep a -> BuildStep a. + +Axiom byteStringInsert : Data.ByteString.Internal.ByteString -> Builder. + +Axiom shortByteString : Data.ByteString.Short.Internal.ShortByteString -> + Builder. + +Axiom shortByteStringCopyStep : forall {a}, + Data.ByteString.Short.Internal.ShortByteString -> BuildStep a -> BuildStep a. + +Axiom lazyByteStringThreshold : GHC.Num.Int -> + Data.ByteString.Lazy.Internal.ByteString -> Builder. + +Axiom lazyByteStringCopy : Data.ByteString.Lazy.Internal.ByteString -> Builder. + +Axiom lazyByteStringInsert : Data.ByteString.Lazy.Internal.ByteString -> + Builder. + +Axiom byteString : Data.ByteString.Internal.ByteString -> Builder. + +Axiom lazyByteString : Data.ByteString.Lazy.Internal.ByteString -> Builder. + +Axiom maximalCopySize : GHC.Num.Int. + +Axiom customStrategy : (option (Buffer * GHC.Num.Int)%type -> + GHC.Types.IO Buffer) -> + GHC.Num.Int -> (GHC.Num.Int -> GHC.Num.Int -> bool) -> AllocationStrategy. + +Axiom sanitize : GHC.Num.Int -> GHC.Num.Int. + +Axiom untrimmedStrategy : GHC.Num.Int -> GHC.Num.Int -> AllocationStrategy. + +Axiom safeStrategy : GHC.Num.Int -> GHC.Num.Int -> AllocationStrategy. + +Axiom toLazyByteStringWith : AllocationStrategy -> + Data.ByteString.Lazy.Internal.ByteString -> + Builder -> Data.ByteString.Lazy.Internal.ByteString. + +Axiom buildStepToCIOS : forall {a : Type}, + AllocationStrategy -> BuildStep a -> GHC.Types.IO (ChunkIOStream a). + +(* External variables: + Type bool op_zt__ option unit Data.ByteString.Internal.ByteString + Data.ByteString.Lazy.Internal.ByteString + Data.ByteString.Short.Internal.ShortByteString GHC.Base.Applicative + GHC.Base.Functor GHC.Base.Monad GHC.Base.Monoid GHC.Base.Semigroup + GHC.ForeignPtr.ForeignPtr GHC.IO.Handle.Types.Handle GHC.Num.Int GHC.Ptr.Ptr + GHC.Types.IO GHC.Word.Word8 +*) diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Prim.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim.v b/examples/bytestring/lib/Data/ByteString/Builder/Prim.v new file mode 100644 index 000000000..cf56a50cd --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim.v @@ -0,0 +1,333 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.Bits. +Require Data.ByteString.Builder.Internal. +Require Data.ByteString.Builder.Prim.Binary. +Require Data.ByteString.Builder.Prim.Internal. +Require Data.ByteString.Internal. +Require Data.ByteString.Lazy.Internal. +Require GHC.Base. +Require GHC.Char. +Require GHC.Num. +Require GHC.Prim. +Require GHC.Real. +Import Data.Bits.Notations. +Import Data.ByteString.Builder.Prim.Internal.Notations. +Import GHC.Base.Notations. +Import GHC.Num.Notations. +Import GHC.Prim.Notations. + +(* No type declarations to convert. *) + +(* Converted value declarations: *) + +Definition primBounded {a : Type} + : Data.ByteString.Builder.Prim.Internal.BoundedPrim a -> + a -> Data.ByteString.Builder.Internal.Builder := + fun w x => + let step := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | k, Data.ByteString.Builder.Internal.BufferRange op ope => + Data.ByteString.Builder.Prim.Internal.runB w x op GHC.Base.>>= + (fun op' => + let br' := Data.ByteString.Builder.Internal.BufferRange op' ope in k br') + end in + GHC.Base.mappend (Data.ByteString.Builder.Internal.ensureFree + (Data.ByteString.Builder.Prim.Internal.sizeBound w)) + (Data.ByteString.Builder.Internal.builder step). + +Definition primFixed {a : Type} + : Data.ByteString.Builder.Prim.Internal.FixedPrim a -> + a -> Data.ByteString.Builder.Internal.Builder := + primBounded GHC.Base.∘ Data.ByteString.Builder.Prim.Internal.toB. + +Definition primMapListBounded {a : Type} + : Data.ByteString.Builder.Prim.Internal.BoundedPrim a -> + list a -> Data.ByteString.Builder.Internal.Builder := + fun w xs0 => + let bound := Data.ByteString.Builder.Prim.Internal.sizeBound w in + let fix step arg_1__ arg_2__ arg_3__ + := match arg_1__, arg_2__, arg_3__ with + | xs1, k, Data.ByteString.Builder.Internal.BufferRange op0 ope0 => + let fix go arg_4__ arg_5__ + := match arg_4__, arg_5__ with + | nil, op => k (Data.ByteString.Builder.Internal.BufferRange op ope0) + | (cons x' xs' as xs), op => + if GHC.Ptr.plusPtr op bound GHC.Base.<= ope0 : bool + then Data.ByteString.Builder.Prim.Internal.runB w x' op GHC.Base.>>= go xs' else + GHC.Base.return_ (Data.ByteString.Builder.Internal.bufferFull bound op (step xs + k)) + end in + go xs1 op0 + end in + Data.ByteString.Builder.Internal.builder (step xs0). + +Definition primMapListFixed {a : Type} + : Data.ByteString.Builder.Prim.Internal.FixedPrim a -> + list a -> Data.ByteString.Builder.Internal.Builder := + primMapListBounded GHC.Base.∘ Data.ByteString.Builder.Prim.Internal.toB. + +Definition primUnfoldrBounded {b : Type} {a : Type} + : Data.ByteString.Builder.Prim.Internal.BoundedPrim b -> + (a -> option (b * a)%type) -> a -> Data.ByteString.Builder.Internal.Builder := + fun w f x0 => + let bound := Data.ByteString.Builder.Prim.Internal.sizeBound w in + let fix fillWith arg_1__ arg_2__ arg_3__ + := match arg_1__, arg_2__, arg_3__ with + | x, k, Data.ByteString.Builder.Internal.BufferRange op0 ope0 => + let fix go arg_4__ arg_5__ + := match arg_4__, arg_5__ with + | None, op => k (Data.ByteString.Builder.Internal.BufferRange op ope0) + | Some (pair y x'), op => + if GHC.Ptr.plusPtr op bound GHC.Base.<= ope0 : bool + then Data.ByteString.Builder.Prim.Internal.runB w y op GHC.Base.>>= + go (f x') else + GHC.Base.return_ (Data.ByteString.Builder.Internal.bufferFull bound op + (fun '(Data.ByteString.Builder.Internal.BufferRange + opNew opeNew) => + Data.ByteString.Builder.Prim.Internal.runB + w y opNew GHC.Base.>>= + (fun opNew' => + fillWith x' k + (Data.ByteString.Builder.Internal.BufferRange + opNew' opeNew)))) + end in + go (f x) op0 + end in + Data.ByteString.Builder.Internal.builder (fillWith x0). + +Definition primUnfoldrFixed {b : Type} {a : Type} + : Data.ByteString.Builder.Prim.Internal.FixedPrim b -> + (a -> option (b * a)%type) -> a -> Data.ByteString.Builder.Internal.Builder := + primUnfoldrBounded GHC.Base.∘ Data.ByteString.Builder.Prim.Internal.toB. + +Definition primMapByteStringBounded + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> + Data.ByteString.Builder.Internal.Builder := + fun w => + let bound := Data.ByteString.Builder.Prim.Internal.sizeBound w in + let step := + fun arg_1__ arg_2__ => + match arg_1__, arg_2__ with + | Data.ByteString.Internal.BS ifp isize, k => + let ipe := GHC.Ptr.plusPtr (GHC.ForeignPtr.unsafeForeignPtrToPtr ifp) isize in + let fix goBS arg_4__ arg_5__ + := match arg_4__, arg_5__ with + | ip0, (Data.ByteString.Builder.Internal.BufferRange op0 ope as br) => + let goPartial := + fun ipeTmp => + let fix go ip op + := if ip GHC.Base.< ipeTmp : bool + then Foreign.Storable.peek ip GHC.Base.>>= + (fun x => + Data.ByteString.Builder.Prim.Internal.runB w x op GHC.Base.>>= + (fun op' => go (GHC.Ptr.plusPtr ip #1) op')) else + goBS ip (Data.ByteString.Builder.Internal.BufferRange op ope) in + go ip0 op0 in + let inpRemaining := GHC.Ptr.minusPtr ipe ip0 in + let outRemaining := GHC.Real.div (GHC.Ptr.minusPtr ope op0) bound in + if ip0 GHC.Base.>= ipe : bool + then GHC.ForeignPtr.touchForeignPtr ifp GHC.Base.>> k br else + if GHC.Ptr.plusPtr op0 bound GHC.Base.<= ope : bool + then goPartial (GHC.Ptr.plusPtr ip0 (GHC.Base.min outRemaining + inpRemaining)) else + GHC.Base.return_ (Data.ByteString.Builder.Internal.bufferFull bound op0 (goBS + ip0)) + end in + goBS (GHC.ForeignPtr.unsafeForeignPtrToPtr ifp) + end in + fun bs => Data.ByteString.Builder.Internal.builder (step bs). + +Definition primMapByteStringFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word8 -> + Data.ByteString.Internal.ByteString -> + Data.ByteString.Builder.Internal.Builder := + primMapByteStringBounded GHC.Base.∘ Data.ByteString.Builder.Prim.Internal.toB. + +Definition primMapLazyByteStringBounded + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Builder.Internal.Builder := + fun w => + Data.ByteString.Lazy.Internal.foldrChunks (fun x b => + GHC.Base.mappend (primMapByteStringBounded w x) b) GHC.Base.mempty. + +Definition primMapLazyByteStringFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Builder.Internal.Builder := + primMapLazyByteStringBounded GHC.Base.∘ + Data.ByteString.Builder.Prim.Internal.toB. + +Definition cstring + : _GHC.Prim.Addr#_ -> Data.ByteString.Builder.Internal.Builder := + let step {r} + : _GHC.Prim.Addr#_ -> + Data.ByteString.Builder.Internal.BuildStep r -> + Data.ByteString.Builder.Internal.BuildStep r := + fix step arg_0__ arg_1__ arg_2__ + := match arg_0__, arg_1__, arg_2__ with + | addr + , k + , (Data.ByteString.Builder.Internal.BufferRange (GHC.Ptr.Ptr lop_op0zh__ as op0) + ope as br) => + let ch := _GHC.Prim.indexWord8OffAddr#_ addr 0 in + if _GHC.Word.W8#_ ch GHC.Base.== #0 : bool then k br else + if op0 GHC.Base.== ope : bool + then GHC.Base.return_ (Data.ByteString.Builder.Internal.bufferFull + Data.ByteString.Lazy.Internal.defaultChunkSize op0 (step addr k)) else + GHC.Types.IO (fun s => + let 's' := _GHC.Prim.writeWord8OffAddr#_ lop_op0zh__ 0 ch s in + pair s' tt) GHC.Base.>> + (let br' := + Data.ByteString.Builder.Internal.BufferRange (GHC.Ptr.plusPtr op0 #1) ope in + step (addr GHC.Prim.plusAddr# 1) k br') + end in + fun addr0 => Data.ByteString.Builder.Internal.builder (step addr0). + +Definition cstringUtf8 + : _GHC.Prim.Addr#_ -> Data.ByteString.Builder.Internal.Builder := + let step {r} + : _GHC.Prim.Addr#_ -> + Data.ByteString.Builder.Internal.BuildStep r -> + Data.ByteString.Builder.Internal.BuildStep r := + fix step arg_0__ arg_1__ arg_2__ + := match arg_0__, arg_1__, arg_2__ with + | addr + , k + , (Data.ByteString.Builder.Internal.BufferRange (GHC.Ptr.Ptr lop_op0zh__ as op0) + ope as br) => + let ch := _GHC.Prim.indexWord8OffAddr#_ addr 0 in + if _GHC.Word.W8#_ ch GHC.Base.== #0 : bool then k br else + if op0 GHC.Base.== ope : bool + then GHC.Base.return_ (Data.ByteString.Builder.Internal.bufferFull + Data.ByteString.Lazy.Internal.defaultChunkSize op0 (step addr k)) else + if andb (_GHC.Word.W8#_ ch GHC.Base.== #192) (_GHC.Word.W8#_ + (_GHC.Prim.indexWord8OffAddr#_ addr 1) GHC.Base.== + #128) : bool + then let 'GHC.Word.op_W8zh__ lop_nullBytezh__ := #0 in + GHC.Types.IO (fun s => + let 's' := _GHC.Prim.writeWord8OffAddr#_ lop_op0zh__ 0 lop_nullBytezh__ s in + pair s' tt) GHC.Base.>> + (let br' := + Data.ByteString.Builder.Internal.BufferRange (GHC.Ptr.plusPtr op0 #1) ope in + step (addr GHC.Prim.plusAddr# 2) k br') else + GHC.Types.IO (fun s => + let 's' := _GHC.Prim.writeWord8OffAddr#_ lop_op0zh__ 0 ch s in + pair s' tt) GHC.Base.>> + (let br' := + Data.ByteString.Builder.Internal.BufferRange (GHC.Ptr.plusPtr op0 #1) ope in + step (addr GHC.Prim.plusAddr# 1) k br') + end in + fun addr0 => Data.ByteString.Builder.Internal.builder (step addr0). + +Definition char8 + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Char.Char := + (GHC.Real.fromIntegral GHC.Base.∘ GHC.Base.ord) + Data.ByteString.Builder.Prim.Internal.>$< + Data.ByteString.Builder.Prim.Binary.word8. + +Definition encodeCharUtf8 {a} + : (GHC.Word.Word8 -> a) -> + (GHC.Word.Word8 -> GHC.Word.Word8 -> a) -> + (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8 -> a) -> + (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8 -> a) -> + GHC.Char.Char -> a := + fun f1 f2 f3 f4 c => + let 'x := GHC.Base.ord c in + if x GHC.Base.<= #127 : bool then f1 (GHC.Real.fromIntegral x) else + if x GHC.Base.<= #2047 : bool + then let x2 := + GHC.Real.fromIntegral ((x Data.Bits..&.(**) #63) GHC.Num.+ #128) in + let x1 := GHC.Real.fromIntegral ((Data.Bits.shiftR x #6) GHC.Num.+ #192) in + f2 x1 x2 else + if x GHC.Base.<= #65535 : bool + then let x3 := + GHC.Real.fromIntegral ((x Data.Bits..&.(**) #63) GHC.Num.+ #128) in + let x2 := + GHC.Real.fromIntegral (((Data.Bits.shiftR x #6) Data.Bits..&.(**) #63) GHC.Num.+ + #128) in + let x1 := GHC.Real.fromIntegral ((Data.Bits.shiftR x #12) GHC.Num.+ #224) in + f3 x1 x2 x3 else + let x4 := GHC.Real.fromIntegral ((x Data.Bits..&.(**) #63) GHC.Num.+ #128) in + let x3 := + GHC.Real.fromIntegral (((Data.Bits.shiftR x #6) Data.Bits..&.(**) #63) GHC.Num.+ + #128) in + let x2 := + GHC.Real.fromIntegral (((Data.Bits.shiftR x #12) Data.Bits..&.(**) #63) + GHC.Num.+ + #128) in + let x1 := GHC.Real.fromIntegral ((Data.Bits.shiftR x #18) GHC.Num.+ #240) in + f4 x1 x2 x3 x4. + +Definition charUtf8 + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Char.Char := + let pokeN := + fun n io op => io op GHC.Base.>> GHC.Base.return_ (GHC.Ptr.plusPtr op n) in + let f1 := + fun x1 => pokeN #1 (fun op => Foreign.Storable.pokeByteOff op #0 x1) in + let f2 := + fun x1 x2 => + pokeN #2 (fun op => + Foreign.Storable.pokeByteOff op #0 x1 GHC.Base.>> + Foreign.Storable.pokeByteOff op #1 x2) in + let f3 := + fun x1 x2 x3 => + pokeN #3 (fun op => + Foreign.Storable.pokeByteOff op #0 x1 GHC.Base.>> + (Foreign.Storable.pokeByteOff op #1 x2 GHC.Base.>> + Foreign.Storable.pokeByteOff op #2 x3)) in + let f4 := + fun x1 x2 x3 x4 => + pokeN #4 (fun op => + Foreign.Storable.pokeByteOff op #0 x1 GHC.Base.>> + (Foreign.Storable.pokeByteOff op #1 x2 GHC.Base.>> + (Foreign.Storable.pokeByteOff op #2 x3 GHC.Base.>> + Foreign.Storable.pokeByteOff op #3 x4))) in + Data.ByteString.Builder.Prim.Internal.boundedPrim #4 (encodeCharUtf8 f1 f2 f3 + f4). + +(* External variables: + None Some Type andb bool cons list nil op_zt__ option pair tt + Data.Bits.op_zizazi__ Data.Bits.shiftR + Data.ByteString.Builder.Internal.BufferRange + Data.ByteString.Builder.Internal.BuildStep + Data.ByteString.Builder.Internal.Builder + Data.ByteString.Builder.Internal.bufferFull + Data.ByteString.Builder.Internal.builder + Data.ByteString.Builder.Internal.ensureFree + Data.ByteString.Builder.Prim.Binary.word8 + Data.ByteString.Builder.Prim.Internal.BoundedPrim + Data.ByteString.Builder.Prim.Internal.FixedPrim + Data.ByteString.Builder.Prim.Internal.boundedPrim + Data.ByteString.Builder.Prim.Internal.op_zgzdzl__ + Data.ByteString.Builder.Prim.Internal.runB + Data.ByteString.Builder.Prim.Internal.sizeBound + Data.ByteString.Builder.Prim.Internal.toB Data.ByteString.Internal.BS + Data.ByteString.Internal.ByteString Data.ByteString.Lazy.Internal.ByteString + Data.ByteString.Lazy.Internal.defaultChunkSize + Data.ByteString.Lazy.Internal.foldrChunks Foreign.Storable.peek + Foreign.Storable.pokeByteOff GHC.Base.mappend GHC.Base.mempty GHC.Base.min + GHC.Base.op_z2218U__ GHC.Base.op_zeze__ GHC.Base.op_zgze__ GHC.Base.op_zgzg__ + GHC.Base.op_zgzgze__ GHC.Base.op_zl__ GHC.Base.op_zlze__ GHC.Base.ord + GHC.Base.return_ GHC.Char.Char GHC.ForeignPtr.touchForeignPtr + GHC.ForeignPtr.unsafeForeignPtrToPtr GHC.Num.fromInteger GHC.Num.op_zp__ + GHC.Prim.op_Addrzh__ GHC.Prim.op_indexWord8OffAddrzh__ GHC.Prim.op_plusAddrzh__ + GHC.Prim.op_writeWord8OffAddrzh__ GHC.Ptr.Ptr GHC.Ptr.minusPtr GHC.Ptr.plusPtr + GHC.Real.div GHC.Real.fromIntegral GHC.Types.IO GHC.Word.Word8 + GHC.Word.op_W8zh__ +*) diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/ASCII.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Prim/ASCII.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/ASCII.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/ASCII.v b/examples/bytestring/lib/Data/ByteString/Builder/Prim/ASCII.v new file mode 100644 index 000000000..65aa3dc9a --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/ASCII.v @@ -0,0 +1,213 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.Bits. +Require Data.ByteString.Builder.Prim.Binary. +Require Data.ByteString.Builder.Prim.Internal. +Require Data.ByteString.Builder.Prim.Internal.Base16. +Require Data.ByteString.Builder.Prim.Internal.Floating. +Require GHC.Base. +Require GHC.Char. +Require GHC.Err. +Require GHC.Num. +Require GHC.Real. +Import Data.Bits.Notations. +Import Data.ByteString.Builder.Prim.Internal.Notations. +Import GHC.Base.Notations. +Import GHC.Num.Notations. + +(* No type declarations to convert. *) + +(* Converted value declarations: *) + +Definition char7 + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Char.Char := + (fun c => GHC.Real.fromIntegral (GHC.Base.ord c Data.Bits..&.(**) #127)) + Data.ByteString.Builder.Prim.Internal.>$< + Data.ByteString.Builder.Prim.Binary.word8. + +Definition encodeIntDecimal {a} `{GHC.Real.Integral a} + : GHC.Num.Int -> Data.ByteString.Builder.Prim.Internal.BoundedPrim a := + fun bound => + Data.ByteString.Builder.Prim.Internal.boundedPrim bound (c_int_dec GHC.Base.∘ + GHC.Real.fromIntegral). + +Definition int8Dec + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Int.Int8 := + encodeIntDecimal #4. + +Definition int16Dec + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Int.Int16 := + encodeIntDecimal #6. + +Definition int32Dec + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Int.Int32 := + encodeIntDecimal #11. + +Definition int64Dec + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Int.Int64 := + Data.ByteString.Builder.Prim.Internal.boundedPrim #20 (c_long_long_int_dec + GHC.Base.∘ + GHC.Real.fromIntegral). + +Definition intDec + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Num.Int := + Data.ByteString.Builder.Prim.Internal.caseWordSize_32_64 (GHC.Real.fromIntegral + Data.ByteString.Builder.Prim.Internal.>$< + int32Dec) (GHC.Real.fromIntegral + Data.ByteString.Builder.Prim.Internal.>$< + int64Dec). + +Definition encodeWordDecimal {a} `{GHC.Real.Integral a} + : GHC.Num.Int -> Data.ByteString.Builder.Prim.Internal.BoundedPrim a := + fun bound => + Data.ByteString.Builder.Prim.Internal.boundedPrim bound (c_uint_dec GHC.Base.∘ + GHC.Real.fromIntegral). + +Definition word8Dec + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Word.Word8 := + encodeWordDecimal #3. + +Definition word16Dec + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Word.Word16 := + encodeWordDecimal #5. + +Definition word32Dec + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Word.Word32 := + encodeWordDecimal #10. + +Definition word64Dec + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Word.Word64 := + Data.ByteString.Builder.Prim.Internal.boundedPrim #20 (c_long_long_uint_dec + GHC.Base.∘ + GHC.Real.fromIntegral). + +Definition wordDec + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Num.Word := + Data.ByteString.Builder.Prim.Internal.caseWordSize_32_64 (GHC.Real.fromIntegral + Data.ByteString.Builder.Prim.Internal.>$< + word32Dec) (GHC.Real.fromIntegral + Data.ByteString.Builder.Prim.Internal.>$< + word64Dec). + +Definition encodeWordHex {a} `{Foreign.Storable.Storable a} `{GHC.Real.Integral + a} + : Data.ByteString.Builder.Prim.Internal.BoundedPrim a := + Data.ByteString.Builder.Prim.Internal.boundedPrim (#2 GHC.Num.* + Foreign.Storable.sizeOf (GHC.Err.undefined : a)) (c_uint_hex + GHC.Base.∘ + GHC.Real.fromIntegral). + +Definition word8Hex + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Word.Word8 := + encodeWordHex. + +Definition word16Hex + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Word.Word16 := + encodeWordHex. + +Definition word32Hex + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Word.Word32 := + encodeWordHex. + +Definition word64Hex + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Word.Word64 := + Data.ByteString.Builder.Prim.Internal.boundedPrim #16 (c_long_long_uint_hex + GHC.Base.∘ + GHC.Real.fromIntegral). + +Definition wordHex + : Data.ByteString.Builder.Prim.Internal.BoundedPrim GHC.Num.Word := + Data.ByteString.Builder.Prim.Internal.caseWordSize_32_64 (GHC.Real.fromIntegral + Data.ByteString.Builder.Prim.Internal.>$< + word32Hex) (GHC.Real.fromIntegral + Data.ByteString.Builder.Prim.Internal.>$< + word64Hex). + +Definition word8HexFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word8 := + Data.ByteString.Builder.Prim.Internal.fixedPrim #2 (fun x op => + Foreign.Storable.poke (GHC.Ptr.castPtr op) GHC.Base.=<< + Data.ByteString.Builder.Prim.Internal.Base16.encode8_as_16h + Data.ByteString.Builder.Prim.Internal.Base16.lowerTable x). + +Definition word16HexFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word16 := + (fun x => + pair (GHC.Real.fromIntegral (Data.Bits.shiftR x #8)) (GHC.Real.fromIntegral x)) + Data.ByteString.Builder.Prim.Internal.>$< + Data.ByteString.Builder.Prim.Internal.pairF word8HexFixed word8HexFixed. + +Definition word32HexFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word32 := + (fun x => + pair (GHC.Real.fromIntegral (Data.Bits.shiftR x #16)) (GHC.Real.fromIntegral x)) + Data.ByteString.Builder.Prim.Internal.>$< + Data.ByteString.Builder.Prim.Internal.pairF word16HexFixed word16HexFixed. + +Definition word64HexFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word64 := + (fun x => + pair (GHC.Real.fromIntegral (Data.Bits.shiftR x #32)) (GHC.Real.fromIntegral x)) + Data.ByteString.Builder.Prim.Internal.>$< + Data.ByteString.Builder.Prim.Internal.pairF word32HexFixed word32HexFixed. + +Definition int8HexFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int8 := + GHC.Real.fromIntegral Data.ByteString.Builder.Prim.Internal.>$< word8HexFixed. + +Definition int16HexFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int16 := + GHC.Real.fromIntegral Data.ByteString.Builder.Prim.Internal.>$< word16HexFixed. + +Definition int32HexFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int32 := + GHC.Real.fromIntegral Data.ByteString.Builder.Prim.Internal.>$< word32HexFixed. + +Definition int64HexFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int64 := + GHC.Real.fromIntegral Data.ByteString.Builder.Prim.Internal.>$< word64HexFixed. + +Definition floatHexFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Types.Float := + Data.ByteString.Builder.Prim.Internal.Floating.encodeFloatViaWord32F + word32HexFixed. + +Definition doubleHexFixed + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Types.Double := + Data.ByteString.Builder.Prim.Internal.Floating.encodeDoubleViaWord64F + word64HexFixed. + +(* External variables: + c_int_dec c_long_long_int_dec c_long_long_uint_dec c_long_long_uint_hex + c_uint_dec c_uint_hex pair Data.Bits.op_zizazi__ Data.Bits.shiftR + Data.ByteString.Builder.Prim.Binary.word8 + Data.ByteString.Builder.Prim.Internal.BoundedPrim + Data.ByteString.Builder.Prim.Internal.FixedPrim + Data.ByteString.Builder.Prim.Internal.boundedPrim + Data.ByteString.Builder.Prim.Internal.caseWordSize_32_64 + Data.ByteString.Builder.Prim.Internal.fixedPrim + Data.ByteString.Builder.Prim.Internal.op_zgzdzl__ + Data.ByteString.Builder.Prim.Internal.pairF + Data.ByteString.Builder.Prim.Internal.Base16.encode8_as_16h + Data.ByteString.Builder.Prim.Internal.Base16.lowerTable + Data.ByteString.Builder.Prim.Internal.Floating.encodeDoubleViaWord64F + Data.ByteString.Builder.Prim.Internal.Floating.encodeFloatViaWord32F + Foreign.Storable.Storable Foreign.Storable.poke Foreign.Storable.sizeOf + GHC.Base.op_z2218U__ GHC.Base.op_zezlzl__ GHC.Base.ord GHC.Char.Char + GHC.Err.undefined GHC.Int.Int16 GHC.Int.Int32 GHC.Int.Int64 GHC.Int.Int8 + GHC.Num.Int GHC.Num.Word GHC.Num.fromInteger GHC.Num.op_zt__ GHC.Ptr.castPtr + GHC.Real.Integral GHC.Real.fromIntegral GHC.Types.Double GHC.Types.Float + GHC.Word.Word16 GHC.Word.Word32 GHC.Word.Word64 GHC.Word.Word8 +*) diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Binary.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Binary.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Binary.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Binary.v b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Binary.v new file mode 100644 index 000000000..9bcf4306f --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Binary.v @@ -0,0 +1,194 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.Bits. +Require Data.ByteString.Builder.Prim.Internal. +Require Data.ByteString.Builder.Prim.Internal.Floating. +Require GHC.Base. +Require GHC.Num. +Require GHC.Real. +Import Data.ByteString.Builder.Prim.Internal.Notations. +Import GHC.Base.Notations. +Import GHC.Num.Notations. + +(* No type declarations to convert. *) + +(* Converted value declarations: *) + +Definition word8 + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word8 := + Data.ByteString.Builder.Prim.Internal.storableToF. + +Definition word16BE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word16 := + Data.ByteString.Builder.Prim.Internal.fixedPrim #2 (fun w p => + Foreign.Storable.poke p (GHC.Real.fromIntegral (Data.Bits.shiftR + w + #8) : GHC.Word.Word8) + GHC.Base.>> + Foreign.Storable.poke (GHC.Ptr.plusPtr p #1) + (GHC.Real.fromIntegral w : GHC.Word.Word8)). + +Definition word16Host + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word16 := + Data.ByteString.Builder.Prim.Internal.storableToF. + +Definition word16LE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word16 := + word16Host. + +Definition word32BE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word32 := + Data.ByteString.Builder.Prim.Internal.fixedPrim #4 (fun w p => + Foreign.Storable.poke p (GHC.Real.fromIntegral (Data.Bits.shiftR + w + #24) : GHC.Word.Word8) + GHC.Base.>> + (Foreign.Storable.poke (GHC.Ptr.plusPtr p #1) + (GHC.Real.fromIntegral (Data.Bits.shiftR w + #16) : GHC.Word.Word8) GHC.Base.>> + (Foreign.Storable.poke (GHC.Ptr.plusPtr p #2) + (GHC.Real.fromIntegral (Data.Bits.shiftR w + #8) : GHC.Word.Word8) GHC.Base.>> + Foreign.Storable.poke (GHC.Ptr.plusPtr p #3) + (GHC.Real.fromIntegral w : GHC.Word.Word8)))). + +Definition word32Host + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word32 := + Data.ByteString.Builder.Prim.Internal.storableToF. + +Definition word32LE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word32 := + word32Host. + +Definition word64BE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word64 := + Data.ByteString.Builder.Prim.Internal.fixedPrim #8 (fun w p => + Foreign.Storable.poke p (GHC.Real.fromIntegral (Data.Bits.shiftR + w + #56) : GHC.Word.Word8) + GHC.Base.>> + (Foreign.Storable.poke (GHC.Ptr.plusPtr p #1) + (GHC.Real.fromIntegral (Data.Bits.shiftR w + #48) : GHC.Word.Word8) GHC.Base.>> + (Foreign.Storable.poke (GHC.Ptr.plusPtr p #2) + (GHC.Real.fromIntegral (Data.Bits.shiftR w + #40) : GHC.Word.Word8) GHC.Base.>> + (Foreign.Storable.poke (GHC.Ptr.plusPtr p #3) + (GHC.Real.fromIntegral (Data.Bits.shiftR w + #32) : GHC.Word.Word8) GHC.Base.>> + (Foreign.Storable.poke (GHC.Ptr.plusPtr p #4) + (GHC.Real.fromIntegral (Data.Bits.shiftR w + #24) : GHC.Word.Word8) GHC.Base.>> + (Foreign.Storable.poke (GHC.Ptr.plusPtr p #5) + (GHC.Real.fromIntegral (Data.Bits.shiftR w + #16) : GHC.Word.Word8) GHC.Base.>> + (Foreign.Storable.poke (GHC.Ptr.plusPtr p #6) + (GHC.Real.fromIntegral (Data.Bits.shiftR w + #8) : GHC.Word.Word8) GHC.Base.>> + Foreign.Storable.poke (GHC.Ptr.plusPtr p #7) + (GHC.Real.fromIntegral w : GHC.Word.Word8)))))))). + +Definition word64Host + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word64 := + Data.ByteString.Builder.Prim.Internal.storableToF. + +Definition word64LE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word64 := + word64Host. + +Definition wordHost + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Num.Word := + Data.ByteString.Builder.Prim.Internal.storableToF. + +Definition int8 + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int8 := + GHC.Real.fromIntegral Data.ByteString.Builder.Prim.Internal.>$< word8. + +Definition int16BE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int16 := + GHC.Real.fromIntegral Data.ByteString.Builder.Prim.Internal.>$< word16BE. + +Definition int16LE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int16 := + GHC.Real.fromIntegral Data.ByteString.Builder.Prim.Internal.>$< word16LE. + +Definition int32BE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int32 := + GHC.Real.fromIntegral Data.ByteString.Builder.Prim.Internal.>$< word32BE. + +Definition int32LE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int32 := + GHC.Real.fromIntegral Data.ByteString.Builder.Prim.Internal.>$< word32LE. + +Definition int64BE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int64 := + GHC.Real.fromIntegral Data.ByteString.Builder.Prim.Internal.>$< word64BE. + +Definition int64LE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int64 := + GHC.Real.fromIntegral Data.ByteString.Builder.Prim.Internal.>$< word64LE. + +Definition intHost + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Num.Int := + Data.ByteString.Builder.Prim.Internal.storableToF. + +Definition int16Host + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int16 := + Data.ByteString.Builder.Prim.Internal.storableToF. + +Definition int32Host + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int32 := + Data.ByteString.Builder.Prim.Internal.storableToF. + +Definition int64Host + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Int.Int64 := + Data.ByteString.Builder.Prim.Internal.storableToF. + +Definition floatBE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Types.Float := + Data.ByteString.Builder.Prim.Internal.Floating.encodeFloatViaWord32F word32BE. + +Definition floatLE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Types.Float := + Data.ByteString.Builder.Prim.Internal.Floating.encodeFloatViaWord32F word32LE. + +Definition doubleBE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Types.Double := + Data.ByteString.Builder.Prim.Internal.Floating.encodeDoubleViaWord64F word64BE. + +Definition doubleLE + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Types.Double := + Data.ByteString.Builder.Prim.Internal.Floating.encodeDoubleViaWord64F word64LE. + +Definition floatHost + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Types.Float := + Data.ByteString.Builder.Prim.Internal.storableToF. + +Definition doubleHost + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Types.Double := + Data.ByteString.Builder.Prim.Internal.storableToF. + +(* External variables: + Data.Bits.shiftR Data.ByteString.Builder.Prim.Internal.FixedPrim + Data.ByteString.Builder.Prim.Internal.fixedPrim + Data.ByteString.Builder.Prim.Internal.op_zgzdzl__ + Data.ByteString.Builder.Prim.Internal.storableToF + Data.ByteString.Builder.Prim.Internal.Floating.encodeDoubleViaWord64F + Data.ByteString.Builder.Prim.Internal.Floating.encodeFloatViaWord32F + Foreign.Storable.poke GHC.Base.op_zgzg__ GHC.Int.Int16 GHC.Int.Int32 + GHC.Int.Int64 GHC.Int.Int8 GHC.Num.Int GHC.Num.Word GHC.Num.fromInteger + GHC.Ptr.plusPtr GHC.Real.fromIntegral GHC.Types.Double GHC.Types.Float + GHC.Word.Word16 GHC.Word.Word32 GHC.Word.Word64 GHC.Word.Word8 +*) diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.h2ci new file mode 100644 index 000000000..df56fdc8e --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.h2ci @@ -0,0 +1,38 @@ +superclassCount: + Data.ByteString.Builder.Prim.Internal.Monoidal: '0' + Data.ByteString.Builder.Prim.Internal.Contravariant: '0' +classTypes: + Data.ByteString.Builder.Prim.Internal.Monoidal: fromList [] + Data.ByteString.Builder.Prim.Internal.Contravariant: fromList [] +constructors: + Data.ByteString.Builder.Prim.Internal.BoundedPrim: ! '[Qualified "Data.ByteString.Builder.Prim.Internal" + "BP"]' + Data.ByteString.Builder.Prim.Internal.FixedPrim: ! '[Qualified "Data.ByteString.Builder.Prim.Internal" + "FP"]' +constructorFields: + Data.ByteString.Builder.Prim.Internal.BP: NonRecordFields 2 + Data.ByteString.Builder.Prim.Internal.FP: NonRecordFields 2 +classDefns: + Data.ByteString.Builder.Prim.Internal.Monoidal: ClassDefinition (Qualified "Data.ByteString.Builder.Prim.Internal" + "Monoidal") [Typed Ungeneralizable Explicit (Ident (Bare "f") :| []) (Arrow (Qualid + (Bare "Type")) (Qualid (Bare "Type")))] Nothing [(Qualified "Data.ByteString.Builder.Prim.Internal" + "pair_",Forall (Typed Ungeneralizable Implicit (Ident (Bare "a") :| []) (Qualid + (Bare "Type")) :| []) (Forall (Typed Ungeneralizable Implicit (Ident (Bare "b") + :| []) (Qualid (Bare "Type")) :| []) (Arrow (App (Qualid (Bare "f")) (PosArg (Qualid + (Bare "a")) :| [])) (Arrow (App (Qualid (Bare "f")) (PosArg (Qualid (Bare "b")) + :| [])) (App (Qualid (Bare "f")) (PosArg (InScope (App (Qualid (Bare "op_zt__")) + (PosArg (Qualid (Bare "a")) :| [PosArg (Qualid (Bare "b"))])) "type") :| []))))))] + Data.ByteString.Builder.Prim.Internal.Contravariant: ClassDefinition (Qualified + "Data.ByteString.Builder.Prim.Internal" "Contravariant") [Typed Ungeneralizable + Explicit (Ident (Bare "f") :| []) (Arrow (Qualid (Bare "Type")) (Qualid (Bare + "Type")))] Nothing [(Qualified "Data.ByteString.Builder.Prim.Internal" "contramap",Forall + (Typed Ungeneralizable Implicit (Ident (Bare "b") :| []) (Qualid (Bare "Type")) + :| []) (Forall (Typed Ungeneralizable Implicit (Ident (Bare "a") :| []) (Qualid + (Bare "Type")) :| []) (Arrow (Arrow (Qualid (Bare "b")) (Qualid (Bare "a"))) (Arrow + (App (Qualid (Bare "f")) (PosArg (Qualid (Bare "a")) :| [])) (App (Qualid (Bare + "f")) (PosArg (Qualid (Bare "b")) :| []))))))] +constructorTypes: + Data.ByteString.Builder.Prim.Internal.BP: Qualified "Data.ByteString.Builder.Prim.Internal" + "BoundedPrim" + Data.ByteString.Builder.Prim.Internal.FP: Qualified "Data.ByteString.Builder.Prim.Internal" + "FixedPrim" diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.v b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.v new file mode 100644 index 000000000..bf7efdc5d --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.v @@ -0,0 +1,251 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.Either. +Require GHC.Base. +Require GHC.Err. +Require GHC.Num. +Import GHC.Base.Notations. +Import GHC.Num.Notations. + +(* Converted type declarations: *) + +Definition Size := + GHC.Num.Int%type. + +Record Monoidal__Dict (f : Type -> Type) := Monoidal__Dict_Build { + pair___ : forall {a : Type}, forall {b : Type}, f a -> f b -> f (a * b)%type }. + +Definition Monoidal (f : Type -> Type) := + forall r__, (Monoidal__Dict f -> r__) -> r__. +Existing Class Monoidal. + +Record Contravariant__Dict (f : Type -> Type) := Contravariant__Dict_Build { + contramap__ : forall {b : Type}, forall {a : Type}, (b -> a) -> f a -> f b }. + +Definition pair_ `{g__0__ : Monoidal f} + : forall {a : Type}, forall {b : Type}, f a -> f b -> f (a * b)%type := + g__0__ _ (pair___ f). + +Inductive FixedPrim a : Type := + | FP + : GHC.Num.Int -> + (a -> GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO unit) -> FixedPrim a. + +Definition Contravariant (f : Type -> Type) := + forall r__, (Contravariant__Dict f -> r__) -> r__. +Existing Class Contravariant. + +Definition contramap `{g__0__ : Contravariant f} + : forall {b : Type}, forall {a : Type}, (b -> a) -> f a -> f b := + g__0__ _ (contramap__ f). + +Inductive BoundedPrim a : Type := + | BP + : GHC.Num.Int -> + (a -> + GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO (GHC.Ptr.Ptr GHC.Word.Word8)) -> + BoundedPrim a. + +Arguments FP {_} _ _. + +Arguments BP {_} _ _. + +(* Converted value declarations: *) + +Definition contramapF {b : Type} {a : Type} + : (b -> a) -> FixedPrim a -> FixedPrim b := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | f, FP l io => FP l (io GHC.Base.∘ f) + end. + +Local Definition Contravariant__FixedPrim_contramap + : forall {b : Type}, + forall {a : Type}, (b -> a) -> FixedPrim a -> FixedPrim b := + fun {b : Type} {a : Type} => contramapF. + +Program Instance Contravariant__FixedPrim : Contravariant FixedPrim := + fun _ k__ => + k__ {| contramap__ := fun {b : Type} {a : Type} => + Contravariant__FixedPrim_contramap |}. + +Definition contramapB {b : Type} {a : Type} + : (b -> a) -> BoundedPrim a -> BoundedPrim b := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | f, BP b io => BP b (io GHC.Base.∘ f) + end. + +Local Definition Contravariant__BoundedPrim_contramap + : forall {b : Type}, + forall {a : Type}, (b -> a) -> BoundedPrim a -> BoundedPrim b := + fun {b : Type} {a : Type} => contramapB. + +Program Instance Contravariant__BoundedPrim : Contravariant BoundedPrim := + fun _ k__ => + k__ {| contramap__ := fun {b : Type} {a : Type} => + Contravariant__BoundedPrim_contramap |}. + +Definition pairF {a : Type} {b : Type} + : FixedPrim a -> FixedPrim b -> FixedPrim (a * b)%type := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | FP l1 io1, FP l2 io2 => + FP (l1 GHC.Num.+ l2) (fun arg_2__ arg_3__ => + match arg_2__, arg_3__ with + | pair x1 x2, op => io1 x1 op GHC.Base.>> io2 x2 (GHC.Ptr.plusPtr op l1) + end) + end. + +Local Definition Monoidal__FixedPrim_pair_ + : forall {a : Type}, + forall {b : Type}, FixedPrim a -> FixedPrim b -> FixedPrim (a * b)%type := + fun {a : Type} {b : Type} => pairF. + +Program Instance Monoidal__FixedPrim : Monoidal FixedPrim := + fun _ k__ => + k__ {| pair___ := fun {a : Type} {b : Type} => Monoidal__FixedPrim_pair_ |}. + +Definition pairB {a : Type} {b : Type} + : BoundedPrim a -> BoundedPrim b -> BoundedPrim (a * b)%type := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | BP b1 io1, BP b2 io2 => + BP (b1 GHC.Num.+ b2) (fun arg_2__ arg_3__ => + match arg_2__, arg_3__ with + | pair x1 x2, op => io1 x1 op GHC.Base.>>= io2 x2 + end) + end. + +Local Definition Monoidal__BoundedPrim_pair_ + : forall {a : Type}, + forall {b : Type}, BoundedPrim a -> BoundedPrim b -> BoundedPrim (a * b)%type := + fun {a : Type} {b : Type} => pairB. + +Program Instance Monoidal__BoundedPrim : Monoidal BoundedPrim := + fun _ k__ => + k__ {| pair___ := fun {a : Type} {b : Type} => Monoidal__BoundedPrim_pair_ |}. + +Definition op_zgzdzl__ {f : Type -> Type} {b : Type} {a : Type} `{Contravariant + f} + : (b -> a) -> f a -> f b := + contramap. + +Notation "'_>$<_'" := (op_zgzdzl__). + +Infix ">$<" := (_>$<_) (at level 99). + +Definition op_zgztzl__ {f : Type -> Type} {a : Type} {b : Type} `{Monoidal f} + : f a -> f b -> f (a * b)%type := + pair_. + +Notation "'_>*<_'" := (op_zgztzl__). + +Infix ">*<" := (_>*<_) (at level 99). + +Definition fixedPrim {a : Type} + : GHC.Num.Int -> + (a -> GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO unit) -> FixedPrim a := + FP. + +Definition size {a : Type} : FixedPrim a -> GHC.Num.Int := + fun '(FP l _) => l. + +Definition runF {a : Type} + : FixedPrim a -> a -> GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO unit := + fun '(FP _ io) => io. + +Definition emptyF {a : Type} : FixedPrim a := + FP #0 (fun arg_0__ arg_1__ => GHC.Base.return_ tt). + +Definition toB {a : Type} : FixedPrim a -> BoundedPrim a := + fun '(FP l io) => + BP l (fun x op => + io x op GHC.Base.>> (GHC.Base.return_ (GHC.Ptr.plusPtr op l))). + +Definition liftFixedToBounded {a : Type} : FixedPrim a -> BoundedPrim a := + toB. + +Definition storableToF {a : Type} `{Foreign.Storable.Storable a} + : FixedPrim a := + FP (Foreign.Storable.sizeOf (GHC.Err.undefined : a)) (fun x op => + Foreign.Storable.poke (GHC.Ptr.castPtr op) x). + +Definition sizeBound {a : Type} : BoundedPrim a -> GHC.Num.Int := + fun '(BP b _) => b. + +Definition boundedPrim {a : Type} + : GHC.Num.Int -> + (a -> + GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO (GHC.Ptr.Ptr GHC.Word.Word8)) -> + BoundedPrim a := + BP. + +Definition boudedPrim {a : Type} + : GHC.Num.Int -> + (a -> + GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO (GHC.Ptr.Ptr GHC.Word.Word8)) -> + BoundedPrim a := + BP. + +Definition runB {a : Type} + : BoundedPrim a -> + a -> GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO (GHC.Ptr.Ptr GHC.Word.Word8) := + fun '(BP _ io) => io. + +Definition emptyB {a : Type} : BoundedPrim a := + BP #0 (fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, op => GHC.Base.return_ op + end). + +Definition eitherB {a : Type} {b : Type} + : BoundedPrim a -> BoundedPrim b -> BoundedPrim (Data.Either.Either a b) := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | BP b1 io1, BP b2 io2 => + BP (GHC.Base.max b1 b2) (fun x op => + match x with + | Data.Either.Left x1 => io1 x1 op + | Data.Either.Right x2 => io2 x2 op + end) + end. + +Definition condB {a : Type} + : (a -> bool) -> BoundedPrim a -> BoundedPrim a -> BoundedPrim a := + fun p be1 be2 => + contramapB (fun x => + if p x : bool + then Data.Either.Left x + else Data.Either.Right x) (eitherB be1 be2). + +Definition caseWordSize_32_64 {a : Type} : a -> a -> a := + GHC.Base.const GHC.Base.id. + +Module Notations. +Notation "'_Data.ByteString.Builder.Prim.Internal.>$<_'" := (op_zgzdzl__). +Infix "Data.ByteString.Builder.Prim.Internal.>$<" := (_>$<_) (at level 99). +Notation "'_Data.ByteString.Builder.Prim.Internal.>*<_'" := (op_zgztzl__). +Infix "Data.ByteString.Builder.Prim.Internal.>*<" := (_>*<_) (at level 99). +End Notations. + +(* External variables: + Type bool op_zt__ pair tt unit Data.Either.Either Data.Either.Left + Data.Either.Right Foreign.Storable.Storable Foreign.Storable.poke + Foreign.Storable.sizeOf GHC.Base.const GHC.Base.id GHC.Base.max + GHC.Base.op_z2218U__ GHC.Base.op_zgzg__ GHC.Base.op_zgzgze__ GHC.Base.return_ + GHC.Err.undefined GHC.Num.Int GHC.Num.fromInteger GHC.Num.op_zp__ GHC.Ptr.Ptr + GHC.Ptr.castPtr GHC.Ptr.plusPtr GHC.Types.IO GHC.Word.Word8 +*) diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.h2ci new file mode 100644 index 000000000..41d6ada00 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.h2ci @@ -0,0 +1,8 @@ +constructors: + Data.ByteString.Builder.Prim.Internal.Base16.EncodingTable: ! '[Qualified "Data.ByteString.Builder.Prim.Internal.Base16" + "EncodingTable"]' +constructorFields: + Data.ByteString.Builder.Prim.Internal.Base16.EncodingTable: NonRecordFields 1 +constructorTypes: + Data.ByteString.Builder.Prim.Internal.Base16.EncodingTable: Qualified "Data.ByteString.Builder.Prim.Internal.Base16" + "EncodingTable" diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.v b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.v new file mode 100644 index 000000000..48bc0b5e6 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.v @@ -0,0 +1,32 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require GHC.Prim. +Import GHC.Prim.Notations. + +(* Converted type declarations: *) + +Inductive EncodingTable : Type := + | EncodingTable : _GHC.Prim.Addr#_ -> EncodingTable. + +(* Converted value declarations: *) + +Axiom lowerTable : EncodingTable. + +Axiom encode8_as_16h : EncodingTable -> + GHC.Word.Word8 -> GHC.Types.IO GHC.Word.Word16. + +(* External variables: + GHC.Prim.op_Addrzh__ GHC.Types.IO GHC.Word.Word16 GHC.Word.Word8 +*) diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Floating.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Floating.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Floating.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Floating.v b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Floating.v new file mode 100644 index 000000000..9899d4059 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Floating.v @@ -0,0 +1,62 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.ByteString.Builder.Prim.Internal. +Require GHC.Base. +Require GHC.Err. +Import GHC.Base.Notations. + +(* No type declarations to convert. *) + +(* Converted value declarations: *) + +Definition encodeFloatViaWord32F + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word32 -> + Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Types.Float := + fun w32fe => + if Data.ByteString.Builder.Prim.Internal.size w32fe GHC.Base.< + Foreign.Storable.sizeOf (GHC.Err.undefined : GHC.Types.Float) : bool + then GHC.Err.error (GHC.Base.hs_string__ + "encodeFloatViaWord32F: encoding not wide enough") else + Data.ByteString.Builder.Prim.Internal.fixedPrim + (Data.ByteString.Builder.Prim.Internal.size w32fe) (fun x op => + Foreign.Storable.poke (GHC.Ptr.castPtr op) x GHC.Base.>> + (Foreign.Storable.peek (GHC.Ptr.castPtr op) GHC.Base.>>= + (fun x' => + Data.ByteString.Builder.Prim.Internal.runF w32fe x' op))). + +Definition encodeDoubleViaWord64F + : Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Word.Word64 -> + Data.ByteString.Builder.Prim.Internal.FixedPrim GHC.Types.Double := + fun w64fe => + if Data.ByteString.Builder.Prim.Internal.size w64fe GHC.Base.< + Foreign.Storable.sizeOf (GHC.Err.undefined : GHC.Types.Float) : bool + then GHC.Err.error (GHC.Base.hs_string__ + "encodeDoubleViaWord64F: encoding not wide enough") else + Data.ByteString.Builder.Prim.Internal.fixedPrim + (Data.ByteString.Builder.Prim.Internal.size w64fe) (fun x op => + Foreign.Storable.poke (GHC.Ptr.castPtr op) x GHC.Base.>> + (Foreign.Storable.peek (GHC.Ptr.castPtr op) GHC.Base.>>= + (fun x' => + Data.ByteString.Builder.Prim.Internal.runF w64fe x' op))). + +(* External variables: + bool Data.ByteString.Builder.Prim.Internal.FixedPrim + Data.ByteString.Builder.Prim.Internal.fixedPrim + Data.ByteString.Builder.Prim.Internal.runF + Data.ByteString.Builder.Prim.Internal.size Foreign.Storable.peek + Foreign.Storable.poke Foreign.Storable.sizeOf GHC.Base.op_zgzg__ + GHC.Base.op_zgzgze__ GHC.Base.op_zl__ GHC.Err.error GHC.Err.undefined + GHC.Ptr.castPtr GHC.Types.Double GHC.Types.Float GHC.Word.Word32 GHC.Word.Word64 +*) diff --git a/examples/bytestring/lib/Data/ByteString/Char8.h2ci b/examples/bytestring/lib/Data/ByteString/Char8.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Char8.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString/Char8.v b/examples/bytestring/lib/Data/ByteString/Char8.v new file mode 100644 index 000000000..397e5f600 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Char8.v @@ -0,0 +1,748 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.ByteString. +Require Data.ByteString.Internal. +Require Data.ByteString.Unsafe. +Require Data.Functor. +Require Data.OldList. +Require Data.Tuple. +Require GHC.Base. +Require GHC.Char. +Require GHC.List. +Require GHC.Num. +Require GHC.Real. +Require GHC.Unicode. +Import Data.Functor.Notations. +Import GHC.Base.Notations. +Import GHC.Num.Notations. +Import GHC.Real.Notations. + +(* No type declarations to convert. *) + +(* Converted value declarations: *) + +Definition singleton : GHC.Char.Char -> Data.ByteString.Internal.ByteString := + Data.ByteString.singleton GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition pack : GHC.Base.String -> Data.ByteString.Internal.ByteString := + Data.ByteString.Internal.packChars. + +Definition unpack : Data.ByteString.Internal.ByteString -> list GHC.Char.Char := + Data.ByteString.Internal.unpackChars. + +Definition cons_ + : GHC.Char.Char -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + Data.ByteString.cons_ GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition snoc + : Data.ByteString.Internal.ByteString -> + GHC.Char.Char -> Data.ByteString.Internal.ByteString := + fun p => Data.ByteString.snoc p GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition uncons + : Data.ByteString.Internal.ByteString -> + option (GHC.Char.Char * Data.ByteString.Internal.ByteString)%type := + fun bs => + match Data.ByteString.uncons bs with + | None => None + | Some (pair w bs') => Some (pair (Data.ByteString.Internal.w2c w) bs') + end. + +Definition unsnoc + : Data.ByteString.Internal.ByteString -> + option (Data.ByteString.Internal.ByteString * GHC.Char.Char)%type := + fun bs => + match Data.ByteString.unsnoc bs with + | None => None + | Some (pair bs' w) => Some (pair bs' (Data.ByteString.Internal.w2c w)) + end. + +Definition head : Data.ByteString.Internal.ByteString -> GHC.Char.Char := + Data.ByteString.Internal.w2c GHC.Base.∘ Data.ByteString.head. + +Definition last : Data.ByteString.Internal.ByteString -> GHC.Char.Char := + Data.ByteString.Internal.w2c GHC.Base.∘ Data.ByteString.last. + +Definition map + : (GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f => + Data.ByteString.map (Data.ByteString.Internal.c2w GHC.Base.∘ + (f GHC.Base.∘ Data.ByteString.Internal.w2c)). + +Definition intersperse + : GHC.Char.Char -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + Data.ByteString.intersperse GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition foldl {a : Type} + : (a -> GHC.Char.Char -> a) -> a -> Data.ByteString.Internal.ByteString -> a := + fun f => + Data.ByteString.foldl (fun a c => f a (Data.ByteString.Internal.w2c c)). + +Definition foldl' {a : Type} + : (a -> GHC.Char.Char -> a) -> a -> Data.ByteString.Internal.ByteString -> a := + fun f => + Data.ByteString.foldl' (fun a c => f a (Data.ByteString.Internal.w2c c)). + +Definition foldr {a : Type} + : (GHC.Char.Char -> a -> a) -> a -> Data.ByteString.Internal.ByteString -> a := + fun f => Data.ByteString.foldr (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition foldr' {a : Type} + : (GHC.Char.Char -> a -> a) -> a -> Data.ByteString.Internal.ByteString -> a := + fun f => Data.ByteString.foldr' (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition foldl1 + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Internal.ByteString -> GHC.Char.Char := + fun f ps => + Data.ByteString.Internal.w2c (Data.ByteString.foldl1 (fun x y => + Data.ByteString.Internal.c2w (f + (Data.ByteString.Internal.w2c + x) + (Data.ByteString.Internal.w2c + y))) ps). + +Definition foldl1' + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Internal.ByteString -> GHC.Char.Char := + fun f ps => + Data.ByteString.Internal.w2c (Data.ByteString.foldl1' (fun x y => + Data.ByteString.Internal.c2w (f + (Data.ByteString.Internal.w2c + x) + (Data.ByteString.Internal.w2c + y))) ps). + +Definition foldr1 + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Internal.ByteString -> GHC.Char.Char := + fun f ps => + Data.ByteString.Internal.w2c (Data.ByteString.foldr1 (fun x y => + Data.ByteString.Internal.c2w (f + (Data.ByteString.Internal.w2c + x) + (Data.ByteString.Internal.w2c + y))) ps). + +Definition foldr1' + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Internal.ByteString -> GHC.Char.Char := + fun f ps => + Data.ByteString.Internal.w2c (Data.ByteString.foldr1' (fun x y => + Data.ByteString.Internal.c2w (f + (Data.ByteString.Internal.w2c + x) + (Data.ByteString.Internal.w2c + y))) ps). + +Definition concatMap + : (GHC.Char.Char -> Data.ByteString.Internal.ByteString) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f => Data.ByteString.concatMap (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition any + : (GHC.Char.Char -> bool) -> Data.ByteString.Internal.ByteString -> bool := + fun f => Data.ByteString.any (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition all + : (GHC.Char.Char -> bool) -> Data.ByteString.Internal.ByteString -> bool := + fun f => Data.ByteString.all (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition maximum : Data.ByteString.Internal.ByteString -> GHC.Char.Char := + Data.ByteString.Internal.w2c GHC.Base.∘ Data.ByteString.maximum. + +Definition minimum : Data.ByteString.Internal.ByteString -> GHC.Char.Char := + Data.ByteString.Internal.w2c GHC.Base.∘ Data.ByteString.minimum. + +Definition mapAccumL {acc : Type} + : (acc -> GHC.Char.Char -> (acc * GHC.Char.Char)%type) -> + acc -> + Data.ByteString.Internal.ByteString -> + (acc * Data.ByteString.Internal.ByteString)%type := + fun f => + Data.ByteString.mapAccumL (fun acc w => + let 'pair acc' c := f acc (Data.ByteString.Internal.w2c w) in + pair acc' (Data.ByteString.Internal.c2w c)). + +Definition mapAccumR {acc : Type} + : (acc -> GHC.Char.Char -> (acc * GHC.Char.Char)%type) -> + acc -> + Data.ByteString.Internal.ByteString -> + (acc * Data.ByteString.Internal.ByteString)%type := + fun f => + Data.ByteString.mapAccumR (fun acc w => + let 'pair acc' c := f acc (Data.ByteString.Internal.w2c w) in + pair acc' (Data.ByteString.Internal.c2w c)). + +Definition scanl + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + GHC.Char.Char -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f z => + Data.ByteString.scanl (fun a b => + Data.ByteString.Internal.c2w (f (Data.ByteString.Internal.w2c a) + (Data.ByteString.Internal.w2c b))) + (Data.ByteString.Internal.c2w z). + +Definition scanl1 + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f => + Data.ByteString.scanl1 (fun a b => + Data.ByteString.Internal.c2w (f (Data.ByteString.Internal.w2c a) + (Data.ByteString.Internal.w2c b))). + +Definition scanr + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + GHC.Char.Char -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f z => + Data.ByteString.scanr (fun a b => + Data.ByteString.Internal.c2w (f (Data.ByteString.Internal.w2c a) + (Data.ByteString.Internal.w2c b))) + (Data.ByteString.Internal.c2w z). + +Definition scanr1 + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f => + Data.ByteString.scanr1 (fun a b => + Data.ByteString.Internal.c2w (f (Data.ByteString.Internal.w2c a) + (Data.ByteString.Internal.w2c b))). + +Definition replicate + : GHC.Num.Int -> GHC.Char.Char -> Data.ByteString.Internal.ByteString := + fun n => Data.ByteString.replicate n GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition unfoldr {a : Type} + : (a -> option (GHC.Char.Char * a)%type) -> + a -> Data.ByteString.Internal.ByteString := + fun f => + let k := fun '(pair i j) => pair (Data.ByteString.Internal.c2w i) j in + Data.ByteString.unfoldr (GHC.Base.fmap k GHC.Base.∘ f). + +Definition unfoldrN {a : Type} + : GHC.Num.Int -> + (a -> option (GHC.Char.Char * a)%type) -> + a -> (Data.ByteString.Internal.ByteString * option a)%type := + fun n f => + let k := fun '(pair i j) => pair (Data.ByteString.Internal.c2w i) j in + Data.ByteString.unfoldrN n ((fun arg_3__ => GHC.Base.fmap k arg_3__) GHC.Base.∘ + f). + +Definition takeWhile + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f => Data.ByteString.takeWhile (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition takeWhileEnd + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f => + Data.ByteString.takeWhileEnd (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition dropWhile + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f => Data.ByteString.dropWhile (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition dropWhileEnd + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f => + Data.ByteString.dropWhileEnd (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition break + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun f => Data.ByteString.break (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition elemIndex + : GHC.Char.Char -> Data.ByteString.Internal.ByteString -> option GHC.Num.Int := + Data.ByteString.elemIndex GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition breakChar + : GHC.Char.Char -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun c p => + match elemIndex c p with + | None => pair p Data.ByteString.empty + | Some n => + pair (Data.ByteString.Unsafe.unsafeTake n p) (Data.ByteString.Unsafe.unsafeDrop + n p) + end. + +Definition span + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun f => Data.ByteString.span (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition spanEnd + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun f => Data.ByteString.spanEnd (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition breakEnd + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun f => Data.ByteString.breakEnd (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition split + : GHC.Char.Char -> + Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString := + Data.ByteString.split GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition splitWith + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString := + fun f => Data.ByteString.splitWith (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition groupBy + : (GHC.Char.Char -> GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString := + fun k => + Data.ByteString.groupBy (fun a b => + k (Data.ByteString.Internal.w2c a) (Data.ByteString.Internal.w2c b)). + +Definition index + : Data.ByteString.Internal.ByteString -> GHC.Num.Int -> GHC.Char.Char := + (fun arg_0__ => Data.ByteString.Internal.w2c GHC.Base.∘ arg_0__) GHC.Base.∘ + Data.ByteString.index. + +Definition indexMaybe + : Data.ByteString.Internal.ByteString -> GHC.Num.Int -> option GHC.Char.Char := + (fun arg_0__ => GHC.Base.fmap Data.ByteString.Internal.w2c GHC.Base.∘ arg_0__) + GHC.Base.∘ + Data.ByteString.indexMaybe. + +Definition op_znz3fU__ + : Data.ByteString.Internal.ByteString -> GHC.Num.Int -> option GHC.Char.Char := + indexMaybe. + +Notation "'_!?_'" := (op_znz3fU__). + +Infix "!?" := (_!?_) (at level 99). + +Definition elemIndexEnd + : GHC.Char.Char -> Data.ByteString.Internal.ByteString -> option GHC.Num.Int := + Data.ByteString.elemIndexEnd GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition elemIndices + : GHC.Char.Char -> Data.ByteString.Internal.ByteString -> list GHC.Num.Int := + Data.ByteString.elemIndices GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition findIndex + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> option GHC.Num.Int := + fun f => Data.ByteString.findIndex (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition findIndexEnd + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> option GHC.Num.Int := + fun f => + Data.ByteString.findIndexEnd (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition findIndices + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> list GHC.Num.Int := + fun f => + Data.ByteString.findIndices (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition count + : GHC.Char.Char -> Data.ByteString.Internal.ByteString -> GHC.Num.Int := + fun c => Data.ByteString.count (Data.ByteString.Internal.c2w c). + +Definition elem + : GHC.Char.Char -> Data.ByteString.Internal.ByteString -> bool := + fun c => Data.ByteString.elem (Data.ByteString.Internal.c2w c). + +Definition notElem + : GHC.Char.Char -> Data.ByteString.Internal.ByteString -> bool := + fun c => Data.ByteString.notElem (Data.ByteString.Internal.c2w c). + +Definition filter + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f => Data.ByteString.filter (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition partition + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun f => Data.ByteString.partition (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition find + : (GHC.Char.Char -> bool) -> + Data.ByteString.Internal.ByteString -> option GHC.Char.Char := + fun f ps => + GHC.Base.fmap Data.ByteString.Internal.w2c (Data.ByteString.find (f GHC.Base.∘ + Data.ByteString.Internal.w2c) ps). + +Fixpoint zip (ps qs : Data.ByteString.Internal.ByteString) : list (GHC.Char.Char + * + GHC.Char.Char)%type + := match uncons ps with + | None => nil + | Some (pair psH psT) => + match uncons qs with + | None => nil + | Some (pair qsH qsT) => cons (pair psH qsH) (zip psT qsT) + end + end. + +Definition zipWith {a : Type} + : (GHC.Char.Char -> GHC.Char.Char -> a) -> + Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> list a := + fun f => + Data.ByteString.zipWith ((fun arg_0__ => + arg_0__ GHC.Base.∘ Data.ByteString.Internal.w2c) GHC.Base.∘ + (f GHC.Base.∘ Data.ByteString.Internal.w2c)). + +Definition packZipWith + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun f => + let f' := + fun c1 c2 => + Data.ByteString.Internal.c2w (f (Data.ByteString.Internal.w2c c1) + (Data.ByteString.Internal.w2c c2)) in + Data.ByteString.packZipWith f'. + +Definition unzip + : list (GHC.Char.Char * GHC.Char.Char)%type -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun ls => + pair (pack (GHC.Base.map Data.Tuple.fst ls)) (pack (GHC.Base.map Data.Tuple.snd + ls)). + +Definition unsafeHead : Data.ByteString.Internal.ByteString -> GHC.Char.Char := + Data.ByteString.Internal.w2c GHC.Base.∘ Data.ByteString.Unsafe.unsafeHead. + +Fixpoint firstspace (ptr : GHC.Ptr.Ptr GHC.Word.Word8) (n m : GHC.Num.Int) + : GHC.Types.IO GHC.Num.Int + := if n GHC.Base.>= m : bool then GHC.Base.return_ n else + Foreign.Storable.peekByteOff ptr n GHC.Base.>>= + (fun w => + if (negb GHC.Base.∘ Data.ByteString.Internal.isSpaceWord8) w : bool + then firstspace ptr (n GHC.Num.+ #1) m + else GHC.Base.return_ n). + +Definition breakSpace + : Data.ByteString.Internal.ByteString -> + (Data.ByteString.Internal.ByteString * + Data.ByteString.Internal.ByteString)%type := + fun '(Data.ByteString.Internal.BS x l) => + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + firstspace p #0 l GHC.Base.>>= + (fun i => + GHC.Base.return_ (if i GHC.Base.== #0 : bool + then pair Data.ByteString.empty + (Data.ByteString.Internal.BS x + l) else + if i GHC.Base.== l : bool + then pair (Data.ByteString.Internal.BS x l) + Data.ByteString.empty else + pair (Data.ByteString.Internal.BS x i) + (Data.ByteString.Internal.BS + (GHC.ForeignPtr.plusForeignPtr x i) (l + GHC.Num.- + i)))))). + +Fixpoint firstnonspace (ptr : GHC.Ptr.Ptr GHC.Word.Word8) (n m : GHC.Num.Int) + : GHC.Types.IO GHC.Num.Int + := if n GHC.Base.>= m : bool then GHC.Base.return_ n else + Foreign.Storable.peekElemOff ptr n GHC.Base.>>= + (fun w => + if Data.ByteString.Internal.isSpaceWord8 w : bool + then firstnonspace ptr (n GHC.Num.+ #1) m + else GHC.Base.return_ n). + +Definition dropSpace + : Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun '(Data.ByteString.Internal.BS x l) => + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + firstnonspace p #0 l GHC.Base.>>= + (fun i => + GHC.Base.return_ (if i GHC.Base.== l : bool + then Data.ByteString.empty + else Data.ByteString.Internal.BS + (GHC.ForeignPtr.plusForeignPtr x i) (l + GHC.Num.- + i))))). + +Definition strip + : Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + dropWhile GHC.Unicode.isSpace GHC.Base.∘ dropWhileEnd GHC.Unicode.isSpace. + +Fixpoint lines (ps : Data.ByteString.Internal.ByteString) : list + Data.ByteString.Internal.ByteString + := let search := elemIndex (GHC.Char.hs_char__ "") in + if Data.ByteString.null ps : bool then nil else + match search ps with + | None => cons ps nil + | Some n => + cons (Data.ByteString.take n ps) (lines (Data.ByteString.drop (n GHC.Num.+ #1) + ps)) + end. + +Definition unlines + : list Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString := + fun arg_0__ => + match arg_0__ with + | nil => Data.ByteString.empty + | ss => + let nl := singleton (GHC.Char.hs_char__ "") in + Data.ByteString.append (Data.ByteString.concat (Data.OldList.intersperse nl ss)) + nl + end. + +Definition words + : Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString := + GHC.List.filter (negb GHC.Base.∘ Data.ByteString.null) GHC.Base.∘ + Data.ByteString.splitWith Data.ByteString.Internal.isSpaceWord8. + +Definition unwords + : list Data.ByteString.Internal.ByteString -> + Data.ByteString.Internal.ByteString := + Data.ByteString.intercalate (singleton (GHC.Char.hs_char__ " ")). + +Definition readInt + : Data.ByteString.Internal.ByteString -> + option (GHC.Num.Int * Data.ByteString.Internal.ByteString)%type := + fun bs => + let readDec := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | positive, Data.ByteString.Internal.BS fp len => + let w2int := + fun n => + if positive : bool then GHC.Real.fromIntegral n else + GHC.Num.negate (GHC.Real.fromIntegral n) in + let result := + fun nbytes acc str => + if nbytes GHC.Base.> #0 : bool then let i := w2int acc in Some (pair i str) else + None in + let digits := + fun maxq maxr e ptr => + let go + : GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Num.Int -> + GHC.Num.Word -> GHC.Types.IO (GHC.Num.Int * GHC.Num.Word * bool)%type := + fix go (arg_6__ : GHC.Ptr.Ptr GHC.Word.Word8) (arg_7__ : GHC.Num.Int) (arg_8__ + : GHC.Num.Word) : GHC.Types.IO (GHC.Num.Int * GHC.Num.Word * bool)%type + := match arg_6__, arg_7__, arg_8__ with + | p, b, a => + if p GHC.Base.== e : bool then GHC.Base.return_ (pair (pair b a) true) else + match arg_6__, arg_7__, arg_8__ with + | p, b, a => + (GHC.Real.fromIntegral Data.Functor.<$> Foreign.Storable.peek p) GHC.Base.>>= + (fun w => + let d := w GHC.Num.- #48 in + if d GHC.Base.> #9 : bool + then GHC.Base.return_ (pair (pair b a) true) + else if a GHC.Base.< maxq : bool + then go (GHC.Ptr.plusPtr p #1) (b GHC.Num.+ #1) ((a GHC.Num.* #10) GHC.Num.+ d) + else if a GHC.Base.> maxq : bool + then GHC.Base.return_ (pair (pair b a) false) + else if d GHC.Base.<= maxr : bool + then go (GHC.Ptr.plusPtr p #1) (b GHC.Num.+ #1) ((a GHC.Num.* #10) + GHC.Num.+ + d) + else GHC.Base.return_ (pair (pair b a) false)) + end + end in + go ptr in + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp (fun ptr => + let end := GHC.Ptr.plusPtr ptr len in + let cont_16__ arg_17__ := + let 'pair (pair n a) inRange := arg_17__ in + if inRange : bool + then if n GHC.Base.< len : bool + then let rest := + Data.ByteString.Internal.BS + (GHC.ForeignPtr.plusForeignPtr fp n) (len + GHC.Num.- + n) in + GHC.Base.return_ (result n a rest) + else GHC.Base.return_ (result n a + Data.ByteString.empty) + else GHC.Base.return_ None in + (if positive : bool + then digits Data.ByteString.Internal.intmaxQuot10 + Data.ByteString.Internal.intmaxRem10 end ptr #0 #0 + else digits Data.ByteString.Internal.intminQuot10 + Data.ByteString.Internal.intminRem10 end ptr #0 #0) + GHC.Base.>>= + cont_16__)) + end in + match Data.ByteString.uncons bs with + | Some (pair w rest) => + if (w GHC.Num.- #48) GHC.Base.<= #9 : bool then readDec true bs else + if w GHC.Base.== #45 : bool then readDec false rest else + if w GHC.Base.== #43 : bool then readDec true rest else + None + | _ => None + end. + +Definition readInteger + : Data.ByteString.Internal.ByteString -> + option (GHC.Integer.Type.Integer * Data.ByteString.Internal.ByteString)%type := + fun as_ => + let fix combine2 arg_0__ arg_1__ + := match arg_0__, arg_1__ with + | b, cons n (cons m ns) => + let t := (m GHC.Num.* b) GHC.Num.+ n in cons t (combine2 b ns) + | _, ns => ns + end in + let fix combine1 arg_5__ arg_6__ + := match arg_5__, arg_6__ with + | _, cons n nil => n + | b, ns => combine1 (b GHC.Num.* b) (combine2 b ns) + end in + let combine := + fun arg_9__ arg_10__ arg_11__ arg_12__ => + match arg_9__, arg_10__, arg_11__, arg_12__ with + | _, acc, nil, ps => pair (GHC.Real.toInteger acc) ps + | d, acc, ns, ps => + pair (((#10 GHC.Real.^ d) GHC.Num.* combine1 #1000000000 ns) GHC.Num.+ + GHC.Real.toInteger acc) ps + end in + let loop + : GHC.Num.Int -> + GHC.Num.Int -> + list GHC.Integer.Type.Integer -> + Data.ByteString.Internal.ByteString -> + (GHC.Integer.Type.Integer * Data.ByteString.Internal.ByteString)%type := + fix loop (d acc : GHC.Num.Int) (ns : list GHC.Integer.Type.Integer) (ps + : Data.ByteString.Internal.ByteString) : (GHC.Integer.Type.Integer * + Data.ByteString.Internal.ByteString)%type + := if Data.ByteString.null ps : bool + then combine d acc ns Data.ByteString.empty else + let 'w := Data.ByteString.Unsafe.unsafeHead ps in + if andb (w GHC.Base.>= #48) (w GHC.Base.<= #57) : bool + then if d GHC.Base.== #9 : bool + then loop #1 (GHC.Real.fromIntegral w GHC.Num.- #48) (cons (GHC.Real.toInteger + acc) ns) (Data.ByteString.Unsafe.unsafeTail + ps) + else loop (d GHC.Num.+ #1) ((#10 GHC.Num.* acc) GHC.Num.+ + (GHC.Real.fromIntegral w GHC.Num.- #48)) ns + (Data.ByteString.Unsafe.unsafeTail ps) else + combine d acc ns ps in + let first := + fun ps => + if Data.ByteString.null ps : bool then None else + let 'w := Data.ByteString.Unsafe.unsafeHead ps in + if andb (w GHC.Base.>= #48) (w GHC.Base.<= #57) : bool + then Some (loop #1 (GHC.Real.fromIntegral w GHC.Num.- #48) nil + (Data.ByteString.Unsafe.unsafeTail ps)) else + None in + if Data.ByteString.null as_ : bool then None else + match unsafeHead as_ with + | ("-"%char) => + first (Data.ByteString.Unsafe.unsafeTail as_) GHC.Base.>>= + (fun '(pair n bs) => GHC.Base.return_ (pair (GHC.Num.negate n) bs)) + | ("+"%char) => first (Data.ByteString.Unsafe.unsafeTail as_) + | _ => first as_ + end. + +Definition hPutStrLn + : GHC.IO.Handle.Types.Handle -> + Data.ByteString.Internal.ByteString -> GHC.Types.IO unit := + fun h ps => + if Data.ByteString.length ps GHC.Base.< #1024 : bool + then Data.ByteString.hPut h (Data.ByteString.snoc ps #10) else + Data.ByteString.hPut h ps GHC.Base.>> + Data.ByteString.hPut h (Data.ByteString.singleton #10). + +Definition putStrLn + : Data.ByteString.Internal.ByteString -> GHC.Types.IO unit := + hPutStrLn GHC.IO.Handle.FD.stdout. + +Module Notations. +Notation "'_Data.ByteString.Char8.!?_'" := (op_znz3fU__). +Infix "Data.ByteString.Char8.!?" := (_!?_) (at level 99). +End Notations. + +(* External variables: + None Some Type andb bool cons false list negb nil op_zt__ option pair true unit + Data.ByteString.all Data.ByteString.any Data.ByteString.append + Data.ByteString.break Data.ByteString.breakEnd Data.ByteString.concat + Data.ByteString.concatMap Data.ByteString.cons_ Data.ByteString.count + Data.ByteString.drop Data.ByteString.dropWhile Data.ByteString.dropWhileEnd + Data.ByteString.elem Data.ByteString.elemIndex Data.ByteString.elemIndexEnd + Data.ByteString.elemIndices Data.ByteString.empty Data.ByteString.filter + Data.ByteString.find Data.ByteString.findIndex Data.ByteString.findIndexEnd + Data.ByteString.findIndices Data.ByteString.foldl Data.ByteString.foldl' + Data.ByteString.foldl1 Data.ByteString.foldl1' Data.ByteString.foldr + Data.ByteString.foldr' Data.ByteString.foldr1 Data.ByteString.foldr1' + Data.ByteString.groupBy Data.ByteString.hPut Data.ByteString.head + Data.ByteString.index Data.ByteString.indexMaybe Data.ByteString.intercalate + Data.ByteString.intersperse Data.ByteString.last Data.ByteString.length + Data.ByteString.map Data.ByteString.mapAccumL Data.ByteString.mapAccumR + Data.ByteString.maximum Data.ByteString.minimum Data.ByteString.notElem + Data.ByteString.null Data.ByteString.packZipWith Data.ByteString.partition + Data.ByteString.replicate Data.ByteString.scanl Data.ByteString.scanl1 + Data.ByteString.scanr Data.ByteString.scanr1 Data.ByteString.singleton + Data.ByteString.snoc Data.ByteString.span Data.ByteString.spanEnd + Data.ByteString.split Data.ByteString.splitWith Data.ByteString.take + Data.ByteString.takeWhile Data.ByteString.takeWhileEnd Data.ByteString.uncons + Data.ByteString.unfoldr Data.ByteString.unfoldrN Data.ByteString.unsnoc + Data.ByteString.zipWith Data.ByteString.Internal.BS + Data.ByteString.Internal.ByteString + Data.ByteString.Internal.accursedUnutterablePerformIO + Data.ByteString.Internal.c2w Data.ByteString.Internal.intmaxQuot10 + Data.ByteString.Internal.intmaxRem10 Data.ByteString.Internal.intminQuot10 + Data.ByteString.Internal.intminRem10 Data.ByteString.Internal.isSpaceWord8 + Data.ByteString.Internal.packChars Data.ByteString.Internal.unpackChars + Data.ByteString.Internal.unsafeWithForeignPtr Data.ByteString.Internal.w2c + Data.ByteString.Unsafe.unsafeDrop Data.ByteString.Unsafe.unsafeHead + Data.ByteString.Unsafe.unsafeTail Data.ByteString.Unsafe.unsafeTake + Data.Functor.op_zlzdzg__ Data.OldList.intersperse Data.Tuple.fst Data.Tuple.snd + Foreign.Storable.peek Foreign.Storable.peekByteOff Foreign.Storable.peekElemOff + GHC.Base.String GHC.Base.fmap GHC.Base.map GHC.Base.op_z2218U__ + GHC.Base.op_zeze__ GHC.Base.op_zg__ GHC.Base.op_zgze__ GHC.Base.op_zgzg__ + GHC.Base.op_zgzgze__ GHC.Base.op_zl__ GHC.Base.op_zlze__ GHC.Base.return_ + GHC.Char.Char GHC.ForeignPtr.plusForeignPtr GHC.IO.Handle.FD.stdout + GHC.IO.Handle.Types.Handle GHC.Integer.Type.Integer GHC.List.filter GHC.Num.Int + GHC.Num.Word GHC.Num.fromInteger GHC.Num.negate GHC.Num.op_zm__ GHC.Num.op_zp__ + GHC.Num.op_zt__ GHC.Ptr.Ptr GHC.Ptr.plusPtr GHC.Real.fromIntegral + GHC.Real.op_zc__ GHC.Real.toInteger GHC.Types.IO GHC.Unicode.isSpace + GHC.Word.Word8 +*) diff --git a/examples/bytestring/lib/Data/ByteString/Internal.h2ci b/examples/bytestring/lib/Data/ByteString/Internal.h2ci new file mode 100644 index 000000000..dacfde74c --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Internal.h2ci @@ -0,0 +1,6 @@ +constructors: + Data.ByteString.Internal.ByteString: ! '[Qualified "Data.ByteString.Internal" "BS"]' +constructorFields: + Data.ByteString.Internal.BS: NonRecordFields 2 +constructorTypes: + Data.ByteString.Internal.BS: Qualified "Data.ByteString.Internal" "ByteString" diff --git a/examples/bytestring/lib/Data/ByteString/Internal.v b/examples/bytestring/lib/Data/ByteString/Internal.v new file mode 100644 index 000000000..95578d1f9 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Internal.v @@ -0,0 +1,216 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require GHC.Base. +Require GHC.Char. +Require GHC.Num. +Require GHC.Prim. +Require GHC.Real. +Import GHC.Prim.Notations. + +(* Converted type declarations: *) + +Inductive ByteString : Type := + | BS : (GHC.ForeignPtr.ForeignPtr GHC.Word.Word8) -> GHC.Num.Int -> ByteString. + +Definition StrictByteString := + ByteString%type. + +(* Converted value declarations: *) + +Instance Eq___ByteString : GHC.Base.Eq_ ByteString. +Proof. +Admitted. + +Instance Ord__ByteString : GHC.Base.Ord ByteString. +Proof. +Admitted. + +Instance Semigroup__ByteString : GHC.Base.Semigroup ByteString. +Proof. +Admitted. + +Instance Monoid__ByteString : GHC.Base.Monoid ByteString. +Proof. +Admitted. + +(* Skipping all instances of class `Control.DeepSeq.NFData', including + `Data.ByteString.Internal.NFData__ByteString' *) + +(* Skipping all instances of class `GHC.Show.Show', including + `Data.ByteString.Internal.Show__ByteString' *) + +(* Skipping all instances of class `GHC.Read.Read', including + `Data.ByteString.Internal.Read__ByteString' *) + +(* Skipping all instances of class `GHC.Exts.IsList', including + `Data.ByteString.Internal.IsList__ByteString' *) + +(* Skipping all instances of class `Data.Data.Data', including + `Data.ByteString.Internal.Data__ByteString' *) + +Axiom unsafeWithForeignPtr : forall {a : Type}, + forall {b : Type}, + GHC.ForeignPtr.ForeignPtr a -> + (GHC.Ptr.Ptr a -> GHC.Types.IO b) -> GHC.Types.IO b. + +Axiom findIndexOrLength : (GHC.Word.Word8 -> bool) -> ByteString -> GHC.Num.Int. + +Axiom packBytes : list GHC.Word.Word8 -> ByteString. + +Axiom packChars : list GHC.Char.Char -> ByteString. + +Axiom unsafePackLenBytes : GHC.Num.Int -> list GHC.Word.Word8 -> ByteString. + +Axiom unsafePackLenChars : GHC.Num.Int -> list GHC.Char.Char -> ByteString. + +Axiom unsafePackAddress : _GHC.Prim.Addr#_ -> GHC.Types.IO ByteString. + +Axiom unsafePackLenAddress : GHC.Num.Int -> + _GHC.Prim.Addr#_ -> GHC.Types.IO ByteString. + +Axiom unsafePackLiteral : _GHC.Prim.Addr#_ -> ByteString. + +Axiom unsafePackLenLiteral : GHC.Num.Int -> _GHC.Prim.Addr#_ -> ByteString. + +Axiom packUptoLenBytes : GHC.Num.Int -> + list GHC.Word.Word8 -> (ByteString * list GHC.Word.Word8)%type. + +Axiom packUptoLenChars : GHC.Num.Int -> + list GHC.Char.Char -> (ByteString * list GHC.Char.Char)%type. + +Axiom unpackBytes : ByteString -> list GHC.Word.Word8. + +Axiom unpackChars : ByteString -> list GHC.Char.Char. + +Axiom unpackAppendBytesLazy : ByteString -> + list GHC.Word.Word8 -> list GHC.Word.Word8. + +Axiom unpackAppendCharsLazy : ByteString -> + list GHC.Char.Char -> list GHC.Char.Char. + +Axiom unpackAppendBytesStrict : ByteString -> + list GHC.Word.Word8 -> list GHC.Word.Word8. + +Axiom unpackAppendCharsStrict : ByteString -> + list GHC.Char.Char -> list GHC.Char.Char. + +Axiom nullForeignPtr : GHC.ForeignPtr.ForeignPtr GHC.Word.Word8. + +Axiom fromForeignPtr : GHC.ForeignPtr.ForeignPtr GHC.Word.Word8 -> + GHC.Num.Int -> GHC.Num.Int -> ByteString. + +Axiom fromForeignPtr0 : GHC.ForeignPtr.ForeignPtr GHC.Word.Word8 -> + GHC.Num.Int -> ByteString. + +Axiom toForeignPtr : ByteString -> + (GHC.ForeignPtr.ForeignPtr GHC.Word.Word8 * GHC.Num.Int * GHC.Num.Int)%type. + +Axiom toForeignPtr0 : ByteString -> + (GHC.ForeignPtr.ForeignPtr GHC.Word.Word8 * GHC.Num.Int)%type. + +Axiom unsafeCreate : GHC.Num.Int -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO unit) -> ByteString. + +Axiom unsafeCreateUptoN : GHC.Num.Int -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO GHC.Num.Int) -> ByteString. + +Axiom unsafeCreateUptoN' : forall {a : Type}, + GHC.Num.Int -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO (GHC.Num.Int * a)%type) -> + (ByteString * a)%type. + +Axiom create : GHC.Num.Int -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO unit) -> GHC.Types.IO ByteString. + +Axiom createUptoN : GHC.Num.Int -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO GHC.Num.Int) -> + GHC.Types.IO ByteString. + +Axiom createUptoN' : forall {a : Type}, + GHC.Num.Int -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO (GHC.Num.Int * a)%type) -> + GHC.Types.IO (ByteString * a)%type. + +Axiom createAndTrim : GHC.Num.Int -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Types.IO GHC.Num.Int) -> + GHC.Types.IO ByteString. + +Axiom createAndTrim' : forall {a : Type}, + GHC.Num.Int -> + (GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Types.IO (GHC.Num.Int * GHC.Num.Int * a)%type) -> + GHC.Types.IO (ByteString * a)%type. + +Axiom mallocByteString : forall {a : Type}, + GHC.Num.Int -> GHC.Types.IO (GHC.ForeignPtr.ForeignPtr a). + +Axiom eq : ByteString -> ByteString -> bool. + +Axiom compareBytes : ByteString -> ByteString -> comparison. + +Axiom append : ByteString -> ByteString -> ByteString. + +Axiom concat : list ByteString -> ByteString. + +Axiom times : forall {a}, + forall `{GHC.Real.Integral a}, a -> ByteString -> ByteString. + +Axiom checkedAdd : GHC.Base.String -> GHC.Num.Int -> GHC.Num.Int -> GHC.Num.Int. + +Axiom w2c : GHC.Word.Word8 -> GHC.Char.Char. + +Axiom c2w : GHC.Char.Char -> GHC.Word.Word8. + +Axiom isSpaceWord8 : GHC.Word.Word8 -> bool. + +Axiom isSpaceChar8 : GHC.Char.Char -> bool. + +Axiom overflowError : forall {a}, GHC.Base.String -> a. + +Axiom intmaxWord : GHC.Num.Word. + +Axiom intminWord : GHC.Num.Word. + +Axiom intmaxQuot10 : GHC.Num.Word. + +Axiom intmaxRem10 : GHC.Num.Word. + +Axiom intminQuot10 : GHC.Num.Word. + +Axiom intminRem10 : GHC.Num.Word. + +Axiom accursedUnutterablePerformIO : forall {a : Type}, GHC.Types.IO a -> a. + +Axiom memchr : GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Word.Word8 -> + Foreign.C.Types.CSize -> GHC.Types.IO (GHC.Ptr.Ptr GHC.Word.Word8). + +Axiom memcmp : GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Num.Int -> GHC.Types.IO Foreign.C.Types.CInt. + +Axiom memcpy : GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Ptr.Ptr GHC.Word.Word8 -> GHC.Num.Int -> GHC.Types.IO unit. + +Axiom memset : GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Word.Word8 -> + Foreign.C.Types.CSize -> GHC.Types.IO (GHC.Ptr.Ptr GHC.Word.Word8). + +(* External variables: + Type bool comparison list op_zt__ unit Foreign.C.Types.CInt + Foreign.C.Types.CSize GHC.Base.Eq_ GHC.Base.Monoid GHC.Base.Ord + GHC.Base.Semigroup GHC.Base.String GHC.Char.Char GHC.ForeignPtr.ForeignPtr + GHC.Num.Int GHC.Num.Word GHC.Prim.op_Addrzh__ GHC.Ptr.Ptr GHC.Real.Integral + GHC.Types.IO GHC.Word.Word8 +*) diff --git a/examples/bytestring/lib/Data/ByteString/Lazy.h2ci b/examples/bytestring/lib/Data/ByteString/Lazy.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Lazy.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString/Lazy.v b/examples/bytestring/lib/Data/ByteString/Lazy.v new file mode 100644 index 000000000..bb495b592 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Lazy.v @@ -0,0 +1,1832 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Coq.Init.Datatypes. +Require Data.Bifunctor. +Require Data.ByteString. +Require Data.ByteString.Internal. +Require Data.ByteString.Lazy.Internal. +Require Data.ByteString.Lazy.Internal.Deque. +Require Data.ByteString.Unsafe. +Require Data.Foldable. +Require Data.Functor. +Require Data.OldList. +Require Data.Tuple. +Require GHC.Base. +Require GHC.Err. +Require GHC.List. +Require GHC.Num. +Require GHC.Real. +Require GHC.Tuple. +Import Data.Functor.Notations. +Import GHC.Base.Notations. +Import GHC.Num.Notations. + +(* No type declarations to convert. *) + +(* Converted value declarations: *) + +Definition empty : Data.ByteString.Lazy.Internal.ByteString := + Data.ByteString.Lazy.Internal.Empty. + +Definition singleton + : GHC.Word.Word8 -> Data.ByteString.Lazy.Internal.ByteString := + fun w => + Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.singleton w) + Data.ByteString.Lazy.Internal.Empty. + +Definition pack + : list GHC.Word.Word8 -> Data.ByteString.Lazy.Internal.ByteString := + Data.ByteString.Lazy.Internal.packBytes. + +Definition unpack + : Data.ByteString.Lazy.Internal.ByteString -> list GHC.Word.Word8 := + Data.ByteString.Lazy.Internal.unpackBytes. + +Definition fromChunks + : list Data.ByteString.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + Data.Foldable.foldr Data.ByteString.Lazy.Internal.chunk + Data.ByteString.Lazy.Internal.Empty. + +Definition toChunks + : Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Internal.ByteString := + Data.ByteString.Lazy.Internal.foldrChunks cons nil. + +Definition null : Data.ByteString.Lazy.Internal.ByteString -> bool := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => true + | _ => false + end. + +Definition length : Data.ByteString.Lazy.Internal.ByteString -> GHC.Int.Int64 := + Data.ByteString.Lazy.Internal.foldlChunks (fun n c => + n GHC.Num.+ GHC.Real.fromIntegral (Data.ByteString.length c)) #0. + +Definition cons_ + : GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun c => Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.singleton c). + +Definition cons' + : GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ arg_1__ => + let j_3__ := + match arg_0__, arg_1__ with + | w, cs => Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.singleton w) cs + end in + match arg_0__, arg_1__ with + | w, Data.ByteString.Lazy.Internal.Chunk c cs => + if Data.ByteString.length c GHC.Base.< #16 : bool + then Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.cons_ w c) cs else + j_3__ + | _, _ => j_3__ + end. + +Definition snoc + : Data.ByteString.Lazy.Internal.ByteString -> + GHC.Word.Word8 -> Data.ByteString.Lazy.Internal.ByteString := + fun cs w => + Data.ByteString.Lazy.Internal.foldrChunks Data.ByteString.Lazy.Internal.Chunk + (singleton w) cs. + +Definition moduleError {a} : GHC.Base.String -> GHC.Base.String -> a := + fun fun_ msg => + GHC.Err.error (Coq.Init.Datatypes.app (GHC.Base.hs_string__ + "Data.ByteString.Lazy.") (Coq.Init.Datatypes.app fun_ (cons + (GHC.Char.hs_char__ ":") + (cons (GHC.Char.hs_char__ + " ") msg)))). + +Definition errorEmptyList {a} : GHC.Base.String -> a := + fun fun_ => moduleError fun_ (GHC.Base.hs_string__ "empty ByteString"). + +Definition head : Data.ByteString.Lazy.Internal.ByteString -> GHC.Word.Word8 := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => + errorEmptyList (GHC.Base.hs_string__ "head") + | Data.ByteString.Lazy.Internal.Chunk c _ => Data.ByteString.Unsafe.unsafeHead c + end. + +Definition uncons + : Data.ByteString.Lazy.Internal.ByteString -> + option (GHC.Word.Word8 * Data.ByteString.Lazy.Internal.ByteString)%type := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => None + | Data.ByteString.Lazy.Internal.Chunk c cs => + Some (pair (Data.ByteString.Unsafe.unsafeHead c) (if Data.ByteString.length c + GHC.Base.== + #1 : bool + then cs + else Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Unsafe.unsafeTail c) + cs)) + end. + +Definition tail + : Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => + errorEmptyList (GHC.Base.hs_string__ "tail") + | Data.ByteString.Lazy.Internal.Chunk c cs => + if Data.ByteString.length c GHC.Base.== #1 : bool then cs else + Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Unsafe.unsafeTail c) cs + end. + +Definition last : Data.ByteString.Lazy.Internal.ByteString -> GHC.Word.Word8 := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => + errorEmptyList (GHC.Base.hs_string__ "last") + | Data.ByteString.Lazy.Internal.Chunk c0 cs0 => + let fix go arg_2__ arg_3__ + := match arg_2__, arg_3__ with + | c, Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Unsafe.unsafeLast c + | _, Data.ByteString.Lazy.Internal.Chunk c cs => go c cs + end in + go c0 cs0 + end. + +Definition init + : Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => + errorEmptyList (GHC.Base.hs_string__ "init") + | Data.ByteString.Lazy.Internal.Chunk c0 cs0 => + let fix go arg_2__ arg_3__ + := match arg_2__, arg_3__ with + | c, Data.ByteString.Lazy.Internal.Empty => + if Data.ByteString.length c GHC.Base.== #1 : bool + then Data.ByteString.Lazy.Internal.Empty else + Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Unsafe.unsafeInit c) + Data.ByteString.Lazy.Internal.Empty + | c, Data.ByteString.Lazy.Internal.Chunk c' cs => + Data.ByteString.Lazy.Internal.Chunk c (go c' cs) + end in + go c0 cs0 + end. + +Definition unsnoc + : Data.ByteString.Lazy.Internal.ByteString -> + option (Data.ByteString.Lazy.Internal.ByteString * GHC.Word.Word8)%type := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => None + | Data.ByteString.Lazy.Internal.Chunk c cs => + Some (pair (init (Data.ByteString.Lazy.Internal.Chunk c cs)) (last + (Data.ByteString.Lazy.Internal.Chunk c cs))) + end. + +Definition append + : Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + GHC.Base.mappend. + +Definition map + : (GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + let fix go arg_0__ + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Lazy.Internal.Empty + | Data.ByteString.Lazy.Internal.Chunk x xs => + let ys := go xs in + let y := Data.ByteString.map f x in Data.ByteString.Lazy.Internal.Chunk y ys + end in + go. + +Definition reverse + : Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + let fix rev arg_0__ arg_1__ + := match arg_0__, arg_1__ with + | a, Data.ByteString.Lazy.Internal.Empty => a + | a, Data.ByteString.Lazy.Internal.Chunk c cs => + rev (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.reverse c) a) cs + end in + rev Data.ByteString.Lazy.Internal.Empty. + +Definition intersperse + : GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Lazy.Internal.Empty + | w, Data.ByteString.Lazy.Internal.Chunk c cs => + let intersperse' + : Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun '(Data.ByteString.Internal.BS fp l) => + Data.ByteString.Internal.unsafeCreate (#2 GHC.Num.* l) (fun p' => + Data.ByteString.Internal.unsafeWithForeignPtr fp + (fun p => + Foreign.Storable.poke p' w GHC.Base.>> + Data.ByteString.Internal.c_intersperse + (GHC.Ptr.plusPtr p' #1) p + (GHC.Real.fromIntegral l) w)) in + Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.intersperse w c) + (Data.ByteString.Lazy.Internal.foldrChunks (Data.ByteString.Lazy.Internal.Chunk + GHC.Base.∘ + intersperse') Data.ByteString.Lazy.Internal.Empty cs) + end. + +Definition transpose + : list Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + fun css => + GHC.Base.map (fun ss => + Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.pack ss) + Data.ByteString.Lazy.Internal.Empty) (Data.OldList.transpose (GHC.Base.map + unpack css)). + +Definition foldl {a : Type} + : (a -> GHC.Word.Word8 -> a) -> + a -> Data.ByteString.Lazy.Internal.ByteString -> a := + fun f => + let fix go arg_0__ arg_1__ + := match arg_0__, arg_1__ with + | a, Data.ByteString.Lazy.Internal.Empty => a + | a, Data.ByteString.Lazy.Internal.Chunk c cs => + go (Data.ByteString.foldl f a c) cs + end in + go. + +Definition foldl' {a : Type} + : (a -> GHC.Word.Word8 -> a) -> + a -> Data.ByteString.Lazy.Internal.ByteString -> a := + fun f => + let fix go arg_0__ arg_1__ + := match arg_0__, arg_1__ with + | a, Data.ByteString.Lazy.Internal.Empty => a + | a, Data.ByteString.Lazy.Internal.Chunk c cs => + go (Data.ByteString.foldl' f a c) cs + end in + go. + +Definition foldr {a : Type} + : (GHC.Word.Word8 -> a -> a) -> + a -> Data.ByteString.Lazy.Internal.ByteString -> a := + fun k => + Data.ByteString.Lazy.Internal.foldrChunks (GHC.Base.flip (Data.ByteString.foldr + k)). + +Fixpoint foldr' {a : Type} (f : GHC.Word.Word8 -> a -> a) (a : a) + : Data.ByteString.Lazy.Internal.ByteString -> a + := let go := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => a + | Data.ByteString.Lazy.Internal.Chunk c cs => + Data.ByteString.foldr' f (foldr' f a cs) c + end in + go. + +Definition foldl1 + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Word.Word8 := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => + errorEmptyList (GHC.Base.hs_string__ "foldl1") + | f, Data.ByteString.Lazy.Internal.Chunk c cs => + foldl f (Data.ByteString.Unsafe.unsafeHead c) + (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Unsafe.unsafeTail c) cs) + end. + +Definition foldl1' + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Word.Word8 := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => + errorEmptyList (GHC.Base.hs_string__ "foldl1'") + | f, Data.ByteString.Lazy.Internal.Chunk c cs => + foldl' f (Data.ByteString.Unsafe.unsafeHead c) + (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Unsafe.unsafeTail c) cs) + end. + +Definition foldr1 + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Word.Word8 := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => + errorEmptyList (GHC.Base.hs_string__ "foldr1") + | f, Data.ByteString.Lazy.Internal.Chunk c0 cs0 => + let fix go arg_3__ arg_4__ + := match arg_3__, arg_4__ with + | c, Data.ByteString.Lazy.Internal.Empty => Data.ByteString.foldr1 f c + | c, Data.ByteString.Lazy.Internal.Chunk c' cs => + Data.ByteString.foldr f (go c' cs) c + end in + go c0 cs0 + end. + +Definition foldr1' + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Word.Word8 := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => + errorEmptyList (GHC.Base.hs_string__ "foldr1'") + | f, Data.ByteString.Lazy.Internal.Chunk c0 cs0 => + let fix go arg_3__ arg_4__ + := match arg_3__, arg_4__ with + | c, Data.ByteString.Lazy.Internal.Empty => Data.ByteString.foldr1' f c + | c, Data.ByteString.Lazy.Internal.Chunk c' cs => + Data.ByteString.foldr' f (go c' cs) c + end in + go c0 cs0 + end. + +Definition concat + : list Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + GHC.Base.mconcat. + +Definition concatMap + : (GHC.Word.Word8 -> Data.ByteString.Lazy.Internal.ByteString) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Lazy.Internal.Empty + | f, Data.ByteString.Lazy.Internal.Chunk c0 cs0 => + let go + : Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fix go (arg_2__ : Data.ByteString.Lazy.Internal.ByteString) (arg_3__ + : Data.ByteString.Internal.ByteString) (arg_4__ + : Data.ByteString.Lazy.Internal.ByteString) + : Data.ByteString.Lazy.Internal.ByteString + := match arg_2__, arg_3__, arg_4__ with + | Data.ByteString.Lazy.Internal.Empty, c', cs' => to c' cs' + | Data.ByteString.Lazy.Internal.Chunk c cs, c', cs' => + Data.ByteString.Lazy.Internal.Chunk c (go cs c' cs') + end + with to (c : Data.ByteString.Internal.ByteString) (cs + : Data.ByteString.Lazy.Internal.ByteString) + : Data.ByteString.Lazy.Internal.ByteString + := if Data.ByteString.null c : bool + then match cs with + | Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Lazy.Internal.Empty + | Data.ByteString.Lazy.Internal.Chunk c' cs' => to c' cs' + end else + go (f (Data.ByteString.Unsafe.unsafeHead c)) (Data.ByteString.Unsafe.unsafeTail + c) cs for go in + let to + : Data.ByteString.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fix go (arg_2__ : Data.ByteString.Lazy.Internal.ByteString) (arg_3__ + : Data.ByteString.Internal.ByteString) (arg_4__ + : Data.ByteString.Lazy.Internal.ByteString) + : Data.ByteString.Lazy.Internal.ByteString + := match arg_2__, arg_3__, arg_4__ with + | Data.ByteString.Lazy.Internal.Empty, c', cs' => to c' cs' + | Data.ByteString.Lazy.Internal.Chunk c cs, c', cs' => + Data.ByteString.Lazy.Internal.Chunk c (go cs c' cs') + end + with to (c : Data.ByteString.Internal.ByteString) (cs + : Data.ByteString.Lazy.Internal.ByteString) + : Data.ByteString.Lazy.Internal.ByteString + := if Data.ByteString.null c : bool + then match cs with + | Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Lazy.Internal.Empty + | Data.ByteString.Lazy.Internal.Chunk c' cs' => to c' cs' + end else + go (f (Data.ByteString.Unsafe.unsafeHead c)) (Data.ByteString.Unsafe.unsafeTail + c) cs for to in + to c0 cs0 + end. + +Definition any + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> bool := + fun f => + Data.ByteString.Lazy.Internal.foldrChunks (fun c rest => + orb (Data.ByteString.any f c) rest) false. + +Definition all + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> bool := + fun f => + Data.ByteString.Lazy.Internal.foldrChunks (fun c rest => + andb (Data.ByteString.all f c) rest) true. + +Definition maximum + : Data.ByteString.Lazy.Internal.ByteString -> GHC.Word.Word8 := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => + errorEmptyList (GHC.Base.hs_string__ "maximum") + | Data.ByteString.Lazy.Internal.Chunk c cs => + Data.ByteString.Lazy.Internal.foldlChunks (fun n c' => + GHC.Base.max n (Data.ByteString.maximum c')) + (Data.ByteString.maximum c) cs + end. + +Definition minimum + : Data.ByteString.Lazy.Internal.ByteString -> GHC.Word.Word8 := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => + errorEmptyList (GHC.Base.hs_string__ "minimum") + | Data.ByteString.Lazy.Internal.Chunk c cs => + Data.ByteString.Lazy.Internal.foldlChunks (fun n c' => + GHC.Base.min n (Data.ByteString.minimum c')) + (Data.ByteString.minimum c) cs + end. + +Fixpoint compareLength (arg_0__ : Data.ByteString.Lazy.Internal.ByteString) + (arg_1__ : GHC.Int.Int64) : comparison + := match arg_0__, arg_1__ with + | _, toCmp => + if toCmp GHC.Base.< #0 : bool then Gt else + match arg_0__, arg_1__ with + | Data.ByteString.Lazy.Internal.Empty, toCmp => GHC.Base.compare #0 toCmp + | Data.ByteString.Lazy.Internal.Chunk c cs, toCmp => + compareLength cs (toCmp GHC.Num.- + GHC.Real.fromIntegral (Data.ByteString.length c)) + end + end. + +Definition mapAccumL {acc : Type} + : (acc -> GHC.Word.Word8 -> (acc * GHC.Word.Word8)%type) -> + acc -> + Data.ByteString.Lazy.Internal.ByteString -> + (acc * Data.ByteString.Lazy.Internal.ByteString)%type := + fun f => + let fix go arg_0__ arg_1__ + := match arg_0__, arg_1__ with + | s, Data.ByteString.Lazy.Internal.Empty => + pair s Data.ByteString.Lazy.Internal.Empty + | s, Data.ByteString.Lazy.Internal.Chunk c cs => + let 'pair s' c' := Data.ByteString.mapAccumL f s c in + let 'pair s'' cs' := go s' cs in + pair s'' (Data.ByteString.Lazy.Internal.Chunk c' cs') + end in + go. + +Definition mapAccumR {acc : Type} + : (acc -> GHC.Word.Word8 -> (acc * GHC.Word.Word8)%type) -> + acc -> + Data.ByteString.Lazy.Internal.ByteString -> + (acc * Data.ByteString.Lazy.Internal.ByteString)%type := + fun f => + let fix go arg_0__ arg_1__ + := match arg_0__, arg_1__ with + | s, Data.ByteString.Lazy.Internal.Empty => + pair s Data.ByteString.Lazy.Internal.Empty + | s, Data.ByteString.Lazy.Internal.Chunk c cs => + let 'pair s' cs' := go s cs in + let 'pair s'' c' := Data.ByteString.mapAccumR f s' c in + pair s'' (Data.ByteString.Lazy.Internal.Chunk c' cs') + end in + go. + +Definition scanl + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun function => + GHC.Base.fmap (Data.Tuple.uncurry (GHC.Base.flip snoc)) GHC.Base.∘ + mapAccumL (fun x y => pair (function x y) x). + +Definition scanl1 + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun function byteStream => + match uncons byteStream with + | None => Data.ByteString.Lazy.Internal.Empty + | Some (pair firstByte remainingBytes) => + scanl function firstByte remainingBytes + end. + +Definition scanr + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun function => + GHC.Base.fmap (Data.Tuple.uncurry cons_) GHC.Base.∘ + mapAccumR (fun x y => pair (function y x) x). + +Definition scanr1 + : (GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun function byteStream => + match unsnoc byteStream with + | None => Data.ByteString.Lazy.Internal.Empty + | Some (pair initialBytes lastByte) => scanr function lastByte initialBytes + end. + +Definition unfoldr {a : Type} + : (a -> option (GHC.Word.Word8 * a)%type) -> + a -> Data.ByteString.Lazy.Internal.ByteString := + fun f => + let fix unfoldChunk n x + := match Data.ByteString.unfoldrN n f x with + | pair c None => + if Data.ByteString.null c : bool then Data.ByteString.Lazy.Internal.Empty else + Data.ByteString.Lazy.Internal.Chunk c Data.ByteString.Lazy.Internal.Empty + | pair c (Some x') => + Data.ByteString.Lazy.Internal.Chunk c (unfoldChunk (n GHC.Num.* #2) x') + end in + unfoldChunk #32. + +Definition iterate + : (GHC.Word.Word8 -> GHC.Word.Word8) -> + GHC.Word.Word8 -> Data.ByteString.Lazy.Internal.ByteString := + fun f => unfoldr (fun x => let 'x' := f x in Some (pair x' x')). + +(* Translating `repeat' failed: recursion through non-lambda value unsupported + [in definition cs in module Data.ByteString.Lazy] *) + +Axiom repeat : forall {A : Type}, A. + +Definition replicate + : GHC.Int.Int64 -> + GHC.Word.Word8 -> Data.ByteString.Lazy.Internal.ByteString := + fun n w => + let 'pair q r := GHC.Real.quotRem n (GHC.Real.fromIntegral + Data.ByteString.Lazy.Internal.smallChunkSize) in + let c := + Data.ByteString.replicate Data.ByteString.Lazy.Internal.smallChunkSize w in + let fix nChunks arg_2__ + := let 'num_3__ := arg_2__ in + if num_3__ GHC.Base.== #0 : bool then Data.ByteString.Lazy.Internal.Empty else + let 'm := arg_2__ in + Data.ByteString.Lazy.Internal.Chunk c (nChunks (m GHC.Num.- #1)) in + let cs := nChunks q in + if n GHC.Base.<= #0 : bool then Data.ByteString.Lazy.Internal.Empty else + if n GHC.Base.< + GHC.Real.fromIntegral Data.ByteString.Lazy.Internal.smallChunkSize : bool + then Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.replicate + (GHC.Real.fromIntegral n) w) Data.ByteString.Lazy.Internal.Empty else + if r GHC.Base.== #0 : bool then cs else + Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Unsafe.unsafeTake + (GHC.Real.fromIntegral r) c) cs. + +(* Translating `cycle' failed: recursion through non-lambda value unsupported + [in definition cs' in module Data.ByteString.Lazy] *) + +Axiom cycle : forall {A : Type}, A. + +Definition take + : GHC.Int.Int64 -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | i, _ => + if i GHC.Base.<= #0 : bool then Data.ByteString.Lazy.Internal.Empty else + match arg_0__, arg_1__ with + | i, cs0 => + let fix take' arg_2__ arg_3__ + := match arg_2__, arg_3__ with + | num_4__, _ => + if num_4__ GHC.Base.== #0 : bool then Data.ByteString.Lazy.Internal.Empty else + match arg_2__, arg_3__ with + | _, Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Lazy.Internal.Empty + | n, Data.ByteString.Lazy.Internal.Chunk c cs => + if n GHC.Base.< GHC.Real.fromIntegral (Data.ByteString.length c) : bool + then Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.take + (GHC.Real.fromIntegral n) c) + Data.ByteString.Lazy.Internal.Empty + else Data.ByteString.Lazy.Internal.Chunk c (take' (n GHC.Num.- + GHC.Real.fromIntegral + (Data.ByteString.length c)) cs) + end + end in + take' i cs0 + end + end. + +Definition takeEnd + : GHC.Int.Int64 -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | i, _ => + if i GHC.Base.<= #0 : bool then Data.ByteString.Lazy.Internal.Empty else + match arg_0__, arg_1__ with + | i, cs0 => + let takeTuple := + fun arg_2__ arg_3__ => + match arg_2__, arg_3__ with + | _, pair num_4__ cs => + if num_4__ GHC.Base.== #0 : bool then pair #0 cs else + match arg_2__, arg_3__ with + | c, pair n cs => + if n GHC.Base.> GHC.Real.fromIntegral (Data.ByteString.length c) : bool + then pair (n GHC.Num.- GHC.Real.fromIntegral (Data.ByteString.length c)) + (Data.ByteString.Lazy.Internal.Chunk c cs) else + pair #0 (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.takeEnd + (GHC.Real.fromIntegral n) c) cs) + end + end in + let takeEnd' := + fun arg_10__ arg_11__ => + match arg_10__, arg_11__ with + | num_12__, _ => + if num_12__ GHC.Base.== #0 : bool then Data.ByteString.Lazy.Internal.Empty else + match arg_10__, arg_11__ with + | n, cs => + Data.Tuple.snd (Data.ByteString.Lazy.Internal.foldrChunks takeTuple (pair n + Data.ByteString.Lazy.Internal.Empty) + cs) + end + end in + takeEnd' i cs0 + end + end. + +Definition drop + : GHC.Int.Int64 -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | i, p => + if i GHC.Base.<= #0 : bool then p else + match arg_0__, arg_1__ with + | i, cs0 => + let fix drop' arg_2__ arg_3__ + := match arg_2__, arg_3__ with + | num_4__, cs => + if num_4__ GHC.Base.== #0 : bool then cs else + match arg_2__, arg_3__ with + | _, Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Lazy.Internal.Empty + | n, Data.ByteString.Lazy.Internal.Chunk c cs => + if n GHC.Base.< GHC.Real.fromIntegral (Data.ByteString.length c) : bool + then Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.drop + (GHC.Real.fromIntegral n) c) cs + else drop' (n GHC.Num.- GHC.Real.fromIntegral (Data.ByteString.length c)) cs + end + end in + drop' i cs0 + end + end. + +Definition dropEnd + : GHC.Int.Int64 -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | i, p => + if i GHC.Base.<= #0 : bool then p else + match arg_0__, arg_1__ with + | i, p => + let fromDeque + : Data.ByteString.Lazy.Internal.Deque.Deque -> + Data.ByteString.Lazy.Internal.ByteString := + fun deque => + append (Data.Foldable.foldr Data.ByteString.Lazy.Internal.chunk + Data.ByteString.Lazy.Internal.Empty (Data.ByteString.Lazy.Internal.Deque.front + deque)) (Data.Foldable.foldl' (GHC.Base.flip + Data.ByteString.Lazy.Internal.chunk) + Data.ByteString.Lazy.Internal.Empty (Data.ByteString.Lazy.Internal.Deque.rear + deque)) in + let reverseChunks := + Data.ByteString.Lazy.Internal.foldlChunks (GHC.Base.flip + Data.ByteString.Lazy.Internal.Chunk) empty in + let getOutput + : Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.Deque.Deque -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.Deque.Deque)%type := + fix getOutput (out : Data.ByteString.Lazy.Internal.ByteString) (deque + : Data.ByteString.Lazy.Internal.Deque.Deque) + : (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.Deque.Deque)%type + := match Data.ByteString.Lazy.Internal.Deque.popFront deque with + | None => pair (reverseChunks out) deque + | Some (pair x deque') => + if Data.ByteString.Lazy.Internal.Deque.byteLength deque' GHC.Base.>= i : bool + then getOutput (Data.ByteString.Lazy.Internal.Chunk x out) deque' else + pair (reverseChunks out) deque + end in + let len := fun c => GHC.Real.fromIntegral (Data.ByteString.length c) in + let dropEndBytes + : Data.ByteString.Lazy.Internal.Deque.Deque -> + GHC.Int.Int64 -> Data.ByteString.Lazy.Internal.Deque.Deque := + fix dropEndBytes (deque : Data.ByteString.Lazy.Internal.Deque.Deque) (n + : GHC.Int.Int64) : Data.ByteString.Lazy.Internal.Deque.Deque + := match Data.ByteString.Lazy.Internal.Deque.popRear deque with + | None => deque + | Some (pair deque' x) => + if len x GHC.Base.<= n : bool then dropEndBytes deque' (n GHC.Num.- len x) else + Data.ByteString.Lazy.Internal.Deque.snoc (Data.ByteString.dropEnd + (GHC.Real.fromIntegral n) x) deque' + end in + let go + : Data.ByteString.Lazy.Internal.Deque.Deque -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fix go (arg_17__ : Data.ByteString.Lazy.Internal.Deque.Deque) (arg_18__ + : Data.ByteString.Lazy.Internal.ByteString) + : Data.ByteString.Lazy.Internal.ByteString + := match arg_17__, arg_18__ with + | deque, Data.ByteString.Lazy.Internal.Chunk c cs => + if Data.ByteString.Lazy.Internal.Deque.byteLength deque GHC.Base.< i : bool + then go (Data.ByteString.Lazy.Internal.Deque.snoc c deque) cs else + let 'pair output deque' := getOutput empty + (Data.ByteString.Lazy.Internal.Deque.snoc c deque) in + Data.ByteString.Lazy.Internal.foldrChunks Data.ByteString.Lazy.Internal.Chunk + (go deque' cs) output + | deque, Data.ByteString.Lazy.Internal.Empty => fromDeque (dropEndBytes deque i) + end in + go Data.ByteString.Lazy.Internal.Deque.empty p + end + end. + +Definition splitAt + : GHC.Int.Int64 -> + Data.ByteString.Lazy.Internal.ByteString -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | i, cs0 => + if i GHC.Base.<= #0 : bool + then pair Data.ByteString.Lazy.Internal.Empty cs0 else + match arg_0__, arg_1__ with + | i, cs0 => + let fix splitAt' arg_2__ arg_3__ + := match arg_2__, arg_3__ with + | num_4__, cs => + if num_4__ GHC.Base.== #0 : bool + then pair Data.ByteString.Lazy.Internal.Empty cs else + match arg_2__, arg_3__ with + | _, Data.ByteString.Lazy.Internal.Empty => + pair Data.ByteString.Lazy.Internal.Empty Data.ByteString.Lazy.Internal.Empty + | n, Data.ByteString.Lazy.Internal.Chunk c cs => + if n GHC.Base.< GHC.Real.fromIntegral (Data.ByteString.length c) : bool + then pair (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.take + (GHC.Real.fromIntegral n) c) + Data.ByteString.Lazy.Internal.Empty) (Data.ByteString.Lazy.Internal.Chunk + (Data.ByteString.drop (GHC.Real.fromIntegral n) c) cs) + else let 'pair cs' cs'' := splitAt' (n GHC.Num.- + GHC.Real.fromIntegral (Data.ByteString.length c)) cs in + pair (Data.ByteString.Lazy.Internal.Chunk c cs') cs'' + end + end in + splitAt' i cs0 + end + end. + +Definition takeWhile + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + let fix takeWhile' arg_0__ + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Lazy.Internal.Empty + | Data.ByteString.Lazy.Internal.Chunk c cs => + let scrut_1__ := + Data.ByteString.Internal.findIndexOrLength (negb GHC.Base.∘ f) c in + let 'num_2__ := scrut_1__ in + if num_2__ GHC.Base.== #0 : bool then Data.ByteString.Lazy.Internal.Empty else + let 'n := scrut_1__ in + if n GHC.Base.< Data.ByteString.length c : bool + then Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.take n c) + Data.ByteString.Lazy.Internal.Empty else + Data.ByteString.Lazy.Internal.Chunk c (takeWhile' cs) + end in + takeWhile'. + +Definition takeWhileEnd + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + let takeTuple := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, pair false bs => pair false bs + | c, pair true bs => + let 'c' := Data.ByteString.takeWhileEnd f c in + if Data.ByteString.length c' GHC.Base.== Data.ByteString.length c : bool + then pair true (Data.ByteString.Lazy.Internal.Chunk c bs) else + pair false (append (Data.ByteString.Lazy.Internal.fromStrict c') bs) + end in + let takeWhileEnd' := + fun arg_9__ => + match arg_9__ with + | Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Lazy.Internal.Empty + | cs => + Data.Tuple.snd (Data.ByteString.Lazy.Internal.foldrChunks takeTuple (pair true + Data.ByteString.Lazy.Internal.Empty) + cs) + end in + takeWhileEnd'. + +Definition dropWhile + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + let fix dropWhile' arg_0__ + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Lazy.Internal.Empty + | Data.ByteString.Lazy.Internal.Chunk c cs => + let 'n := Data.ByteString.Internal.findIndexOrLength (negb GHC.Base.∘ f) c in + if n GHC.Base.< Data.ByteString.length c : bool + then Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.drop n c) cs else + dropWhile' cs + end in + dropWhile'. + +Definition dropWhileEnd + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + let fix dropEndBytes arg_0__ + := match arg_0__ with + | nil => Data.ByteString.Lazy.Internal.Empty + | cons x xs => + let 'x' := Data.ByteString.dropWhileEnd f x in + if Data.ByteString.null x' : bool then dropEndBytes xs else + Data.Foldable.foldl' (GHC.Base.flip Data.ByteString.Lazy.Internal.Chunk) + Data.ByteString.Lazy.Internal.Empty (cons x' xs) + end in + let fix go arg_7__ arg_8__ + := match arg_7__, arg_8__ with + | acc, Data.ByteString.Lazy.Internal.Chunk c cs => + if f (Data.ByteString.last c) : bool then go (cons c acc) cs else + Data.Foldable.foldl (GHC.Base.flip Data.ByteString.Lazy.Internal.Chunk) (go nil + cs) (cons c acc) + | acc, Data.ByteString.Lazy.Internal.Empty => dropEndBytes acc + end in + go nil. + +Definition break + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun f => + let fix break' arg_0__ + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => + pair Data.ByteString.Lazy.Internal.Empty Data.ByteString.Lazy.Internal.Empty + | Data.ByteString.Lazy.Internal.Chunk c cs => + let scrut_2__ := Data.ByteString.Internal.findIndexOrLength f c in + let 'num_3__ := scrut_2__ in + if num_3__ GHC.Base.== #0 : bool + then pair Data.ByteString.Lazy.Internal.Empty + (Data.ByteString.Lazy.Internal.Chunk c cs) else + let 'n := scrut_2__ in + if n GHC.Base.< Data.ByteString.length c : bool + then pair (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.take n c) + Data.ByteString.Lazy.Internal.Empty) (Data.ByteString.Lazy.Internal.Chunk + (Data.ByteString.drop n c) cs) else + let 'pair cs' cs'' := break' cs in + pair (Data.ByteString.Lazy.Internal.Chunk c cs') cs'' + end in + break'. + +Definition breakEnd + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun f => + let fix dropEndBytes arg_0__ + := match arg_0__ with + | nil => + pair Data.ByteString.Lazy.Internal.Empty Data.ByteString.Lazy.Internal.Empty + | cons x xs => + let 'pair x' x'' := Data.ByteString.breakEnd f x in + if Data.ByteString.null x' : bool + then let 'pair y y' := dropEndBytes xs in + pair y (append y' (Data.ByteString.Lazy.Internal.fromStrict x)) else + Data.Foldable.foldl' (GHC.Base.flip (Data.Bifunctor.first GHC.Base.∘ + Data.ByteString.Lazy.Internal.Chunk)) (pair + (Data.ByteString.Lazy.Internal.fromStrict + x') + (Data.ByteString.Lazy.Internal.fromStrict + x'')) xs + end in + let fix go arg_9__ arg_10__ + := match arg_9__, arg_10__ with + | acc, Data.ByteString.Lazy.Internal.Chunk c cs => + if f (Data.ByteString.last c) : bool + then Data.Foldable.foldl (GHC.Base.flip (Data.Bifunctor.first GHC.Base.∘ + Data.ByteString.Lazy.Internal.Chunk)) (go nil cs) (cons c + acc) else + go (cons c acc) cs + | acc, Data.ByteString.Lazy.Internal.Empty => dropEndBytes acc + end in + go nil. + +Definition span + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun p => break (negb GHC.Base.∘ p). + +Definition spanEnd + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun p => breakEnd (negb GHC.Base.∘ p). + +Definition revChunks + : list Data.ByteString.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + Data.Foldable.foldl' (GHC.Base.flip Data.ByteString.Lazy.Internal.chunk) + Data.ByteString.Lazy.Internal.Empty. + +Definition splitWith + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => nil + | p, Data.ByteString.Lazy.Internal.Chunk c0 cs0 => + let comb + : list Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + fix comb (arg_2__ arg_3__ : list Data.ByteString.Internal.ByteString) (arg_4__ + : Data.ByteString.Lazy.Internal.ByteString) : list + Data.ByteString.Lazy.Internal.ByteString + := match arg_2__, arg_3__, arg_4__ with + | acc, cons s nil, Data.ByteString.Lazy.Internal.Empty => + cons (revChunks (cons s acc)) nil + | acc, cons s nil, Data.ByteString.Lazy.Internal.Chunk c cs => + comb (cons s acc) (Data.ByteString.splitWith p c) cs + | acc, cons s ss, cs => cons (revChunks (cons s acc)) (comb nil ss cs) + | _, _, _ => GHC.Err.patternFailure + end in + comb nil (Data.ByteString.splitWith p c0) cs0 + end. + +Definition split + : GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => nil + | w, Data.ByteString.Lazy.Internal.Chunk c0 cs0 => + let comb + : list Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + fix comb (arg_2__ arg_3__ : list Data.ByteString.Internal.ByteString) (arg_4__ + : Data.ByteString.Lazy.Internal.ByteString) : list + Data.ByteString.Lazy.Internal.ByteString + := match arg_2__, arg_3__, arg_4__ with + | acc, cons s nil, Data.ByteString.Lazy.Internal.Empty => + cons (revChunks (cons s acc)) nil + | acc, cons s nil, Data.ByteString.Lazy.Internal.Chunk c cs => + comb (cons s acc) (Data.ByteString.split w c) cs + | acc, cons s ss, cs => cons (revChunks (cons s acc)) (comb nil ss cs) + | _, _, _ => GHC.Err.patternFailure + end in + comb nil (Data.ByteString.split w c0) cs0 + end. + +Definition revNonEmptyChunks + : list Data.ByteString.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + Data.Foldable.foldl' (GHC.Base.flip Data.ByteString.Lazy.Internal.Chunk) + Data.ByteString.Lazy.Internal.Empty. + +Definition group + : Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + let go := + fix go arg_0__ + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => nil + | Data.ByteString.Lazy.Internal.Chunk c cs => + if Data.ByteString.length c GHC.Base.== #1 : bool + then to (cons c nil) (Data.ByteString.Unsafe.unsafeHead c) cs else + to (cons (Data.ByteString.Unsafe.unsafeTake #1 c) nil) + (Data.ByteString.Unsafe.unsafeHead c) (Data.ByteString.Lazy.Internal.Chunk + (Data.ByteString.Unsafe.unsafeTail c) cs) + end + with to arg_4__ arg_5__ arg_6__ + := match arg_4__, arg_5__, arg_6__ with + | acc, _, Data.ByteString.Lazy.Internal.Empty => + cons (revNonEmptyChunks acc) nil + | acc, w, Data.ByteString.Lazy.Internal.Chunk c cs => + let scrut_9__ := + Data.ByteString.Internal.findIndexOrLength (fun arg_8__ => + arg_8__ GHC.Base./= w) c in + let 'num_10__ := scrut_9__ in + if num_10__ GHC.Base.== #0 : bool + then cons (revNonEmptyChunks acc) (go (Data.ByteString.Lazy.Internal.Chunk c + cs)) else + let 'n := scrut_9__ in + if n GHC.Base.== Data.ByteString.length c : bool + then to (cons (Data.ByteString.Unsafe.unsafeTake n c) acc) w cs else + cons (revNonEmptyChunks (cons (Data.ByteString.Unsafe.unsafeTake n c) acc)) (go + (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Unsafe.unsafeDrop n c) + cs)) + end for go in + let to := + fix go arg_0__ + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => nil + | Data.ByteString.Lazy.Internal.Chunk c cs => + if Data.ByteString.length c GHC.Base.== #1 : bool + then to (cons c nil) (Data.ByteString.Unsafe.unsafeHead c) cs else + to (cons (Data.ByteString.Unsafe.unsafeTake #1 c) nil) + (Data.ByteString.Unsafe.unsafeHead c) (Data.ByteString.Lazy.Internal.Chunk + (Data.ByteString.Unsafe.unsafeTail c) cs) + end + with to arg_4__ arg_5__ arg_6__ + := match arg_4__, arg_5__, arg_6__ with + | acc, _, Data.ByteString.Lazy.Internal.Empty => + cons (revNonEmptyChunks acc) nil + | acc, w, Data.ByteString.Lazy.Internal.Chunk c cs => + let scrut_9__ := + Data.ByteString.Internal.findIndexOrLength (fun arg_8__ => + arg_8__ GHC.Base./= w) c in + let 'num_10__ := scrut_9__ in + if num_10__ GHC.Base.== #0 : bool + then cons (revNonEmptyChunks acc) (go (Data.ByteString.Lazy.Internal.Chunk c + cs)) else + let 'n := scrut_9__ in + if n GHC.Base.== Data.ByteString.length c : bool + then to (cons (Data.ByteString.Unsafe.unsafeTake n c) acc) w cs else + cons (revNonEmptyChunks (cons (Data.ByteString.Unsafe.unsafeTake n c) acc)) (go + (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Unsafe.unsafeDrop n c) + cs)) + end for to in + go. + +Definition groupBy + : (GHC.Word.Word8 -> GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + fun k => + let go := + fix go arg_0__ + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => nil + | Data.ByteString.Lazy.Internal.Chunk c cs => + if Data.ByteString.length c GHC.Base.== #1 : bool + then to (cons c nil) (Data.ByteString.Unsafe.unsafeHead c) cs else + to (cons (Data.ByteString.Unsafe.unsafeTake #1 c) nil) + (Data.ByteString.Unsafe.unsafeHead c) (Data.ByteString.Lazy.Internal.Chunk + (Data.ByteString.Unsafe.unsafeTail c) cs) + end + with to arg_4__ arg_5__ arg_6__ + := match arg_4__, arg_5__, arg_6__ with + | acc, _, Data.ByteString.Lazy.Internal.Empty => + cons (revNonEmptyChunks acc) nil + | acc, w, Data.ByteString.Lazy.Internal.Chunk c cs => + let scrut_8__ := + Data.ByteString.Internal.findIndexOrLength (negb GHC.Base.∘ k w) c in + let 'num_9__ := scrut_8__ in + if num_9__ GHC.Base.== #0 : bool + then cons (revNonEmptyChunks acc) (go (Data.ByteString.Lazy.Internal.Chunk c + cs)) else + let 'n := scrut_8__ in + if n GHC.Base.== Data.ByteString.length c : bool + then to (cons (Data.ByteString.Unsafe.unsafeTake n c) acc) w cs else + cons (revNonEmptyChunks (cons (Data.ByteString.Unsafe.unsafeTake n c) acc)) (go + (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Unsafe.unsafeDrop n c) + cs)) + end for go in + let to := + fix go arg_0__ + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => nil + | Data.ByteString.Lazy.Internal.Chunk c cs => + if Data.ByteString.length c GHC.Base.== #1 : bool + then to (cons c nil) (Data.ByteString.Unsafe.unsafeHead c) cs else + to (cons (Data.ByteString.Unsafe.unsafeTake #1 c) nil) + (Data.ByteString.Unsafe.unsafeHead c) (Data.ByteString.Lazy.Internal.Chunk + (Data.ByteString.Unsafe.unsafeTail c) cs) + end + with to arg_4__ arg_5__ arg_6__ + := match arg_4__, arg_5__, arg_6__ with + | acc, _, Data.ByteString.Lazy.Internal.Empty => + cons (revNonEmptyChunks acc) nil + | acc, w, Data.ByteString.Lazy.Internal.Chunk c cs => + let scrut_8__ := + Data.ByteString.Internal.findIndexOrLength (negb GHC.Base.∘ k w) c in + let 'num_9__ := scrut_8__ in + if num_9__ GHC.Base.== #0 : bool + then cons (revNonEmptyChunks acc) (go (Data.ByteString.Lazy.Internal.Chunk c + cs)) else + let 'n := scrut_8__ in + if n GHC.Base.== Data.ByteString.length c : bool + then to (cons (Data.ByteString.Unsafe.unsafeTake n c) acc) w cs else + cons (revNonEmptyChunks (cons (Data.ByteString.Unsafe.unsafeTake n c) acc)) (go + (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Unsafe.unsafeDrop n c) + cs)) + end for to in + go. + +Definition intercalate + : Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun s => concat GHC.Base.∘ Data.OldList.intersperse s. + +Definition index + : Data.ByteString.Lazy.Internal.ByteString -> + GHC.Int.Int64 -> GHC.Word.Word8 := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, i => + if i GHC.Base.< #0 : bool + then moduleError (GHC.Base.hs_string__ "index") (Coq.Init.Datatypes.app + (GHC.Base.hs_string__ "negative index: ") (GHC.Show.show + i)) else + match arg_0__, arg_1__ with + | cs0, i => + let fix index' arg_2__ arg_3__ + := match arg_2__, arg_3__ with + | Data.ByteString.Lazy.Internal.Empty, n => + moduleError (GHC.Base.hs_string__ "index") (Coq.Init.Datatypes.app + (GHC.Base.hs_string__ "index too large: ") + (GHC.Show.show n)) + | Data.ByteString.Lazy.Internal.Chunk c cs, n => + if n GHC.Base.>= GHC.Real.fromIntegral (Data.ByteString.length c) : bool + then index' cs (n GHC.Num.- + GHC.Real.fromIntegral (Data.ByteString.length c)) else + Data.ByteString.Unsafe.unsafeIndex c (GHC.Real.fromIntegral n) + end in + index' cs0 i + end + end. + +Definition indexMaybe + : Data.ByteString.Lazy.Internal.ByteString -> + GHC.Int.Int64 -> option GHC.Word.Word8 := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | _, i => + if i GHC.Base.< #0 : bool then None else + match arg_0__, arg_1__ with + | cs0, i => + let fix index' arg_2__ arg_3__ + := match arg_2__, arg_3__ with + | Data.ByteString.Lazy.Internal.Empty, _ => None + | Data.ByteString.Lazy.Internal.Chunk c cs, n => + if n GHC.Base.>= GHC.Real.fromIntegral (Data.ByteString.length c) : bool + then index' cs (n GHC.Num.- + GHC.Real.fromIntegral (Data.ByteString.length c)) else + Some (Data.ByteString.Unsafe.unsafeIndex c (GHC.Real.fromIntegral n)) + end in + index' cs0 i + end + end. + +Definition op_znz3fU__ + : Data.ByteString.Lazy.Internal.ByteString -> + GHC.Int.Int64 -> option GHC.Word.Word8 := + indexMaybe. + +Notation "'_!?_'" := (op_znz3fU__). + +Infix "!?" := (_!?_) (at level 99). + +Definition elemIndex + : GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> option GHC.Int.Int64 := + fun w => + let fix elemIndex' arg_0__ arg_1__ + := match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => None + | n, Data.ByteString.Lazy.Internal.Chunk c cs => + match Data.ByteString.elemIndex w c with + | None => + elemIndex' (n GHC.Num.+ GHC.Real.fromIntegral (Data.ByteString.length c)) cs + | Some i => Some (n GHC.Num.+ GHC.Real.fromIntegral i) + end + end in + elemIndex' #0. + +Definition findIndexEnd + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> option GHC.Int.Int64 := + fun k => + let fix findIndexEnd' arg_0__ arg_1__ + := match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => None + | n, Data.ByteString.Lazy.Internal.Chunk c cs => + let i := + (GHC.Real.fromIntegral GHC.Base.∘ (fun arg_2__ => n GHC.Num.+ arg_2__)) + Data.Functor.<$> + Data.ByteString.findIndexEnd k c in + let n' := n GHC.Num.+ Data.ByteString.length c in + GHC.Base.mplus (findIndexEnd' n' cs) i + end in + findIndexEnd' #0. + +Definition elemIndexEnd + : GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> option GHC.Int.Int64 := + findIndexEnd GHC.Base.∘ _GHC.Base.==_. + +Definition elemIndices + : GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> list GHC.Int.Int64 := + fun w => + let fix elemIndices' arg_0__ arg_1__ + := match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => nil + | n, Data.ByteString.Lazy.Internal.Chunk c cs => + Coq.Init.Datatypes.app (GHC.Base.map ((fun arg_2__ => arg_2__ GHC.Num.+ n) + GHC.Base.∘ + GHC.Real.fromIntegral) (Data.ByteString.elemIndices w c)) + (elemIndices' (n GHC.Num.+ GHC.Real.fromIntegral (Data.ByteString.length c)) cs) + end in + elemIndices' #0. + +Definition count + : GHC.Word.Word8 -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Int.Int64 := + fun w => + Data.ByteString.Lazy.Internal.foldlChunks (fun n c => + n GHC.Num.+ GHC.Real.fromIntegral (Data.ByteString.count w c)) #0. + +Definition findIndex + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> option GHC.Int.Int64 := + fun k => + let fix findIndex' arg_0__ arg_1__ + := match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => None + | n, Data.ByteString.Lazy.Internal.Chunk c cs => + match Data.ByteString.findIndex k c with + | None => + findIndex' (n GHC.Num.+ GHC.Real.fromIntegral (Data.ByteString.length c)) cs + | Some i => Some (n GHC.Num.+ GHC.Real.fromIntegral i) + end + end in + findIndex' #0. + +Definition find + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> option GHC.Word.Word8 := + fun f => + let fix find' arg_0__ + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => None + | Data.ByteString.Lazy.Internal.Chunk c cs => + match Data.ByteString.find f c with + | None => find' cs + | Some w => Some w + end + end in + find'. + +Definition findIndices + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> list GHC.Int.Int64 := + fun k => + let fix findIndices' arg_0__ arg_1__ + := match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => nil + | n, Data.ByteString.Lazy.Internal.Chunk c cs => + Coq.Init.Datatypes.app (GHC.Base.map ((fun arg_2__ => arg_2__ GHC.Num.+ n) + GHC.Base.∘ + GHC.Real.fromIntegral) (Data.ByteString.findIndices k c)) + (findIndices' (n GHC.Num.+ GHC.Real.fromIntegral (Data.ByteString.length c)) cs) + end in + findIndices' #0. + +Definition elem + : GHC.Word.Word8 -> Data.ByteString.Lazy.Internal.ByteString -> bool := + fun w cs => match elemIndex w cs with | None => false | _ => true end. + +Definition notElem + : GHC.Word.Word8 -> Data.ByteString.Lazy.Internal.ByteString -> bool := + fun w cs => negb (elem w cs). + +Definition filter + : (GHC.Word.Word8 -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun p => + let fix go arg_0__ + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => Data.ByteString.Lazy.Internal.Empty + | Data.ByteString.Lazy.Internal.Chunk x xs => + Data.ByteString.Lazy.Internal.chunk (Data.ByteString.filter p x) (go xs) + end in + go. + +Fixpoint partition (arg_0__ : GHC.Word.Word8 -> bool) (arg_1__ + : Data.ByteString.Lazy.Internal.ByteString) + : (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type + := match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => + pair Data.ByteString.Lazy.Internal.Empty Data.ByteString.Lazy.Internal.Empty + | p, Data.ByteString.Lazy.Internal.Chunk x xs => + let 'pair ts fs := partition p xs in + let 'pair t f := Data.ByteString.partition p x in + pair (Data.ByteString.Lazy.Internal.chunk t ts) + (Data.ByteString.Lazy.Internal.chunk f fs) + end. + +Fixpoint isPrefixOf (arg_0__ arg_1__ : Data.ByteString.Lazy.Internal.ByteString) + : bool + := match arg_0__, arg_1__ with + | Data.ByteString.Lazy.Internal.Empty, _ => true + | _, Data.ByteString.Lazy.Internal.Empty => false + | Data.ByteString.Lazy.Internal.Chunk x xs + , Data.ByteString.Lazy.Internal.Chunk y ys => + let 'pair yh yt := Data.ByteString.splitAt (Data.ByteString.length x) y in + let 'pair xh xt := Data.ByteString.splitAt (Data.ByteString.length y) x in + if Data.ByteString.length x GHC.Base.== Data.ByteString.length y : bool + then andb (x GHC.Base.== y) (isPrefixOf xs ys) else + if Data.ByteString.length x GHC.Base.< Data.ByteString.length y : bool + then andb (x GHC.Base.== yh) (isPrefixOf xs (Data.ByteString.Lazy.Internal.Chunk + yt ys)) else + andb (xh GHC.Base.== y) (isPrefixOf (Data.ByteString.Lazy.Internal.Chunk xt xs) + ys) + end. + +Fixpoint stripPrefix (arg_0__ arg_1__ + : Data.ByteString.Lazy.Internal.ByteString) : option + Data.ByteString.Lazy.Internal.ByteString + := match arg_0__, arg_1__ with + | Data.ByteString.Lazy.Internal.Empty, bs => Some bs + | _, Data.ByteString.Lazy.Internal.Empty => None + | Data.ByteString.Lazy.Internal.Chunk x xs + , Data.ByteString.Lazy.Internal.Chunk y ys => + if Data.ByteString.length x GHC.Base.== Data.ByteString.length y : bool + then if x GHC.Base.== y : bool + then stripPrefix xs ys + else None else + if Data.ByteString.length x GHC.Base.< Data.ByteString.length y : bool + then Data.ByteString.stripPrefix x y GHC.Base.>>= + (fun yt => stripPrefix xs (Data.ByteString.Lazy.Internal.Chunk yt ys)) else + Data.ByteString.stripPrefix y x GHC.Base.>>= + (fun xt => stripPrefix (Data.ByteString.Lazy.Internal.Chunk xt xs) ys) + end. + +Definition isSuffixOf + : Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> bool := + fun x y => isPrefixOf (reverse x) (reverse y). + +Definition stripSuffix + : Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> + option Data.ByteString.Lazy.Internal.ByteString := + fun x y => reverse Data.Functor.<$> stripPrefix (reverse x) (reverse y). + +Definition zipWith {a : Type} + : (GHC.Word.Word8 -> GHC.Word.Word8 -> a) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> list a := + fun arg_0__ arg_1__ arg_2__ => + match arg_0__, arg_1__, arg_2__ with + | _, Data.ByteString.Lazy.Internal.Empty, _ => nil + | _, _, Data.ByteString.Lazy.Internal.Empty => nil + | f + , Data.ByteString.Lazy.Internal.Chunk a as_ + , Data.ByteString.Lazy.Internal.Chunk b bs => + let go := + fix go x xs y ys + := cons (f (Data.ByteString.Unsafe.unsafeHead x) + (Data.ByteString.Unsafe.unsafeHead y)) (to (Data.ByteString.Unsafe.unsafeTail x) + xs (Data.ByteString.Unsafe.unsafeTail y) ys) + with to arg_4__ arg_5__ arg_6__ arg_7__ + := let j_9__ := + match arg_4__, arg_5__, arg_6__, arg_7__ with + | _ + , Data.ByteString.Lazy.Internal.Chunk x' xs + , _ + , Data.ByteString.Lazy.Internal.Chunk y' ys => + go x' xs y' ys + | _, _, _, _ => GHC.Err.patternFailure + end in + let j_11__ := + match arg_4__, arg_5__, arg_6__, arg_7__ with + | _, Data.ByteString.Lazy.Internal.Chunk x' xs, y, ys => + if negb (Data.ByteString.null y) : bool then go x' xs y ys else + j_9__ + | _, _, _, _ => j_9__ + end in + let j_13__ := + match arg_4__, arg_5__, arg_6__, arg_7__ with + | x, xs, _, Data.ByteString.Lazy.Internal.Chunk y' ys => + if negb (Data.ByteString.null x) : bool then go x xs y' ys else + j_11__ + | _, _, _, _ => j_11__ + end in + let j_15__ := + match arg_4__, arg_5__, arg_6__, arg_7__ with + | x, xs, y, ys => + if andb (negb (Data.ByteString.null x)) (negb (Data.ByteString.null y)) : bool + then go x xs y ys else + j_13__ + end in + let j_17__ := + match arg_4__, arg_5__, arg_6__, arg_7__ with + | _, _, y, Data.ByteString.Lazy.Internal.Empty => + if Data.ByteString.null y : bool then nil else + j_15__ + | _, _, _, _ => j_15__ + end in + match arg_4__, arg_5__, arg_6__, arg_7__ with + | x, Data.ByteString.Lazy.Internal.Empty, _, _ => + if Data.ByteString.null x : bool then nil else + j_17__ + | _, _, _, _ => j_17__ + end for go in + let to := + fix go x xs y ys + := cons (f (Data.ByteString.Unsafe.unsafeHead x) + (Data.ByteString.Unsafe.unsafeHead y)) (to (Data.ByteString.Unsafe.unsafeTail x) + xs (Data.ByteString.Unsafe.unsafeTail y) ys) + with to arg_4__ arg_5__ arg_6__ arg_7__ + := let j_9__ := + match arg_4__, arg_5__, arg_6__, arg_7__ with + | _ + , Data.ByteString.Lazy.Internal.Chunk x' xs + , _ + , Data.ByteString.Lazy.Internal.Chunk y' ys => + go x' xs y' ys + | _, _, _, _ => GHC.Err.patternFailure + end in + let j_11__ := + match arg_4__, arg_5__, arg_6__, arg_7__ with + | _, Data.ByteString.Lazy.Internal.Chunk x' xs, y, ys => + if negb (Data.ByteString.null y) : bool then go x' xs y ys else + j_9__ + | _, _, _, _ => j_9__ + end in + let j_13__ := + match arg_4__, arg_5__, arg_6__, arg_7__ with + | x, xs, _, Data.ByteString.Lazy.Internal.Chunk y' ys => + if negb (Data.ByteString.null x) : bool then go x xs y' ys else + j_11__ + | _, _, _, _ => j_11__ + end in + let j_15__ := + match arg_4__, arg_5__, arg_6__, arg_7__ with + | x, xs, y, ys => + if andb (negb (Data.ByteString.null x)) (negb (Data.ByteString.null y)) : bool + then go x xs y ys else + j_13__ + end in + let j_17__ := + match arg_4__, arg_5__, arg_6__, arg_7__ with + | _, _, y, Data.ByteString.Lazy.Internal.Empty => + if Data.ByteString.null y : bool then nil else + j_15__ + | _, _, _, _ => j_15__ + end in + match arg_4__, arg_5__, arg_6__, arg_7__ with + | x, Data.ByteString.Lazy.Internal.Empty, _, _ => + if Data.ByteString.null x : bool then nil else + j_17__ + | _, _, _, _ => j_17__ + end for to in + go a as_ b bs + end. + +Definition zip + : Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> + list (GHC.Word.Word8 * GHC.Word.Word8)%type := + zipWith GHC.Tuple.pair2. + +Fixpoint packZipWith (arg_0__ + : GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Word.Word8) (arg_1__ arg_2__ + : Data.ByteString.Lazy.Internal.ByteString) + : Data.ByteString.Lazy.Internal.ByteString + := match arg_0__, arg_1__, arg_2__ with + | _, Data.ByteString.Lazy.Internal.Empty, _ => + Data.ByteString.Lazy.Internal.Empty + | _, _, Data.ByteString.Lazy.Internal.Empty => + Data.ByteString.Lazy.Internal.Empty + | f + , Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Internal.BS _ al as a) + as_ + , Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.Internal.BS _ bl as b) + bs => + Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.packZipWith f a b) + (match GHC.Base.compare al bl with + | Lt => + packZipWith f as_ (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.drop al + b) bs) + | Eq => packZipWith f as_ bs + | Gt => + packZipWith f (Data.ByteString.Lazy.Internal.Chunk (Data.ByteString.drop bl a) + as_) bs + end) + end. + +Definition unzip + : list (GHC.Word.Word8 * GHC.Word.Word8)%type -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun ls => + pair (pack (GHC.Base.map Data.Tuple.fst ls)) (pack (GHC.Base.map Data.Tuple.snd + ls)). + +Definition inits + : Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + let fix inits' arg_0__ + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => nil + | Data.ByteString.Lazy.Internal.Chunk c cs => + Coq.Init.Datatypes.app (GHC.Base.map (fun arg_1__ => + Data.ByteString.Lazy.Internal.Chunk arg_1__ + Data.ByteString.Lazy.Internal.Empty) + (GHC.List.tail (Data.ByteString.inits c))) (GHC.Base.map + (Data.ByteString.Lazy.Internal.Chunk c) (inits' cs)) + end in + (fun arg_4__ => cons Data.ByteString.Lazy.Internal.Empty arg_4__) GHC.Base.∘ + inits'. + +Fixpoint tails (arg_0__ : Data.ByteString.Lazy.Internal.ByteString) : list + Data.ByteString.Lazy.Internal.ByteString + := match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => + cons Data.ByteString.Lazy.Internal.Empty nil + | (Data.ByteString.Lazy.Internal.Chunk c cs' as cs) => + if Data.ByteString.length c GHC.Base.== #1 : bool then cons cs (tails cs') else + cons cs (tails (Data.ByteString.Lazy.Internal.Chunk + (Data.ByteString.Unsafe.unsafeTail c) cs')) + end. + +Definition copy + : Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + Data.ByteString.Lazy.Internal.foldrChunks (Data.ByteString.Lazy.Internal.Chunk + GHC.Base.∘ + Data.ByteString.copy) Data.ByteString.Lazy.Internal.Empty. + +(* Translating `hGetContentsN' failed: recursion through non-lambda value + unsupported [in definition lazyRead in module Data.ByteString.Lazy] *) + +Axiom hGetContentsN : forall {A : Type}, A. + +Definition illegalBufferSize {a} + : GHC.IO.Handle.Types.Handle -> + GHC.Base.String -> GHC.Num.Int -> GHC.Types.IO a := + fun handle fn sz => + let msg := + Coq.Init.Datatypes.app fn (Coq.Init.Datatypes.app (GHC.Base.hs_string__ + ": illegal ByteString size ") (GHC.Show.showsPrec #9 sz + nil)) in + GHC.IO.Exception.ioError (System.IO.Error.mkIOError + System.IO.Error.illegalOperationErrorType msg (Some handle) None). + +Definition hGetN + : GHC.Num.Int -> + GHC.IO.Handle.Types.Handle -> + GHC.Num.Int -> GHC.Types.IO Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ arg_1__ arg_2__ => + match arg_0__, arg_1__, arg_2__ with + | k, h, n => + let j_5__ := + match arg_0__, arg_1__, arg_2__ with + | _, h, n => illegalBufferSize h (GHC.Base.hs_string__ "hGet") n + end in + let j_7__ := + match arg_0__, arg_1__, arg_2__ with + | _, _, num_3__ => + if num_3__ GHC.Base.== #0 : bool + then GHC.Base.return_ Data.ByteString.Lazy.Internal.Empty else + j_5__ + end in + let fix readChunks i + := Data.ByteString.hGet h (GHC.Base.min k i) GHC.Base.>>= + (fun c => + let scrut_8__ := Data.ByteString.length c in + let 'num_9__ := scrut_8__ in + if num_9__ GHC.Base.== #0 : bool + then GHC.Base.return_ Data.ByteString.Lazy.Internal.Empty else + let 'm := scrut_8__ in + readChunks (i GHC.Num.- m) GHC.Base.>>= + (fun cs => GHC.Base.return_ (Data.ByteString.Lazy.Internal.Chunk c cs))) in + if n GHC.Base.> #0 : bool then readChunks n else + j_7__ + end. + +Definition hGetNonBlockingN + : GHC.Num.Int -> + GHC.IO.Handle.Types.Handle -> + GHC.Num.Int -> GHC.Types.IO Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ arg_1__ arg_2__ => + match arg_0__, arg_1__, arg_2__ with + | k, h, n => + let j_5__ := + match arg_0__, arg_1__, arg_2__ with + | _, h, n => illegalBufferSize h (GHC.Base.hs_string__ "hGetNonBlocking") n + end in + let j_7__ := + match arg_0__, arg_1__, arg_2__ with + | _, _, num_3__ => + if num_3__ GHC.Base.== #0 : bool + then GHC.Base.return_ Data.ByteString.Lazy.Internal.Empty else + j_5__ + end in + let fix readChunks i + := Data.ByteString.hGetNonBlocking h (GHC.Base.min k i) GHC.Base.>>= + (fun c => + let scrut_8__ := Data.ByteString.length c in + let 'num_9__ := scrut_8__ in + if num_9__ GHC.Base.== #0 : bool + then GHC.Base.return_ Data.ByteString.Lazy.Internal.Empty else + let 'm := scrut_8__ in + readChunks (i GHC.Num.- m) GHC.Base.>>= + (fun cs => GHC.Base.return_ (Data.ByteString.Lazy.Internal.Chunk c cs))) in + if n GHC.Base.> #0 : bool then readChunks n else + j_7__ + end. + +Definition hGetContents + : GHC.IO.Handle.Types.Handle -> + GHC.Types.IO Data.ByteString.Lazy.Internal.ByteString := + hGetContentsN Data.ByteString.Lazy.Internal.defaultChunkSize. + +Definition hGet + : GHC.IO.Handle.Types.Handle -> + GHC.Num.Int -> GHC.Types.IO Data.ByteString.Lazy.Internal.ByteString := + hGetN Data.ByteString.Lazy.Internal.defaultChunkSize. + +Definition hGetNonBlocking + : GHC.IO.Handle.Types.Handle -> + GHC.Num.Int -> GHC.Types.IO Data.ByteString.Lazy.Internal.ByteString := + hGetNonBlockingN Data.ByteString.Lazy.Internal.defaultChunkSize. + +Definition readFile + : GHC.Base.String -> GHC.Types.IO Data.ByteString.Lazy.Internal.ByteString := + fun f => + GHC.IO.Handle.FD.openBinaryFile f GHC.IO.IOMode.ReadMode GHC.Base.>>= + hGetContents. + +Definition hPut + : GHC.IO.Handle.Types.Handle -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Types.IO unit := + fun h => + Data.ByteString.Lazy.Internal.foldrChunks (fun c rest => + Data.ByteString.hPut h c GHC.Base.>> rest) (GHC.Base.return_ tt). + +Definition modifyFile + : GHC.IO.IOMode.IOMode -> + GHC.Base.String -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Types.IO unit := + fun mode f txt => + System.IO.withBinaryFile f mode (fun arg_0__ => hPut arg_0__ txt). + +Definition writeFile + : GHC.Base.String -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Types.IO unit := + modifyFile GHC.IO.IOMode.WriteMode. + +Definition appendFile + : GHC.Base.String -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Types.IO unit := + modifyFile GHC.IO.IOMode.AppendMode. + +Definition getContents + : GHC.Types.IO Data.ByteString.Lazy.Internal.ByteString := + hGetContents GHC.IO.Handle.FD.stdin. + +Fixpoint hPutNonBlocking (arg_0__ : GHC.IO.Handle.Types.Handle) (arg_1__ + : Data.ByteString.Lazy.Internal.ByteString) : GHC.Types.IO + Data.ByteString.Lazy.Internal.ByteString + := match arg_0__, arg_1__ with + | _, Data.ByteString.Lazy.Internal.Empty => + GHC.Base.return_ Data.ByteString.Lazy.Internal.Empty + | h, (Data.ByteString.Lazy.Internal.Chunk c cs as bs) => + Data.ByteString.hPutNonBlocking h c GHC.Base.>>= + (fun c' => + let scrut_3__ := Data.ByteString.length c' in + let 'l' := scrut_3__ in + if l' GHC.Base.== Data.ByteString.length c : bool then hPutNonBlocking h cs else + let 'num_4__ := scrut_3__ in + if num_4__ GHC.Base.== #0 : bool then GHC.Base.return_ bs else + GHC.Base.return_ (Data.ByteString.Lazy.Internal.Chunk c' cs)) + end. + +Definition hPutStr + : GHC.IO.Handle.Types.Handle -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Types.IO unit := + hPut. + +Definition putStr + : Data.ByteString.Lazy.Internal.ByteString -> GHC.Types.IO unit := + hPut GHC.IO.Handle.FD.stdout. + +Definition interact + : (Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString) -> + GHC.Types.IO unit := + fun transformer => (putStr GHC.Base.∘ transformer) GHC.Base.=<< getContents. + +Module Notations. +Notation "'_Data.ByteString.Lazy.!?_'" := (op_znz3fU__). +Infix "Data.ByteString.Lazy.!?" := (_!?_) (at level 99). +End Notations. + +(* External variables: + Eq Gt Lt None Some Type andb bool comparison cons false list negb nil op_zt__ + option orb pair true tt unit Coq.Init.Datatypes.app Data.Bifunctor.first + Data.ByteString.all Data.ByteString.any Data.ByteString.breakEnd + Data.ByteString.cons_ Data.ByteString.copy Data.ByteString.count + Data.ByteString.drop Data.ByteString.dropEnd Data.ByteString.dropWhileEnd + Data.ByteString.elemIndex Data.ByteString.elemIndices Data.ByteString.filter + Data.ByteString.find Data.ByteString.findIndex Data.ByteString.findIndexEnd + Data.ByteString.findIndices Data.ByteString.foldl Data.ByteString.foldl' + Data.ByteString.foldr Data.ByteString.foldr' Data.ByteString.foldr1 + Data.ByteString.foldr1' Data.ByteString.hGet Data.ByteString.hGetNonBlocking + Data.ByteString.hPut Data.ByteString.hPutNonBlocking Data.ByteString.inits + Data.ByteString.intersperse Data.ByteString.last Data.ByteString.length + Data.ByteString.map Data.ByteString.mapAccumL Data.ByteString.mapAccumR + Data.ByteString.maximum Data.ByteString.minimum Data.ByteString.null + Data.ByteString.pack Data.ByteString.packZipWith Data.ByteString.partition + Data.ByteString.replicate Data.ByteString.reverse Data.ByteString.singleton + Data.ByteString.split Data.ByteString.splitAt Data.ByteString.splitWith + Data.ByteString.stripPrefix Data.ByteString.take Data.ByteString.takeEnd + Data.ByteString.takeWhileEnd Data.ByteString.unfoldrN + Data.ByteString.Internal.BS Data.ByteString.Internal.ByteString + Data.ByteString.Internal.c_intersperse + Data.ByteString.Internal.findIndexOrLength Data.ByteString.Internal.unsafeCreate + Data.ByteString.Internal.unsafeWithForeignPtr + Data.ByteString.Lazy.Internal.ByteString Data.ByteString.Lazy.Internal.Chunk + Data.ByteString.Lazy.Internal.Empty Data.ByteString.Lazy.Internal.chunk + Data.ByteString.Lazy.Internal.defaultChunkSize + Data.ByteString.Lazy.Internal.foldlChunks + Data.ByteString.Lazy.Internal.foldrChunks + Data.ByteString.Lazy.Internal.fromStrict Data.ByteString.Lazy.Internal.packBytes + Data.ByteString.Lazy.Internal.smallChunkSize + Data.ByteString.Lazy.Internal.unpackBytes + Data.ByteString.Lazy.Internal.Deque.Deque + Data.ByteString.Lazy.Internal.Deque.byteLength + Data.ByteString.Lazy.Internal.Deque.empty + Data.ByteString.Lazy.Internal.Deque.front + Data.ByteString.Lazy.Internal.Deque.popFront + Data.ByteString.Lazy.Internal.Deque.popRear + Data.ByteString.Lazy.Internal.Deque.rear + Data.ByteString.Lazy.Internal.Deque.snoc Data.ByteString.Unsafe.unsafeDrop + Data.ByteString.Unsafe.unsafeHead Data.ByteString.Unsafe.unsafeIndex + Data.ByteString.Unsafe.unsafeInit Data.ByteString.Unsafe.unsafeLast + Data.ByteString.Unsafe.unsafeTail Data.ByteString.Unsafe.unsafeTake + Data.Foldable.foldl Data.Foldable.foldl' Data.Foldable.foldr + Data.Functor.op_zlzdzg__ Data.OldList.intersperse Data.OldList.transpose + Data.Tuple.fst Data.Tuple.snd Data.Tuple.uncurry Foreign.Storable.poke + GHC.Base.String GHC.Base.compare GHC.Base.flip GHC.Base.fmap GHC.Base.map + GHC.Base.mappend GHC.Base.max GHC.Base.mconcat GHC.Base.min GHC.Base.mplus + GHC.Base.op_z2218U__ GHC.Base.op_zeze__ GHC.Base.op_zezlzl__ GHC.Base.op_zg__ + GHC.Base.op_zgze__ GHC.Base.op_zgzg__ GHC.Base.op_zgzgze__ GHC.Base.op_zl__ + GHC.Base.op_zlze__ GHC.Base.op_zsze__ GHC.Base.return_ GHC.Err.error + GHC.Err.patternFailure GHC.IO.Exception.ioError GHC.IO.Handle.FD.openBinaryFile + GHC.IO.Handle.FD.stdin GHC.IO.Handle.FD.stdout GHC.IO.Handle.Types.Handle + GHC.IO.IOMode.AppendMode GHC.IO.IOMode.IOMode GHC.IO.IOMode.ReadMode + GHC.IO.IOMode.WriteMode GHC.Int.Int64 GHC.List.tail GHC.Num.Int + GHC.Num.fromInteger GHC.Num.op_zm__ GHC.Num.op_zp__ GHC.Num.op_zt__ + GHC.Ptr.plusPtr GHC.Real.fromIntegral GHC.Real.quotRem GHC.Show.show + GHC.Show.showsPrec GHC.Tuple.pair2 GHC.Types.IO GHC.Word.Word8 + System.IO.withBinaryFile System.IO.Error.illegalOperationErrorType + System.IO.Error.mkIOError +*) diff --git a/examples/bytestring/lib/Data/ByteString/Lazy/Char8.h2ci b/examples/bytestring/lib/Data/ByteString/Lazy/Char8.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Lazy/Char8.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString/Lazy/Char8.v b/examples/bytestring/lib/Data/ByteString/Lazy/Char8.v new file mode 100644 index 000000000..b1eb23359 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Lazy/Char8.v @@ -0,0 +1,866 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.ByteString. +Require Data.ByteString.Internal. +Require Data.ByteString.Lazy. +Require Data.ByteString.Lazy.Internal. +Require Data.ByteString.Unsafe. +Require Data.Foldable. +Require Data.Functor. +Require Data.OldList. +Require Data.Tuple. +Require GHC.Base. +Require GHC.Char. +Require GHC.List. +Require GHC.Num. +Require GHC.Real. +Import Data.Functor.Notations. +Import GHC.Base.Notations. +Import GHC.Num.Notations. +Import GHC.Real.Notations. + +(* No type declarations to convert. *) + +(* Converted value declarations: *) + +Definition singleton + : GHC.Char.Char -> Data.ByteString.Lazy.Internal.ByteString := + Data.ByteString.Lazy.singleton GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition pack + : list GHC.Char.Char -> Data.ByteString.Lazy.Internal.ByteString := + Data.ByteString.Lazy.Internal.packChars. + +Definition unpack + : Data.ByteString.Lazy.Internal.ByteString -> list GHC.Char.Char := + Data.ByteString.Lazy.Internal.unpackChars. + +Definition cons_ + : GHC.Char.Char -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + Data.ByteString.Lazy.cons_ GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition cons' + : GHC.Char.Char -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + Data.ByteString.Lazy.cons' GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition snoc + : Data.ByteString.Lazy.Internal.ByteString -> + GHC.Char.Char -> Data.ByteString.Lazy.Internal.ByteString := + fun p => Data.ByteString.Lazy.snoc p GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition head : Data.ByteString.Lazy.Internal.ByteString -> GHC.Char.Char := + Data.ByteString.Internal.w2c GHC.Base.∘ Data.ByteString.Lazy.head. + +Definition uncons + : Data.ByteString.Lazy.Internal.ByteString -> + option (GHC.Char.Char * Data.ByteString.Lazy.Internal.ByteString)%type := + fun bs => + match Data.ByteString.Lazy.uncons bs with + | None => None + | Some (pair w bs') => Some (pair (Data.ByteString.Internal.w2c w) bs') + end. + +Definition unsnoc + : Data.ByteString.Lazy.Internal.ByteString -> + option (Data.ByteString.Lazy.Internal.ByteString * GHC.Char.Char)%type := + fun bs => + match Data.ByteString.Lazy.unsnoc bs with + | None => None + | Some (pair bs' w) => Some (pair bs' (Data.ByteString.Internal.w2c w)) + end. + +Definition last : Data.ByteString.Lazy.Internal.ByteString -> GHC.Char.Char := + Data.ByteString.Internal.w2c GHC.Base.∘ Data.ByteString.Lazy.last. + +Definition map + : (GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + Data.ByteString.Lazy.map (Data.ByteString.Internal.c2w GHC.Base.∘ + (f GHC.Base.∘ Data.ByteString.Internal.w2c)). + +Definition intersperse + : GHC.Char.Char -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + Data.ByteString.Lazy.intersperse GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition foldl {a : Type} + : (a -> GHC.Char.Char -> a) -> + a -> Data.ByteString.Lazy.Internal.ByteString -> a := + fun f => + Data.ByteString.Lazy.foldl (fun a c => f a (Data.ByteString.Internal.w2c c)). + +Definition foldl' {a : Type} + : (a -> GHC.Char.Char -> a) -> + a -> Data.ByteString.Lazy.Internal.ByteString -> a := + fun f => + Data.ByteString.Lazy.foldl' (fun a c => f a (Data.ByteString.Internal.w2c c)). + +Definition foldr {a : Type} + : (GHC.Char.Char -> a -> a) -> + a -> Data.ByteString.Lazy.Internal.ByteString -> a := + fun f => Data.ByteString.Lazy.foldr (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition foldr' {a : Type} + : (GHC.Char.Char -> a -> a) -> + a -> Data.ByteString.Lazy.Internal.ByteString -> a := + fun f => + Data.ByteString.Lazy.foldr' (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition foldl1 + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Char.Char := + fun f ps => + Data.ByteString.Internal.w2c (Data.ByteString.Lazy.foldl1 (fun x y => + Data.ByteString.Internal.c2w (f + (Data.ByteString.Internal.w2c + x) + (Data.ByteString.Internal.w2c + y))) ps). + +Definition foldl1' + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Char.Char := + fun f ps => + Data.ByteString.Internal.w2c (Data.ByteString.Lazy.foldl1' (fun x y => + Data.ByteString.Internal.c2w (f + (Data.ByteString.Internal.w2c + x) + (Data.ByteString.Internal.w2c + y))) ps). + +Definition foldr1 + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Char.Char := + fun f ps => + Data.ByteString.Internal.w2c (Data.ByteString.Lazy.foldr1 (fun x y => + Data.ByteString.Internal.c2w (f + (Data.ByteString.Internal.w2c + x) + (Data.ByteString.Internal.w2c + y))) ps). + +Definition foldr1' + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Char.Char := + fun f ps => + Data.ByteString.Internal.w2c (Data.ByteString.Lazy.foldr1' (fun x y => + Data.ByteString.Internal.c2w (f + (Data.ByteString.Internal.w2c + x) + (Data.ByteString.Internal.w2c + y))) ps). + +Definition concatMap + : (GHC.Char.Char -> Data.ByteString.Lazy.Internal.ByteString) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + Data.ByteString.Lazy.concatMap (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition any + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> bool := + fun f => Data.ByteString.Lazy.any (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition all + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> bool := + fun f => Data.ByteString.Lazy.all (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition maximum + : Data.ByteString.Lazy.Internal.ByteString -> GHC.Char.Char := + Data.ByteString.Internal.w2c GHC.Base.∘ Data.ByteString.Lazy.maximum. + +Definition minimum + : Data.ByteString.Lazy.Internal.ByteString -> GHC.Char.Char := + Data.ByteString.Internal.w2c GHC.Base.∘ Data.ByteString.Lazy.minimum. + +Definition scanl + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + GHC.Char.Char -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f z => + Data.ByteString.Lazy.scanl (fun a b => + Data.ByteString.Internal.c2w (f (Data.ByteString.Internal.w2c a) + (Data.ByteString.Internal.w2c b))) + (Data.ByteString.Internal.c2w z). + +Definition scanl1 + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + let f' := + fun accumulator value => + Data.ByteString.Internal.c2w (f (Data.ByteString.Internal.w2c accumulator) + (Data.ByteString.Internal.w2c value)) in + Data.ByteString.Lazy.scanl1 f'. + +Definition scanr + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + GHC.Char.Char -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + let f' := + fun accumulator value => + Data.ByteString.Internal.c2w (f (Data.ByteString.Internal.w2c accumulator) + (Data.ByteString.Internal.w2c value)) in + Data.ByteString.Lazy.scanr f' GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition scanr1 + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + let f' := + fun accumulator value => + Data.ByteString.Internal.c2w (f (Data.ByteString.Internal.w2c accumulator) + (Data.ByteString.Internal.w2c value)) in + Data.ByteString.Lazy.scanr1 f'. + +Definition mapAccumL {acc : Type} + : (acc -> GHC.Char.Char -> (acc * GHC.Char.Char)%type) -> + acc -> + Data.ByteString.Lazy.Internal.ByteString -> + (acc * Data.ByteString.Lazy.Internal.ByteString)%type := + fun f => + Data.ByteString.Lazy.mapAccumL (fun a w => + let 'pair a' c := f a (Data.ByteString.Internal.w2c w) in + pair a' (Data.ByteString.Internal.c2w c)). + +Definition mapAccumR {acc : Type} + : (acc -> GHC.Char.Char -> (acc * GHC.Char.Char)%type) -> + acc -> + Data.ByteString.Lazy.Internal.ByteString -> + (acc * Data.ByteString.Lazy.Internal.ByteString)%type := + fun f => + Data.ByteString.Lazy.mapAccumR (fun acc w => + let 'pair acc' c := f acc (Data.ByteString.Internal.w2c w) in + pair acc' (Data.ByteString.Internal.c2w c)). + +Definition iterate + : (GHC.Char.Char -> GHC.Char.Char) -> + GHC.Char.Char -> Data.ByteString.Lazy.Internal.ByteString := + fun f => + Data.ByteString.Lazy.iterate (Data.ByteString.Internal.c2w GHC.Base.∘ + (f GHC.Base.∘ Data.ByteString.Internal.w2c)) GHC.Base.∘ + Data.ByteString.Internal.c2w. + +Definition repeat : GHC.Char.Char -> Data.ByteString.Lazy.Internal.ByteString := + Data.ByteString.Lazy.repeat GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition replicate + : GHC.Int.Int64 -> GHC.Char.Char -> Data.ByteString.Lazy.Internal.ByteString := + fun w c => Data.ByteString.Lazy.replicate w (Data.ByteString.Internal.c2w c). + +Definition unfoldr {a : Type} + : (a -> option (GHC.Char.Char * a)%type) -> + a -> Data.ByteString.Lazy.Internal.ByteString := + fun f => + Data.ByteString.Lazy.unfoldr (fun a => + match f a with + | None => None + | Some (pair c a') => Some (pair (Data.ByteString.Internal.c2w c) a') + end). + +Definition takeWhile + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + Data.ByteString.Lazy.takeWhile (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition takeWhileEnd + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + Data.ByteString.Lazy.takeWhileEnd (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition dropWhile + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + Data.ByteString.Lazy.dropWhile (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition dropWhileEnd + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + Data.ByteString.Lazy.dropWhileEnd (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition break + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun f => Data.ByteString.Lazy.break (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition breakEnd + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun f => + Data.ByteString.Lazy.breakEnd (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition span + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun f => Data.ByteString.Lazy.span (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition spanEnd + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun f => + Data.ByteString.Lazy.spanEnd (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition split + : GHC.Char.Char -> + Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + Data.ByteString.Lazy.split GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition splitWith + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + fun f => + Data.ByteString.Lazy.splitWith (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition groupBy + : (GHC.Char.Char -> GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + fun k => + Data.ByteString.Lazy.groupBy (fun a b => + k (Data.ByteString.Internal.w2c a) (Data.ByteString.Internal.w2c b)). + +Definition index + : Data.ByteString.Lazy.Internal.ByteString -> GHC.Int.Int64 -> GHC.Char.Char := + (fun arg_0__ => Data.ByteString.Internal.w2c GHC.Base.∘ arg_0__) GHC.Base.∘ + Data.ByteString.Lazy.index. + +Definition indexMaybe + : Data.ByteString.Lazy.Internal.ByteString -> + GHC.Int.Int64 -> option GHC.Char.Char := + (fun arg_0__ => GHC.Base.fmap Data.ByteString.Internal.w2c GHC.Base.∘ arg_0__) + GHC.Base.∘ + Data.ByteString.Lazy.indexMaybe. + +Definition op_znz3fU__ + : Data.ByteString.Lazy.Internal.ByteString -> + GHC.Int.Int64 -> option GHC.Char.Char := + indexMaybe. + +Notation "'_!?_'" := (op_znz3fU__). + +Infix "!?" := (_!?_) (at level 99). + +Definition elemIndex + : GHC.Char.Char -> + Data.ByteString.Lazy.Internal.ByteString -> option GHC.Int.Int64 := + Data.ByteString.Lazy.elemIndex GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition elemIndexEnd + : GHC.Char.Char -> + Data.ByteString.Lazy.Internal.ByteString -> option GHC.Int.Int64 := + Data.ByteString.Lazy.elemIndexEnd GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition elemIndices + : GHC.Char.Char -> + Data.ByteString.Lazy.Internal.ByteString -> list GHC.Int.Int64 := + Data.ByteString.Lazy.elemIndices GHC.Base.∘ Data.ByteString.Internal.c2w. + +Definition findIndex + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> option GHC.Int.Int64 := + fun f => + Data.ByteString.Lazy.findIndex (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition findIndexEnd + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> option GHC.Int.Int64 := + fun f => + Data.ByteString.Lazy.findIndexEnd (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition findIndices + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> list GHC.Int.Int64 := + fun f => + Data.ByteString.Lazy.findIndices (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition count + : GHC.Char.Char -> Data.ByteString.Lazy.Internal.ByteString -> GHC.Int.Int64 := + fun c => Data.ByteString.Lazy.count (Data.ByteString.Internal.c2w c). + +Definition elem + : GHC.Char.Char -> Data.ByteString.Lazy.Internal.ByteString -> bool := + fun c => Data.ByteString.Lazy.elem (Data.ByteString.Internal.c2w c). + +Definition notElem + : GHC.Char.Char -> Data.ByteString.Lazy.Internal.ByteString -> bool := + fun c => Data.ByteString.Lazy.notElem (Data.ByteString.Internal.c2w c). + +Definition filter + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + Data.ByteString.Lazy.filter (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition partition + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun f => + Data.ByteString.Lazy.partition (f GHC.Base.∘ Data.ByteString.Internal.w2c). + +Definition find + : (GHC.Char.Char -> bool) -> + Data.ByteString.Lazy.Internal.ByteString -> option GHC.Char.Char := + fun f ps => + GHC.Base.fmap Data.ByteString.Internal.w2c (Data.ByteString.Lazy.find (f + GHC.Base.∘ + Data.ByteString.Internal.w2c) ps). + +Fixpoint zip (ps qs : Data.ByteString.Lazy.Internal.ByteString) : list + (GHC.Char.Char * GHC.Char.Char)%type + := if orb (Data.ByteString.Lazy.null ps) (Data.ByteString.Lazy.null qs) : bool + then nil else + cons (pair (head ps) (head qs)) (zip (Data.ByteString.Lazy.tail ps) + (Data.ByteString.Lazy.tail qs)). + +Definition zipWith {a : Type} + : (GHC.Char.Char -> GHC.Char.Char -> a) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> list a := + fun f => + Data.ByteString.Lazy.zipWith ((fun arg_0__ => + arg_0__ GHC.Base.∘ Data.ByteString.Internal.w2c) GHC.Base.∘ + (f GHC.Base.∘ Data.ByteString.Internal.w2c)). + +Definition packZipWith + : (GHC.Char.Char -> GHC.Char.Char -> GHC.Char.Char) -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun f => + let f' := + fun c1 c2 => + Data.ByteString.Internal.c2w (f (Data.ByteString.Internal.w2c c1) + (Data.ByteString.Internal.w2c c2)) in + Data.ByteString.Lazy.packZipWith f'. + +Definition unzip + : list (GHC.Char.Char * GHC.Char.Char)%type -> + (Data.ByteString.Lazy.Internal.ByteString * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun ls => + pair (pack (GHC.Base.fmap Data.Tuple.fst ls)) (pack (GHC.Base.fmap + Data.Tuple.snd ls)). + +Definition revChunks + : list Data.ByteString.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + Data.Foldable.foldl' (GHC.Base.flip Data.ByteString.Lazy.Internal.chunk) + Data.ByteString.Lazy.Internal.Empty. + +Definition lines + : Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => nil + | Data.ByteString.Lazy.Internal.Chunk c0 cs0 => + let loop0 + : Data.ByteString.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + fix loop (c : Data.ByteString.Internal.ByteString) (line + : list Data.ByteString.Internal.ByteString) (cs + : Data.ByteString.Lazy.Internal.ByteString) : list + Data.ByteString.Lazy.Internal.ByteString + := match Data.ByteString.elemIndex (Data.ByteString.Internal.c2w + (GHC.Char.hs_char__ "")) c with + | None => + match cs with + | Data.ByteString.Lazy.Internal.Empty => + let c' := revChunks (cons c line) in cons c' nil + | Data.ByteString.Lazy.Internal.Chunk c' cs' => loop c' (cons c line) cs' + end + | Some n => + let c' := revChunks (cons (Data.ByteString.Unsafe.unsafeTake n c) line) in + cons c' (loop0 (Data.ByteString.Unsafe.unsafeDrop (n GHC.Num.+ #1) c) cs) + end + with loop0 (c : Data.ByteString.Internal.ByteString) (cs + : Data.ByteString.Lazy.Internal.ByteString) : list + Data.ByteString.Lazy.Internal.ByteString + := match Data.ByteString.elemIndex (Data.ByteString.Internal.c2w + (GHC.Char.hs_char__ "")) c with + | None => + match cs with + | Data.ByteString.Lazy.Internal.Empty => + if Data.ByteString.null c : bool then nil else + cons (Data.ByteString.Lazy.Internal.Chunk c Data.ByteString.Lazy.Internal.Empty) + nil + | Data.ByteString.Lazy.Internal.Chunk c' cs' => + if Data.ByteString.null c : bool then loop0 c' cs' else + loop c' (cons c nil) cs' + end + | Some n => + if n GHC.Base./= #0 : bool + then cons (Data.ByteString.Lazy.Internal.Chunk + (Data.ByteString.Unsafe.unsafeTake n c) Data.ByteString.Lazy.Internal.Empty) + (loop0 (Data.ByteString.Unsafe.unsafeDrop (n GHC.Num.+ #1) c) cs) else + cons Data.ByteString.Lazy.Internal.Empty (loop0 + (Data.ByteString.Unsafe.unsafeTail c) cs) + end for loop0 in + let loop + : Data.ByteString.Internal.ByteString -> + list Data.ByteString.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + fix loop (c : Data.ByteString.Internal.ByteString) (line + : list Data.ByteString.Internal.ByteString) (cs + : Data.ByteString.Lazy.Internal.ByteString) : list + Data.ByteString.Lazy.Internal.ByteString + := match Data.ByteString.elemIndex (Data.ByteString.Internal.c2w + (GHC.Char.hs_char__ "")) c with + | None => + match cs with + | Data.ByteString.Lazy.Internal.Empty => + let c' := revChunks (cons c line) in cons c' nil + | Data.ByteString.Lazy.Internal.Chunk c' cs' => loop c' (cons c line) cs' + end + | Some n => + let c' := revChunks (cons (Data.ByteString.Unsafe.unsafeTake n c) line) in + cons c' (loop0 (Data.ByteString.Unsafe.unsafeDrop (n GHC.Num.+ #1) c) cs) + end + with loop0 (c : Data.ByteString.Internal.ByteString) (cs + : Data.ByteString.Lazy.Internal.ByteString) : list + Data.ByteString.Lazy.Internal.ByteString + := match Data.ByteString.elemIndex (Data.ByteString.Internal.c2w + (GHC.Char.hs_char__ "")) c with + | None => + match cs with + | Data.ByteString.Lazy.Internal.Empty => + if Data.ByteString.null c : bool then nil else + cons (Data.ByteString.Lazy.Internal.Chunk c Data.ByteString.Lazy.Internal.Empty) + nil + | Data.ByteString.Lazy.Internal.Chunk c' cs' => + if Data.ByteString.null c : bool then loop0 c' cs' else + loop c' (cons c nil) cs' + end + | Some n => + if n GHC.Base./= #0 : bool + then cons (Data.ByteString.Lazy.Internal.Chunk + (Data.ByteString.Unsafe.unsafeTake n c) Data.ByteString.Lazy.Internal.Empty) + (loop0 (Data.ByteString.Unsafe.unsafeDrop (n GHC.Num.+ #1) c) cs) else + cons Data.ByteString.Lazy.Internal.Empty (loop0 + (Data.ByteString.Unsafe.unsafeTail c) cs) + end for loop in + loop0 c0 cs0 + end. + +Definition unlines + : list Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + fun arg_0__ => + match arg_0__ with + | nil => Data.ByteString.Lazy.empty + | ss => + let nl := singleton (GHC.Char.hs_char__ "") in + Data.ByteString.Lazy.append (Data.ByteString.Lazy.concat + (Data.OldList.intersperse nl ss)) nl + end. + +Definition words + : Data.ByteString.Lazy.Internal.ByteString -> + list Data.ByteString.Lazy.Internal.ByteString := + GHC.List.filter (negb GHC.Base.∘ Data.ByteString.Lazy.null) GHC.Base.∘ + Data.ByteString.Lazy.splitWith Data.ByteString.Internal.isSpaceWord8. + +Definition unwords + : list Data.ByteString.Lazy.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString := + Data.ByteString.Lazy.intercalate (singleton (GHC.Char.hs_char__ " ")). + +Definition readInt + : Data.ByteString.Lazy.Internal.ByteString -> + option (GHC.Num.Int * Data.ByteString.Lazy.Internal.ByteString)%type := + fun bs => + let readDec := + fun positive => + let w2int := + fun n => + if positive : bool then GHC.Real.fromIntegral n else + GHC.Num.negate (GHC.Real.fromIntegral n) in + let result := + fun nbytes acc str => + if nbytes GHC.Base.> #0 : bool then let i := w2int acc in Some (pair i str) else + None in + let accumWord := + fun arg_4__ arg_5__ => + match arg_4__, arg_5__ with + | acc, Data.ByteString.Internal.BS fp len => + let digits := + fun maxq maxr e ptr => + let go + : GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Num.Int -> + GHC.Num.Word -> GHC.Types.IO (GHC.Num.Int * GHC.Num.Word * bool)%type := + fix go (arg_6__ : GHC.Ptr.Ptr GHC.Word.Word8) (arg_7__ : GHC.Num.Int) (arg_8__ + : GHC.Num.Word) : GHC.Types.IO (GHC.Num.Int * GHC.Num.Word * bool)%type + := match arg_6__, arg_7__, arg_8__ with + | p, b, a => + if p GHC.Base.== e : bool then GHC.Base.return_ (pair (pair b a) true) else + match arg_6__, arg_7__, arg_8__ with + | p, b, a => + (GHC.Real.fromIntegral Data.Functor.<$> Foreign.Storable.peek p) GHC.Base.>>= + (fun w => + let d := w GHC.Num.- #48 in + if d GHC.Base.> #9 : bool + then GHC.Base.return_ (pair (pair b a) true) + else if a GHC.Base.< maxq : bool + then go (GHC.Ptr.plusPtr p #1) (b GHC.Num.+ #1) ((a GHC.Num.* #10) GHC.Num.+ + d) + else if a GHC.Base.> maxq : bool + then GHC.Base.return_ (pair (pair b a) false) + else if d GHC.Base.<= maxr : bool + then go (GHC.Ptr.plusPtr p #1) (b GHC.Num.+ #1) ((a GHC.Num.* #10) + GHC.Num.+ + d) + else GHC.Base.return_ (pair (pair b a) false)) + end + end in + go ptr in + Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr fp (fun ptr => + let end := GHC.Ptr.plusPtr ptr len in + let cont_16__ arg_17__ := + let '(pair (pair _ _) _ as x) := arg_17__ in + GHC.Base.return_ x in + (if positive : bool + then digits Data.ByteString.Internal.intmaxQuot10 + Data.ByteString.Internal.intmaxRem10 end ptr #0 + acc + else digits Data.ByteString.Internal.intminQuot10 + Data.ByteString.Internal.intminRem10 end ptr #0 + acc) GHC.Base.>>= + cont_16__)) + end in + let fix loop nbytes acc + := fun str => + match str with + | Data.ByteString.Lazy.Internal.Empty => result nbytes acc str + | Data.ByteString.Lazy.Internal.Chunk c cs => + let scrut_22__ := Data.ByteString.length c in + let 'num_23__ := scrut_22__ in + if num_23__ GHC.Base.== #0 : bool then loop nbytes acc cs else + let 'l := scrut_22__ in + let scrut_24__ := accumWord acc c in + let 'pair (pair num_25__ _) inrange := scrut_24__ in + let j_29__ := + let 'pair (pair n a) inrange := scrut_24__ in + if negb inrange : bool then None else + if n GHC.Base.< l : bool + then result (nbytes GHC.Num.+ n) a (Data.ByteString.Lazy.Internal.Chunk + (Data.ByteString.drop n c) cs) else + loop (nbytes GHC.Num.+ n) a cs in + let j_30__ := if num_25__ GHC.Base.== #0 : bool then None else j_29__ in + if num_25__ GHC.Base.== #0 : bool + then if inrange : bool then result nbytes acc str else + j_30__ else + j_30__ + end in + loop #0 #0 in + match Data.ByteString.Lazy.uncons bs with + | Some (pair w rest) => + if (w GHC.Num.- #48) GHC.Base.<= #9 : bool then readDec true bs else + if w GHC.Base.== #45 : bool then readDec false rest else + if w GHC.Base.== #43 : bool then readDec true rest else + None + | _ => None + end. + +Definition readInteger + : Data.ByteString.Lazy.Internal.ByteString -> + option (GHC.Integer.Type.Integer * + Data.ByteString.Lazy.Internal.ByteString)%type := + fun arg_0__ => + match arg_0__ with + | Data.ByteString.Lazy.Internal.Empty => None + | Data.ByteString.Lazy.Internal.Chunk c0 cs0 => + let end := + fun n c cs => let c' := Data.ByteString.Lazy.Internal.chunk c cs in pair n c' in + let fix combine2 arg_3__ arg_4__ + := match arg_3__, arg_4__ with + | b, cons n (cons m ns) => + let t := n GHC.Num.+ (m GHC.Num.* b) in cons t (combine2 b ns) + | _, ns => ns + end in + let fix combine1 arg_8__ arg_9__ + := match arg_8__, arg_9__ with + | _, cons n nil => n + | b, ns => combine1 (b GHC.Num.* b) (combine2 b ns) + end in + let combine := + fun arg_12__ arg_13__ arg_14__ arg_15__ arg_16__ => + match arg_12__, arg_13__, arg_14__, arg_15__, arg_16__ with + | _, acc, nil, c, cs => end (GHC.Real.fromIntegral acc) c cs + | d, acc, ns, c, cs => + end (((#10 GHC.Real.^ d) GHC.Num.* combine1 #1000000000 ns) GHC.Num.+ + GHC.Real.fromIntegral acc) c cs + end in + let loop + : GHC.Num.Int -> + GHC.Num.Int -> + list GHC.Integer.Type.Integer -> + Data.ByteString.Internal.ByteString -> + Data.ByteString.Lazy.Internal.ByteString -> + (GHC.Integer.Type.Integer * Data.ByteString.Lazy.Internal.ByteString)%type := + fix loop (d acc : GHC.Num.Int) (ns : list GHC.Integer.Type.Integer) (c + : Data.ByteString.Internal.ByteString) (cs + : Data.ByteString.Lazy.Internal.ByteString) : (GHC.Integer.Type.Integer * + Data.ByteString.Lazy.Internal.ByteString)%type + := if Data.ByteString.null c : bool + then match cs with + | Data.ByteString.Lazy.Internal.Empty => combine d acc ns c cs + | Data.ByteString.Lazy.Internal.Chunk c' cs' => loop d acc ns c' cs' + end else + let 'w := Data.ByteString.Unsafe.unsafeHead c in + if andb (w GHC.Base.>= #48) (w GHC.Base.<= #57) : bool + then if d GHC.Base.< #9 : bool + then loop (d GHC.Num.+ #1) ((#10 GHC.Num.* acc) GHC.Num.+ + (GHC.Real.fromIntegral w GHC.Num.- #48)) ns + (Data.ByteString.Unsafe.unsafeTail c) cs + else loop #1 (GHC.Real.fromIntegral w GHC.Num.- #48) (cons + (GHC.Real.fromIntegral acc) ns) + (Data.ByteString.Unsafe.unsafeTail c) cs else + combine d acc ns c cs in + let first' := + fun c cs => + let 'w := Data.ByteString.Unsafe.unsafeHead c in + if andb (w GHC.Base.>= #48) (w GHC.Base.<= #57) : bool + then Some (loop #1 (GHC.Real.fromIntegral w GHC.Num.- #48) nil + (Data.ByteString.Unsafe.unsafeTail c) cs) else + None in + let first := + fun c cs => + if Data.ByteString.null c : bool + then match cs with + | Data.ByteString.Lazy.Internal.Empty => None + | Data.ByteString.Lazy.Internal.Chunk c' cs' => first' c' cs' + end else + first' c cs in + match Data.ByteString.Internal.w2c (Data.ByteString.Unsafe.unsafeHead c0) with + | ("-"%char) => + first (Data.ByteString.Unsafe.unsafeTail c0) cs0 GHC.Base.>>= + (fun '(pair n cs') => GHC.Base.return_ (pair (GHC.Num.negate n) cs')) + | ("+"%char) => first (Data.ByteString.Unsafe.unsafeTail c0) cs0 + | _ => first c0 cs0 + end + end. + +Definition hPutStrLn + : GHC.IO.Handle.Types.Handle -> + Data.ByteString.Lazy.Internal.ByteString -> GHC.Types.IO unit := + fun h ps => + Data.ByteString.Lazy.hPut h ps GHC.Base.>> + Data.ByteString.Lazy.hPut h (Data.ByteString.Lazy.singleton #10). + +Definition putStrLn + : Data.ByteString.Lazy.Internal.ByteString -> GHC.Types.IO unit := + hPutStrLn GHC.IO.Handle.FD.stdout. + +Module Notations. +Notation "'_Data.ByteString.Lazy.Char8.!?_'" := (op_znz3fU__). +Infix "Data.ByteString.Lazy.Char8.!?" := (_!?_) (at level 99). +End Notations. + +(* External variables: + None Some Type andb bool cons false list negb nil op_zt__ option orb pair true + unit Data.ByteString.drop Data.ByteString.elemIndex Data.ByteString.length + Data.ByteString.null Data.ByteString.Internal.BS + Data.ByteString.Internal.ByteString + Data.ByteString.Internal.accursedUnutterablePerformIO + Data.ByteString.Internal.c2w Data.ByteString.Internal.intmaxQuot10 + Data.ByteString.Internal.intmaxRem10 Data.ByteString.Internal.intminQuot10 + Data.ByteString.Internal.intminRem10 Data.ByteString.Internal.isSpaceWord8 + Data.ByteString.Internal.unsafeWithForeignPtr Data.ByteString.Internal.w2c + Data.ByteString.Lazy.all Data.ByteString.Lazy.any Data.ByteString.Lazy.append + Data.ByteString.Lazy.break Data.ByteString.Lazy.breakEnd + Data.ByteString.Lazy.concat Data.ByteString.Lazy.concatMap + Data.ByteString.Lazy.cons' Data.ByteString.Lazy.cons_ Data.ByteString.Lazy.count + Data.ByteString.Lazy.dropWhile Data.ByteString.Lazy.dropWhileEnd + Data.ByteString.Lazy.elem Data.ByteString.Lazy.elemIndex + Data.ByteString.Lazy.elemIndexEnd Data.ByteString.Lazy.elemIndices + Data.ByteString.Lazy.empty Data.ByteString.Lazy.filter Data.ByteString.Lazy.find + Data.ByteString.Lazy.findIndex Data.ByteString.Lazy.findIndexEnd + Data.ByteString.Lazy.findIndices Data.ByteString.Lazy.foldl + Data.ByteString.Lazy.foldl' Data.ByteString.Lazy.foldl1 + Data.ByteString.Lazy.foldl1' Data.ByteString.Lazy.foldr + Data.ByteString.Lazy.foldr' Data.ByteString.Lazy.foldr1 + Data.ByteString.Lazy.foldr1' Data.ByteString.Lazy.groupBy + Data.ByteString.Lazy.hPut Data.ByteString.Lazy.head Data.ByteString.Lazy.index + Data.ByteString.Lazy.indexMaybe Data.ByteString.Lazy.intercalate + Data.ByteString.Lazy.intersperse Data.ByteString.Lazy.iterate + Data.ByteString.Lazy.last Data.ByteString.Lazy.map + Data.ByteString.Lazy.mapAccumL Data.ByteString.Lazy.mapAccumR + Data.ByteString.Lazy.maximum Data.ByteString.Lazy.minimum + Data.ByteString.Lazy.notElem Data.ByteString.Lazy.null + Data.ByteString.Lazy.packZipWith Data.ByteString.Lazy.partition + Data.ByteString.Lazy.repeat Data.ByteString.Lazy.replicate + Data.ByteString.Lazy.scanl Data.ByteString.Lazy.scanl1 + Data.ByteString.Lazy.scanr Data.ByteString.Lazy.scanr1 + Data.ByteString.Lazy.singleton Data.ByteString.Lazy.snoc + Data.ByteString.Lazy.span Data.ByteString.Lazy.spanEnd + Data.ByteString.Lazy.split Data.ByteString.Lazy.splitWith + Data.ByteString.Lazy.tail Data.ByteString.Lazy.takeWhile + Data.ByteString.Lazy.takeWhileEnd Data.ByteString.Lazy.uncons + Data.ByteString.Lazy.unfoldr Data.ByteString.Lazy.unsnoc + Data.ByteString.Lazy.zipWith Data.ByteString.Lazy.Internal.ByteString + Data.ByteString.Lazy.Internal.Chunk Data.ByteString.Lazy.Internal.Empty + Data.ByteString.Lazy.Internal.chunk Data.ByteString.Lazy.Internal.packChars + Data.ByteString.Lazy.Internal.unpackChars Data.ByteString.Unsafe.unsafeDrop + Data.ByteString.Unsafe.unsafeHead Data.ByteString.Unsafe.unsafeTail + Data.ByteString.Unsafe.unsafeTake Data.Foldable.foldl' Data.Functor.op_zlzdzg__ + Data.OldList.intersperse Data.Tuple.fst Data.Tuple.snd Foreign.Storable.peek + GHC.Base.flip GHC.Base.fmap GHC.Base.op_z2218U__ GHC.Base.op_zeze__ + GHC.Base.op_zg__ GHC.Base.op_zgze__ GHC.Base.op_zgzg__ GHC.Base.op_zgzgze__ + GHC.Base.op_zl__ GHC.Base.op_zlze__ GHC.Base.op_zsze__ GHC.Base.return_ + GHC.Char.Char GHC.IO.Handle.FD.stdout GHC.IO.Handle.Types.Handle GHC.Int.Int64 + GHC.Integer.Type.Integer GHC.List.filter GHC.Num.Int GHC.Num.Word + GHC.Num.fromInteger GHC.Num.negate GHC.Num.op_zm__ GHC.Num.op_zp__ + GHC.Num.op_zt__ GHC.Ptr.Ptr GHC.Ptr.plusPtr GHC.Real.fromIntegral + GHC.Real.op_zc__ GHC.Types.IO GHC.Word.Word8 +*) diff --git a/examples/bytestring/lib/Data/ByteString/Lazy/Internal.h2ci b/examples/bytestring/lib/Data/ByteString/Lazy/Internal.h2ci new file mode 100644 index 000000000..90fd09a86 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Lazy/Internal.h2ci @@ -0,0 +1,9 @@ +constructors: + Data.ByteString.Lazy.Internal.ByteString: ! '[Qualified "Data.ByteString.Lazy.Internal" + "Empty",Qualified "Data.ByteString.Lazy.Internal" "Chunk"]' +constructorFields: + Data.ByteString.Lazy.Internal.Chunk: NonRecordFields 2 + Data.ByteString.Lazy.Internal.Empty: NonRecordFields 0 +constructorTypes: + Data.ByteString.Lazy.Internal.Chunk: Qualified "Data.ByteString.Lazy.Internal" "ByteString" + Data.ByteString.Lazy.Internal.Empty: Qualified "Data.ByteString.Lazy.Internal" "ByteString" diff --git a/examples/bytestring/lib/Data/ByteString/Lazy/Internal.v b/examples/bytestring/lib/Data/ByteString/Lazy/Internal.v new file mode 100644 index 000000000..c362d4432 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Lazy/Internal.v @@ -0,0 +1,112 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.ByteString.Internal. +Require GHC.Base. +Require GHC.Char. +Require GHC.Num. +Require GHC.Real. +Require HsToCoq.Err. + +(* Converted type declarations: *) + +Inductive ByteString : Type := + | Empty : ByteString + | Chunk : Data.ByteString.Internal.ByteString -> ByteString -> ByteString. + +Definition LazyByteString := + ByteString%type. + +Instance Default__ByteString : HsToCoq.Err.Default ByteString := + HsToCoq.Err.Build_Default _ Empty. + +(* Converted value declarations: *) + +Instance Eq___ByteString : GHC.Base.Eq_ ByteString. +Proof. +Admitted. + +Instance Ord__ByteString : GHC.Base.Ord ByteString. +Proof. +Admitted. + +Instance Semigroup__ByteString : GHC.Base.Semigroup ByteString. +Proof. +Admitted. + +Instance Monoid__ByteString : GHC.Base.Monoid ByteString. +Proof. +Admitted. + +(* Skipping all instances of class `Control.DeepSeq.NFData', including + `Data.ByteString.Lazy.Internal.NFData__ByteString' *) + +(* Skipping all instances of class `GHC.Show.Show', including + `Data.ByteString.Lazy.Internal.Show__ByteString' *) + +(* Skipping all instances of class `GHC.Read.Read', including + `Data.ByteString.Lazy.Internal.Read__ByteString' *) + +(* Skipping all instances of class `GHC.Exts.IsList', including + `Data.ByteString.Lazy.Internal.IsList__ByteString' *) + +(* Skipping all instances of class `Data.Data.Data', including + `Data.ByteString.Lazy.Internal.Data__ByteString' *) + +Axiom packBytes : list GHC.Word.Word8 -> ByteString. + +Axiom packChars : list GHC.Char.Char -> ByteString. + +Axiom unpackBytes : ByteString -> list GHC.Word.Word8. + +Axiom unpackChars : ByteString -> list GHC.Char.Char. + +Axiom invariant : ByteString -> bool. + +Axiom checkInvariant : ByteString -> ByteString. + +Axiom chunk : Data.ByteString.Internal.ByteString -> ByteString -> ByteString. + +Axiom foldrChunks : forall {a : Type}, + (Data.ByteString.Internal.ByteString -> a -> a) -> a -> ByteString -> a. + +Axiom foldlChunks : forall {a : Type}, + (a -> Data.ByteString.Internal.ByteString -> a) -> a -> ByteString -> a. + +Axiom defaultChunkSize : GHC.Num.Int. + +Axiom smallChunkSize : GHC.Num.Int. + +Axiom chunkOverhead : GHC.Num.Int. + +Axiom eq : ByteString -> ByteString -> bool. + +Axiom cmp : ByteString -> ByteString -> comparison. + +Axiom append : ByteString -> ByteString -> ByteString. + +Axiom concat : list ByteString -> ByteString. + +Axiom times : forall {a}, + forall `{GHC.Real.Integral a}, a -> ByteString -> ByteString. + +Axiom fromStrict : Data.ByteString.Internal.ByteString -> ByteString. + +Axiom toStrict : ByteString -> Data.ByteString.Internal.ByteString. + +(* External variables: + Type bool comparison list Data.ByteString.Internal.ByteString GHC.Base.Eq_ + GHC.Base.Monoid GHC.Base.Ord GHC.Base.Semigroup GHC.Char.Char GHC.Num.Int + GHC.Real.Integral GHC.Word.Word8 HsToCoq.Err.Build_Default HsToCoq.Err.Default +*) diff --git a/examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.h2ci b/examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.h2ci new file mode 100644 index 000000000..ae8f8a9d5 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.h2ci @@ -0,0 +1,17 @@ +constructors: + Data.ByteString.Lazy.Internal.Deque.Deque: ! '[Qualified "Data.ByteString.Lazy.Internal.Deque" + "Deque"]' +constructorFields: + Data.ByteString.Lazy.Internal.Deque.Deque: RecordFields [Qualified "Data.ByteString.Lazy.Internal.Deque" + "front",Qualified "Data.ByteString.Lazy.Internal.Deque" "rear",Qualified "Data.ByteString.Lazy.Internal.Deque" + "byteLength"] +recordFieldTypes: + Data.ByteString.Lazy.Internal.Deque.rear: Qualified "Data.ByteString.Lazy.Internal.Deque" + "Deque" + Data.ByteString.Lazy.Internal.Deque.front: Qualified "Data.ByteString.Lazy.Internal.Deque" + "Deque" + Data.ByteString.Lazy.Internal.Deque.byteLength: Qualified "Data.ByteString.Lazy.Internal.Deque" + "Deque" +constructorTypes: + Data.ByteString.Lazy.Internal.Deque.Deque: Qualified "Data.ByteString.Lazy.Internal.Deque" + "Deque" diff --git a/examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.v b/examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.v new file mode 100644 index 000000000..a4285f309 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.v @@ -0,0 +1,101 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.ByteString. +Require Data.ByteString.Internal. +Require GHC.Base. +Require GHC.List. +Require GHC.Num. +Require GHC.Real. +Require HsToCoq.Err. +Import GHC.Base.Notations. +Import GHC.Num.Notations. + +(* Converted type declarations: *) + +Inductive Deque : Type := + | Deque (front : list Data.ByteString.Internal.ByteString) (rear + : list Data.ByteString.Internal.ByteString) (byteLength : GHC.Int.Int64) + : Deque. + +Instance Default__Deque : HsToCoq.Err.Default Deque := + HsToCoq.Err.Build_Default _ (Deque HsToCoq.Err.default HsToCoq.Err.default + HsToCoq.Err.default). + +Definition byteLength (arg_0__ : Deque) := + let 'Deque _ _ byteLength := arg_0__ in + byteLength. + +Definition front (arg_0__ : Deque) := + let 'Deque front _ _ := arg_0__ in + front. + +Definition rear (arg_0__ : Deque) := + let 'Deque _ rear _ := arg_0__ in + rear. + +(* Converted value declarations: *) + +Definition empty : Deque := + Deque nil nil #0. + +Definition null : Deque -> bool := + fun deque => byteLength deque GHC.Base.== #0. + +Definition len : Data.ByteString.Internal.ByteString -> GHC.Int.Int64 := + fun x => GHC.Real.fromIntegral (Data.ByteString.length x). + +Definition cons_ : Data.ByteString.Internal.ByteString -> Deque -> Deque := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | x, Deque fs rs acc => Deque (cons x fs) rs (acc GHC.Num.+ len x) + end. + +Definition snoc : Data.ByteString.Internal.ByteString -> Deque -> Deque := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | x, Deque fs rs acc => Deque fs (cons x rs) (acc GHC.Num.+ len x) + end. + +Definition popFront + : Deque -> option (Data.ByteString.Internal.ByteString * Deque)%type := + fun arg_0__ => + match arg_0__ with + | Deque nil rs acc => + match GHC.List.reverse rs with + | nil => None + | cons x xs => Some (pair x (Deque xs nil (acc GHC.Num.- len x))) + end + | Deque (cons x xs) rs acc => Some (pair x (Deque xs rs (acc GHC.Num.- len x))) + end. + +Definition popRear + : Deque -> option (Deque * Data.ByteString.Internal.ByteString)%type := + fun arg_0__ => + match arg_0__ with + | Deque fs nil acc => + match GHC.List.reverse fs with + | nil => None + | cons x xs => Some (pair (Deque nil xs (acc GHC.Num.- len x)) x) + end + | Deque fs (cons x xs) acc => Some (pair (Deque fs xs (acc GHC.Num.- len x)) x) + end. + +(* External variables: + None Some bool cons list nil op_zt__ option pair Data.ByteString.length + Data.ByteString.Internal.ByteString GHC.Base.op_zeze__ GHC.Int.Int64 + GHC.List.reverse GHC.Num.fromInteger GHC.Num.op_zm__ GHC.Num.op_zp__ + GHC.Real.fromIntegral HsToCoq.Err.Build_Default HsToCoq.Err.Default + HsToCoq.Err.default +*) diff --git a/examples/bytestring/lib/Data/ByteString/Short.h2ci b/examples/bytestring/lib/Data/ByteString/Short.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Short.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString/Short.v b/examples/bytestring/lib/Data/ByteString/Short.v new file mode 100644 index 000000000..324eb9d3f --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Short.v @@ -0,0 +1,17 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* No imports to convert. *) + +(* No type declarations to convert. *) + +(* No value declarations to convert. *) diff --git a/examples/bytestring/lib/Data/ByteString/Short/Internal.h2ci b/examples/bytestring/lib/Data/ByteString/Short/Internal.h2ci new file mode 100644 index 000000000..a78aa1f15 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Short/Internal.h2ci @@ -0,0 +1,17 @@ +constructors: + Data.ByteString.Short.Internal.MBA: ! '[Qualified "Data.ByteString.Short.Internal" + "op_MBAzh__"]' + Data.ByteString.Short.Internal.ShortByteString: ! '[Qualified "Data.ByteString.Short.Internal" + "SBS"]' + Data.ByteString.Short.Internal.BA: ! '[Qualified "Data.ByteString.Short.Internal" + "op_BAzh__"]' +constructorFields: + Data.ByteString.Short.Internal.op_MBAzh__: NonRecordFields 1 + Data.ByteString.Short.Internal.SBS: NonRecordFields 1 + Data.ByteString.Short.Internal.op_BAzh__: NonRecordFields 1 +constructorTypes: + Data.ByteString.Short.Internal.op_MBAzh__: Qualified "Data.ByteString.Short.Internal" + "MBA" + Data.ByteString.Short.Internal.SBS: Qualified "Data.ByteString.Short.Internal" "ShortByteString" + Data.ByteString.Short.Internal.op_BAzh__: Qualified "Data.ByteString.Short.Internal" + "BA" diff --git a/examples/bytestring/lib/Data/ByteString/Short/Internal.v b/examples/bytestring/lib/Data/ByteString/Short/Internal.v new file mode 100644 index 000000000..500466a72 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Short/Internal.v @@ -0,0 +1,658 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Coq.Init.Datatypes. +Require Data.ByteString.Internal. +Require Data.Foldable. +Require GHC.Base. +Require GHC.Char. +Require GHC.Err. +Require GHC.Num. +Require GHC.Prim. +Require GHC.Real. +Import GHC.Base.Notations. +Import GHC.Num.Notations. +Import GHC.Prim.Notations. + +(* Converted type declarations: *) + +Inductive ShortByteString : Type := + | SBS : _GHC.Prim.ByteArray#_ -> ShortByteString. + +Inductive MBA s : Type := + | op_MBAzh__ : (_GHC.Prim.MutableByteArray#_ s) -> MBA s. + +Inductive BA : Type := | op_BAzh__ : _GHC.Prim.ByteArray#_ -> BA. + +Arguments op_MBAzh__ {_} _. + +Notation "'_MBA#_'" := (op_MBAzh__). + +Infix "MBA#" := (_MBA#_) (at level 99). + +Notation "'_BA#_'" := (op_BAzh__). + +Infix "BA#" := (_BA#_) (at level 99). + +(* Converted value declarations: *) + +(* Translating `instance Lift__ShortByteString' failed: Could not find + information for the class `Language.Haskell.TH.Syntax.Lift' when defining the + instance `Data.ByteString.Short.Internal.Lift__ShortByteString' *) + +Definition asBA : ShortByteString -> BA := + fun '(SBS lop_bazh__) => _BA#_ lop_bazh__. + +Definition length : ShortByteString -> GHC.Num.Int := + fun '(SBS lop_barrzh__) => + _GHC.Types.I#_ (_GHC.Prim.sizeofByteArray#_ lop_barrzh__). + +Definition memcmp_ByteArray + : BA -> BA -> GHC.Num.Int -> GHC.Types.IO Foreign.C.Types.CInt := + fun arg_0__ arg_1__ arg_2__ => + match arg_0__, arg_1__, arg_2__ with + | op_BAzh__ lop_ba1zh__, op_BAzh__ lop_ba2zh__, len => + c_memcmp_ByteArray lop_ba1zh__ lop_ba2zh__ (GHC.Real.fromIntegral len) + end. + +Definition equateBytes : ShortByteString -> ShortByteString -> bool := + fun sbs1 sbs2 => + let len2 := length sbs2 in + let len1 := length sbs1 in + andb (len1 GHC.Base.== len2) (#0 GHC.Base.== + Data.ByteString.Internal.accursedUnutterablePerformIO (memcmp_ByteArray (asBA + sbs1) (asBA sbs2) len1)). + +Local Definition Eq___ShortByteString_op_zeze__ + : ShortByteString -> ShortByteString -> bool := + equateBytes. + +Local Definition Eq___ShortByteString_op_zsze__ + : ShortByteString -> ShortByteString -> bool := + fun x y => negb (Eq___ShortByteString_op_zeze__ x y). + +Program Instance Eq___ShortByteString : GHC.Base.Eq_ ShortByteString := + fun _ k__ => + k__ {| GHC.Base.op_zeze____ := Eq___ShortByteString_op_zeze__ ; + GHC.Base.op_zsze____ := Eq___ShortByteString_op_zsze__ |}. + +Definition compareBytes : ShortByteString -> ShortByteString -> comparison := + fun sbs1 sbs2 => + let len2 := length sbs2 in + let len1 := length sbs1 in + let len := GHC.Base.min len1 len2 in + let 'i := Data.ByteString.Internal.accursedUnutterablePerformIO + (memcmp_ByteArray (asBA sbs1) (asBA sbs2) len) in + if i GHC.Base.< #0 : bool then Lt else + if i GHC.Base.> #0 : bool then Gt else + if len2 GHC.Base.> len1 : bool then Lt else + if len2 GHC.Base.< len1 : bool then Gt else + Eq. + +Local Definition Ord__ShortByteString_compare + : ShortByteString -> ShortByteString -> comparison := + compareBytes. + +Local Definition Ord__ShortByteString_op_zl__ + : ShortByteString -> ShortByteString -> bool := + fun x y => Ord__ShortByteString_compare x y GHC.Base.== Lt. + +Local Definition Ord__ShortByteString_op_zlze__ + : ShortByteString -> ShortByteString -> bool := + fun x y => Ord__ShortByteString_compare x y GHC.Base./= Gt. + +Local Definition Ord__ShortByteString_op_zg__ + : ShortByteString -> ShortByteString -> bool := + fun x y => Ord__ShortByteString_compare x y GHC.Base.== Gt. + +Local Definition Ord__ShortByteString_op_zgze__ + : ShortByteString -> ShortByteString -> bool := + fun x y => Ord__ShortByteString_compare x y GHC.Base./= Lt. + +Local Definition Ord__ShortByteString_max + : ShortByteString -> ShortByteString -> ShortByteString := + fun x y => if Ord__ShortByteString_op_zlze__ x y : bool then y else x. + +Local Definition Ord__ShortByteString_min + : ShortByteString -> ShortByteString -> ShortByteString := + fun x y => if Ord__ShortByteString_op_zlze__ x y : bool then x else y. + +Program Instance Ord__ShortByteString : GHC.Base.Ord ShortByteString := + fun _ k__ => + k__ {| GHC.Base.op_zl____ := Ord__ShortByteString_op_zl__ ; + GHC.Base.op_zlze____ := Ord__ShortByteString_op_zlze__ ; + GHC.Base.op_zg____ := Ord__ShortByteString_op_zg__ ; + GHC.Base.op_zgze____ := Ord__ShortByteString_op_zgze__ ; + GHC.Base.compare__ := Ord__ShortByteString_compare ; + GHC.Base.max__ := Ord__ShortByteString_max ; + GHC.Base.min__ := Ord__ShortByteString_min |}. + +Definition op_copyByteArrayzh__ {s} + : _GHC.Prim.ByteArray#_ -> + _GHC.Prim.Int#_ -> + _GHC.Prim.MutableByteArray#_ s -> + _GHC.Prim.Int#_ -> + _GHC.Prim.Int#_ -> _GHC.Prim.State#_ s -> _GHC.Prim.State#_ s := + _GHC.Prim.copyByteArray#_. + +Notation "'_copyByteArray#_'" := (op_copyByteArrayzh__). + +Infix "copyByteArray#" := (_copyByteArray#_) (at level 99). + +Definition copyByteArray {s} + : BA -> + GHC.Num.Int -> MBA s -> GHC.Num.Int -> GHC.Num.Int -> GHC.ST.ST s unit := + fun arg_0__ arg_1__ arg_2__ arg_3__ arg_4__ => + match arg_0__, arg_1__, arg_2__, arg_3__, arg_4__ with + | op_BAzh__ lop_srczh__ + , GHC.Types.op_Izh__ lop_srczuoffzh__ + , op_MBAzh__ lop_dstzh__ + , GHC.Types.op_Izh__ lop_dstzuoffzh__ + , GHC.Types.op_Izh__ lop_lenzh__ => + GHC.ST.ST (fun s => + let 's := _copyByteArray#_ lop_srczh__ lop_srczuoffzh__ lop_dstzh__ + lop_dstzuoffzh__ lop_lenzh__ s in + pair s tt) + end. + +Definition newByteArray {s} : GHC.Num.Int -> GHC.ST.ST s (MBA s) := + fun '(GHC.Types.op_Izh__ lop_lenzh__) => + GHC.ST.ST (fun s => + let 'pair s lop_mbazh__ := _GHC.Prim.newByteArray#_ lop_lenzh__ s in + pair s (_MBA#_ lop_mbazh__)). + +Definition unsafeFreezeByteArray {s} : MBA s -> GHC.ST.ST s BA := + fun '(op_MBAzh__ lop_mbazh__) => + GHC.ST.ST (fun s => + let 'pair s lop_bazh__ := _GHC.Prim.unsafeFreezeByteArray#_ lop_mbazh__ s in + pair s (_BA#_ lop_bazh__)). + +Definition create + : GHC.Num.Int -> (forall {s}, MBA s -> GHC.ST.ST s unit) -> ShortByteString := + fun len fill => + GHC.ST.runST (newByteArray len GHC.Base.>>= + (fun mba => + fill mba GHC.Base.>> + (let cont_0__ arg_1__ := + let 'op_BAzh__ lop_bazh__ := arg_1__ in + GHC.Base.return_ (SBS lop_bazh__) in + unsafeFreezeByteArray mba GHC.Base.>>= cont_0__))). + +Definition append : ShortByteString -> ShortByteString -> ShortByteString := + fun src1 src2 => + let len2 := length src2 in + let len1 := length src1 in + create (len1 GHC.Num.+ len2) (fun dst => + copyByteArray (asBA src1) #0 dst #0 len1 GHC.Base.>> + copyByteArray (asBA src2) #0 dst len1 len2). + +Local Definition Semigroup__ShortByteString_op_zlzlzgzg__ + : ShortByteString -> ShortByteString -> ShortByteString := + append. + +Program Instance Semigroup__ShortByteString + : GHC.Base.Semigroup ShortByteString := + fun _ k__ => + k__ {| GHC.Base.op_zlzlzgzg____ := Semigroup__ShortByteString_op_zlzlzgzg__ |}. + +Local Definition Monoid__ShortByteString_mappend + : ShortByteString -> ShortByteString -> ShortByteString := + _GHC.Base.<<>>_. + +Definition concat : list ShortByteString -> ShortByteString := + fun sbss => + let copy {s} + : MBA s -> GHC.Num.Int -> list ShortByteString -> GHC.ST.ST s unit := + fix copy (arg_0__ : MBA s) (arg_1__ : GHC.Num.Int) (arg_2__ + : list ShortByteString) : GHC.ST.ST s unit + := match arg_0__, arg_1__, arg_2__ with + | _, _, nil => GHC.Base.return_ tt + | dst, off, cons src sbss => + let len := length src in + copyByteArray (asBA src) #0 dst off len GHC.Base.>> + copy dst (off GHC.Num.+ len) sbss + end in + let fix totalLen arg_7__ arg_8__ + := match arg_7__, arg_8__ with + | acc, nil => acc + | acc, cons sbs sbss => totalLen (acc GHC.Num.+ length sbs) sbss + end in + create (totalLen #0 sbss) (fun dst => copy dst #0 sbss). + +Local Definition Monoid__ShortByteString_mconcat + : list ShortByteString -> ShortByteString := + concat. + +Definition empty : ShortByteString := + create #0 (fun arg_0__ => GHC.Base.return_ tt). + +Local Definition Monoid__ShortByteString_mempty : ShortByteString := + empty. + +Program Instance Monoid__ShortByteString : GHC.Base.Monoid ShortByteString := + fun _ k__ => + k__ {| GHC.Base.mappend__ := Monoid__ShortByteString_mappend ; + GHC.Base.mconcat__ := Monoid__ShortByteString_mconcat ; + GHC.Base.mempty__ := Monoid__ShortByteString_mempty |}. + +(* Skipping all instances of class `Control.DeepSeq.NFData', including + `Data.ByteString.Short.Internal.NFData__ShortByteString' *) + +(* Skipping all instances of class `GHC.Show.Show', including + `Data.ByteString.Short.Internal.Show__ShortByteString' *) + +(* Skipping all instances of class `GHC.Read.Read', including + `Data.ByteString.Short.Internal.Read__ShortByteString' *) + +(* Skipping all instances of class `GHC.Exts.IsList', including + `Data.ByteString.Short.Internal.IsList__ShortByteString' *) + +(* Translating `instance IsString__ShortByteString' failed: Could not find + information for the class `Data.String.IsString' when defining the instance + `Data.ByteString.Short.Internal.IsString__ShortByteString' *) + +(* Skipping all instances of class `Data.Data.Data', including + `Data.ByteString.Short.Internal.Data__ShortByteString' *) + +Definition null : ShortByteString -> bool := + fun sbs => length sbs GHC.Base.== #0. + +Definition indexError {a} : ShortByteString -> GHC.Num.Int -> a := + fun sbs i => + GHC.Err.error (Coq.Init.Datatypes.app (GHC.Base.hs_string__ + "Data.ByteString.Short.index: error in array index; ") + (Coq.Init.Datatypes.app (GHC.Show.show i) (Coq.Init.Datatypes.app + (GHC.Base.hs_string__ " not in range [0..") + (Coq.Init.Datatypes.app (GHC.Show.show (length sbs)) + (GHC.Base.hs_string__ + ")"))))). + +Definition indexWord8Array : BA -> GHC.Num.Int -> GHC.Word.Word8 := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | op_BAzh__ lop_bazh__, GHC.Types.op_Izh__ lop_izh__ => + _GHC.Word.W8#_ (_GHC.Prim.indexWord8Array#_ lop_bazh__ lop_izh__) + end. + +Definition unsafeIndex : ShortByteString -> GHC.Num.Int -> GHC.Word.Word8 := + fun sbs => indexWord8Array (asBA sbs). + +Definition index : ShortByteString -> GHC.Num.Int -> GHC.Word.Word8 := + fun sbs i => + if andb (i GHC.Base.>= #0) (i GHC.Base.< length sbs) : bool + then unsafeIndex sbs i else + indexError sbs i. + +Definition indexMaybe + : ShortByteString -> GHC.Num.Int -> option GHC.Word.Word8 := + fun sbs i => + if andb (i GHC.Base.>= #0) (i GHC.Base.< length sbs) : bool + then Some (unsafeIndex sbs i) else + None. + +Definition op_znz3fU__ + : ShortByteString -> GHC.Num.Int -> option GHC.Word.Word8 := + indexMaybe. + +Notation "'_!?_'" := (op_znz3fU__). + +Infix "!?" := (_!?_) (at level 99). + +Definition op_copyAddrToByteArrayzh__ + : _GHC.Prim.Addr#_ -> + _GHC.Prim.MutableByteArray#_ GHC.Prim.RealWorld -> + _GHC.Prim.Int#_ -> + _GHC.Prim.Int#_ -> + _GHC.Prim.State#_ GHC.Prim.RealWorld -> _GHC.Prim.State#_ GHC.Prim.RealWorld := + _GHC.Prim.copyAddrToByteArray#_. + +Notation "'_copyAddrToByteArray#_'" := (op_copyAddrToByteArrayzh__). + +Infix "copyAddrToByteArray#" := (_copyAddrToByteArray#_) (at level 99). + +Definition copyAddrToByteArray {a} + : GHC.Ptr.Ptr a -> + MBA GHC.Prim.RealWorld -> + GHC.Num.Int -> GHC.Num.Int -> GHC.ST.ST GHC.Prim.RealWorld unit := + fun arg_0__ arg_1__ arg_2__ arg_3__ => + match arg_0__, arg_1__, arg_2__, arg_3__ with + | GHC.Ptr.Ptr lop_srczh__ + , op_MBAzh__ lop_dstzh__ + , GHC.Types.op_Izh__ lop_dstzuoffzh__ + , GHC.Types.op_Izh__ lop_lenzh__ => + GHC.ST.ST (fun s => + let 's := _copyAddrToByteArray#_ lop_srczh__ lop_dstzh__ lop_dstzuoffzh__ + lop_lenzh__ s in + pair s tt) + end. + +Definition createFromPtr {a : Type} + : GHC.Ptr.Ptr a -> GHC.Num.Int -> GHC.Types.IO ShortByteString := + fun ptr len => + GHC.IO.stToIO (newByteArray len GHC.Base.>>= + (fun mba => + copyAddrToByteArray ptr mba #0 len GHC.Base.>> + (let cont_0__ arg_1__ := + let 'op_BAzh__ lop_bazh__ := arg_1__ in + GHC.Base.return_ (SBS lop_bazh__) in + unsafeFreezeByteArray mba GHC.Base.>>= cont_0__))). + +Definition unsafePackLenLiteral + : GHC.Num.Int -> _GHC.Prim.Addr#_ -> ShortByteString := + fun len lop_addrzh__ => + Data.ByteString.Internal.accursedUnutterablePerformIO (createFromPtr + (GHC.Ptr.Ptr lop_addrzh__) len). + +Definition toShortIO + : Data.ByteString.Internal.ByteString -> GHC.Types.IO ShortByteString := + fun '(Data.ByteString.Internal.BS fptr len) => + GHC.IO.stToIO (newByteArray len) GHC.Base.>>= + (fun mba => + let ptr := GHC.ForeignPtr.unsafeForeignPtrToPtr fptr in + GHC.IO.stToIO (copyAddrToByteArray ptr mba #0 len) GHC.Base.>> + (GHC.ForeignPtr.touchForeignPtr fptr GHC.Base.>> + (let cont_2__ arg_3__ := + let 'op_BAzh__ lop_bazh__ := arg_3__ in + GHC.Base.return_ (SBS lop_bazh__) in + GHC.IO.stToIO (unsafeFreezeByteArray mba) GHC.Base.>>= cont_2__))). + +Definition toShort : Data.ByteString.Internal.ByteString -> ShortByteString := + fun bs => GHC.IO.Unsafe.unsafeDupablePerformIO (toShortIO bs). + +Definition newPinnedByteArray {s} : GHC.Num.Int -> GHC.ST.ST s (MBA s) := + fun '(GHC.Types.op_Izh__ lop_lenzh__) => + GHC.ST.ST (fun s => + let 'pair s lop_mbazh__ := _GHC.Prim.newPinnedByteArray#_ lop_lenzh__ s in + pair s (_MBA#_ lop_mbazh__)). + +Definition fromShortIO + : ShortByteString -> GHC.Types.IO Data.ByteString.Internal.ByteString := + fun sbs => + let len := length sbs in + let cont_1__ arg_2__ := + let '(op_MBAzh__ lop_mbazh__ as mba) := arg_2__ in + GHC.IO.stToIO (copyByteArray (asBA sbs) #0 mba #0 len) GHC.Base.>> + (let fp := + GHC.ForeignPtr.ForeignPtr (_GHC.Prim.byteArrayContents#_ + (_GHC.Prim.unsafeCoerce#_ lop_mbazh__)) (GHC.ForeignPtr.PlainPtr lop_mbazh__) in + GHC.Base.return_ (Data.ByteString.Internal.BS fp len)) in + GHC.IO.stToIO (newPinnedByteArray len) GHC.Base.>>= cont_1__. + +Definition fromShort : ShortByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ => + let 'SBS lop_bzh__ := arg_0__ in + let j_2__ := + let 'sbs := arg_0__ in + GHC.IO.Unsafe.unsafeDupablePerformIO (fromShortIO sbs) in + let len := _GHC.Types.I#_ (_GHC.Prim.sizeofByteArray#_ lop_bzh__) in + let lop_addrzh__ := _GHC.Prim.byteArrayContents#_ lop_bzh__ in + let fp := + GHC.ForeignPtr.ForeignPtr lop_addrzh__ (GHC.ForeignPtr.PlainPtr + (_GHC.Prim.unsafeCoerce#_ lop_bzh__)) in + if _GHC.Types.isTrue#_ (_GHC.Prim.isByteArrayPinned#_ lop_bzh__) : bool + then Data.ByteString.Internal.BS fp len else + j_2__. + +Definition writeWord8Array {s} + : MBA s -> GHC.Num.Int -> GHC.Word.Word8 -> GHC.ST.ST s unit := + fun arg_0__ arg_1__ arg_2__ => + match arg_0__, arg_1__, arg_2__ with + | op_MBAzh__ lop_mbazh__ + , GHC.Types.op_Izh__ lop_izh__ + , GHC.Word.op_W8zh__ lop_wzh__ => + GHC.ST.ST (fun s => + let 's := _GHC.Prim.writeWord8Array#_ lop_mbazh__ lop_izh__ lop_wzh__ s in + pair s tt) + end. + +Definition packLenBytes + : GHC.Num.Int -> list GHC.Word.Word8 -> ShortByteString := + fun len ws0 => + let go {s} : MBA s -> GHC.Num.Int -> list GHC.Word.Word8 -> GHC.ST.ST s unit := + fix go (arg_0__ : MBA s) (arg_1__ : GHC.Num.Int) (arg_2__ : list GHC.Word.Word8) + : GHC.ST.ST s unit + := match arg_0__, arg_1__, arg_2__ with + | _, _, nil => GHC.Base.return_ tt + | mba, i, cons w ws => + writeWord8Array mba i w GHC.Base.>> go mba (i GHC.Num.+ #1) ws + end in + create len (fun mba => go mba #0 ws0). + +Definition packBytes : list GHC.Word.Word8 -> ShortByteString := + fun cs => packLenBytes (Data.Foldable.length cs) cs. + +Definition pack : list GHC.Word.Word8 -> ShortByteString := + packBytes. + +Definition unpackAppendBytesStrict + : ShortByteString -> + GHC.Num.Int -> GHC.Num.Int -> list GHC.Word.Word8 -> list GHC.Word.Word8 := + fun sbs off len => + let fix go sentinal i acc + := if i GHC.Base.== sentinal : bool then acc else + let w := indexWord8Array (asBA sbs) i in + go sentinal (i GHC.Num.- #1) (cons w acc) in + go (off GHC.Num.- #1) ((off GHC.Num.- #1) GHC.Num.+ len). + +Definition unpackAppendBytesLazy + : ShortByteString -> list GHC.Word.Word8 -> list GHC.Word.Word8 := + fun sbs => + let sz := #100 in + let fix go off len ws + := let remainder := go (off GHC.Num.+ sz) (len GHC.Num.- sz) ws in + if len GHC.Base.<= sz : bool then unpackAppendBytesStrict sbs off len ws else + unpackAppendBytesStrict sbs off sz remainder in + go #0 (length sbs). + +Definition unpackBytes : ShortByteString -> list GHC.Word.Word8 := + fun bs => unpackAppendBytesLazy bs nil. + +Definition unpack : ShortByteString -> list GHC.Word.Word8 := + unpackBytes. + +Definition writeCharArray {s} + : MBA s -> GHC.Num.Int -> GHC.Char.Char -> GHC.ST.ST s unit := + fun arg_0__ arg_1__ arg_2__ => + match arg_0__, arg_1__, arg_2__ with + | op_MBAzh__ lop_mbazh__ + , GHC.Types.op_Izh__ lop_izh__ + , GHC.Types.op_Czh__ lop_czh__ => + GHC.ST.ST (fun s => + let 's := _GHC.Prim.writeCharArray#_ lop_mbazh__ lop_izh__ lop_czh__ s in + pair s tt) + end. + +Definition packLenChars + : GHC.Num.Int -> list GHC.Char.Char -> ShortByteString := + fun len cs0 => + let go {s} : MBA s -> GHC.Num.Int -> list GHC.Char.Char -> GHC.ST.ST s unit := + fix go (arg_0__ : MBA s) (arg_1__ : GHC.Num.Int) (arg_2__ : list GHC.Char.Char) + : GHC.ST.ST s unit + := match arg_0__, arg_1__, arg_2__ with + | _, _, nil => GHC.Base.return_ tt + | mba, i, cons c cs => + writeCharArray mba i c GHC.Base.>> go mba (i GHC.Num.+ #1) cs + end in + create len (fun mba => go mba #0 cs0). + +Definition packChars : list GHC.Char.Char -> ShortByteString := + fun cs => packLenChars (Data.Foldable.length cs) cs. + +Definition indexCharArray : BA -> GHC.Num.Int -> GHC.Char.Char := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | op_BAzh__ lop_bazh__, GHC.Types.op_Izh__ lop_izh__ => + _GHC.Types.C#_ (_GHC.Prim.indexCharArray#_ lop_bazh__ lop_izh__) + end. + +Definition unpackAppendCharsStrict + : ShortByteString -> + GHC.Num.Int -> GHC.Num.Int -> list GHC.Char.Char -> list GHC.Char.Char := + fun sbs off len => + let fix go sentinal i acc + := if i GHC.Base.== sentinal : bool then acc else + let c := indexCharArray (asBA sbs) i in + go sentinal (i GHC.Num.- #1) (cons c acc) in + go (off GHC.Num.- #1) ((off GHC.Num.- #1) GHC.Num.+ len). + +Definition unpackAppendCharsLazy + : ShortByteString -> list GHC.Char.Char -> list GHC.Char.Char := + fun sbs => + let sz := #100 in + let fix go off len cs + := let remainder := go (off GHC.Num.+ sz) (len GHC.Num.- sz) cs in + if len GHC.Base.<= sz : bool then unpackAppendCharsStrict sbs off len cs else + unpackAppendCharsStrict sbs off sz remainder in + go #0 (length sbs). + +Definition unpackChars : ShortByteString -> list GHC.Char.Char := + fun bs => unpackAppendCharsLazy bs nil. + +Definition op_copyByteArrayToAddrzh__ + : _GHC.Prim.ByteArray#_ -> + _GHC.Prim.Int#_ -> + _GHC.Prim.Addr#_ -> + _GHC.Prim.Int#_ -> + _GHC.Prim.State#_ GHC.Prim.RealWorld -> _GHC.Prim.State#_ GHC.Prim.RealWorld := + _GHC.Prim.copyByteArrayToAddr#_. + +Notation "'_copyByteArrayToAddr#_'" := (op_copyByteArrayToAddrzh__). + +Infix "copyByteArrayToAddr#" := (_copyByteArrayToAddr#_) (at level 99). + +Definition copyByteArrayToAddr {a} + : BA -> + GHC.Num.Int -> + GHC.Ptr.Ptr a -> GHC.Num.Int -> GHC.ST.ST GHC.Prim.RealWorld unit := + fun arg_0__ arg_1__ arg_2__ arg_3__ => + match arg_0__, arg_1__, arg_2__, arg_3__ with + | op_BAzh__ lop_srczh__ + , GHC.Types.op_Izh__ lop_srczuoffzh__ + , GHC.Ptr.Ptr lop_dstzh__ + , GHC.Types.op_Izh__ lop_lenzh__ => + GHC.ST.ST (fun s => + let 's := _copyByteArrayToAddr#_ lop_srczh__ lop_srczuoffzh__ lop_dstzh__ + lop_lenzh__ s in + pair s tt) + end. + +Definition copyToPtr {a : Type} + : ShortByteString -> + GHC.Num.Int -> GHC.Ptr.Ptr a -> GHC.Num.Int -> GHC.Types.IO unit := + fun src off dst len => + GHC.IO.stToIO (copyByteArrayToAddr (asBA src) off dst len). + +Definition moduleErrorMsg + : GHC.Base.String -> GHC.Base.String -> GHC.Base.String := + fun fun_ msg => + Coq.Init.Datatypes.app (GHC.Base.hs_string__ "Data.ByteString.Short.") + (Coq.Init.Datatypes.app fun_ (cons (GHC.Char.hs_char__ ":") (cons + (GHC.Char.hs_char__ " ") msg))). + +Definition moduleErrorIO {a} + : GHC.Base.String -> GHC.Base.String -> GHC.Types.IO a := + fun fun_ msg => + (GHC.IO.throwIO GHC.Base.∘ GHC.IO.Exception.userError) (moduleErrorMsg fun_ + msg). + +Definition packCStringLen + : Foreign.C.String.CStringLen -> GHC.Types.IO ShortByteString := + fun arg_0__ => + let 'pair cstr len := arg_0__ in + if len GHC.Base.>= #0 : bool then createFromPtr cstr len else + let 'pair _ len := arg_0__ in + moduleErrorIO (GHC.Base.hs_string__ "packCStringLen") (Coq.Init.Datatypes.app + (GHC.Base.hs_string__ "negative length: ") (GHC.Show.show + len)). + +Definition packCString + : Foreign.C.String.CString -> GHC.Types.IO ShortByteString := + fun cstr => + Data.ByteString.Internal.c_strlen cstr GHC.Base.>>= + (fun len => packCStringLen (pair cstr (GHC.Real.fromIntegral len))). + +Definition useAsCString {a : Type} + : ShortByteString -> + (Foreign.C.String.CString -> GHC.Types.IO a) -> GHC.Types.IO a := + fun bs action => + let l := length bs in + Foreign.Marshal.Alloc.allocaBytes (l GHC.Num.+ #1) (fun buf => + copyToPtr bs #0 buf (GHC.Real.fromIntegral l) GHC.Base.>> + (Foreign.Storable.pokeByteOff buf l (#0 : GHC.Word.Word8) + GHC.Base.>> + action buf)). + +Definition useAsCStringLen {a : Type} + : ShortByteString -> + (Foreign.C.String.CStringLen -> GHC.Types.IO a) -> GHC.Types.IO a := + fun bs action => + let l := length bs in + Foreign.Marshal.Alloc.allocaBytes l (fun buf => + copyToPtr bs #0 buf (GHC.Real.fromIntegral l) GHC.Base.>> + action (pair buf l)). + +Module Notations. +Notation "'_Data.ByteString.Short.Internal.MBA#_'" := (op_MBAzh__). +Infix "Data.ByteString.Short.Internal.MBA#" := (_MBA#_) (at level 99). +Notation "'_Data.ByteString.Short.Internal.BA#_'" := (op_BAzh__). +Infix "Data.ByteString.Short.Internal.BA#" := (_BA#_) (at level 99). +Notation "'_Data.ByteString.Short.Internal.copyByteArray#_'" := + (op_copyByteArrayzh__). +Infix "Data.ByteString.Short.Internal.copyByteArray#" := (_copyByteArray#_) + (at level 99). +Notation "'_Data.ByteString.Short.Internal.!?_'" := (op_znz3fU__). +Infix "Data.ByteString.Short.Internal.!?" := (_!?_) (at level 99). +Notation "'_Data.ByteString.Short.Internal.copyAddrToByteArray#_'" := + (op_copyAddrToByteArrayzh__). +Infix "Data.ByteString.Short.Internal.copyAddrToByteArray#" := +(_copyAddrToByteArray#_) (at level 99). +Notation "'_Data.ByteString.Short.Internal.copyByteArrayToAddr#_'" := + (op_copyByteArrayToAddrzh__). +Infix "Data.ByteString.Short.Internal.copyByteArrayToAddr#" := +(_copyByteArrayToAddr#_) (at level 99). +End Notations. + +(* External variables: + Eq Gt Lt None Some Type andb bool c_memcmp_ByteArray comparison cons list negb + nil option pair tt unit Coq.Init.Datatypes.app Data.ByteString.Internal.BS + Data.ByteString.Internal.ByteString + Data.ByteString.Internal.accursedUnutterablePerformIO + Data.ByteString.Internal.c_strlen Data.Foldable.length Foreign.C.String.CString + Foreign.C.String.CStringLen Foreign.C.Types.CInt + Foreign.Marshal.Alloc.allocaBytes Foreign.Storable.pokeByteOff GHC.Base.Eq_ + GHC.Base.Monoid GHC.Base.Ord GHC.Base.Semigroup GHC.Base.String + GHC.Base.compare__ GHC.Base.mappend__ GHC.Base.max__ GHC.Base.mconcat__ + GHC.Base.mempty__ GHC.Base.min GHC.Base.min__ GHC.Base.op_z2218U__ + GHC.Base.op_zeze__ GHC.Base.op_zeze____ GHC.Base.op_zg__ GHC.Base.op_zg____ + GHC.Base.op_zgze__ GHC.Base.op_zgze____ GHC.Base.op_zgzg__ GHC.Base.op_zgzgze__ + GHC.Base.op_zl__ GHC.Base.op_zl____ GHC.Base.op_zlze__ GHC.Base.op_zlze____ + GHC.Base.op_zlzlzgzg__ GHC.Base.op_zlzlzgzg____ GHC.Base.op_zsze__ + GHC.Base.op_zsze____ GHC.Base.return_ GHC.Char.Char GHC.Err.error + GHC.ForeignPtr.ForeignPtr GHC.ForeignPtr.PlainPtr GHC.ForeignPtr.touchForeignPtr + GHC.ForeignPtr.unsafeForeignPtrToPtr GHC.IO.stToIO GHC.IO.throwIO + GHC.IO.Exception.userError GHC.IO.Unsafe.unsafeDupablePerformIO GHC.Num.Int + GHC.Num.fromInteger GHC.Num.op_zm__ GHC.Num.op_zp__ GHC.Prim.RealWorld + GHC.Prim.op_Addrzh__ GHC.Prim.op_ByteArrayzh__ GHC.Prim.op_Intzh__ + GHC.Prim.op_MutableByteArrayzh__ GHC.Prim.op_Statezh__ + GHC.Prim.op_byteArrayContentszh__ GHC.Prim.op_copyAddrToByteArrayzh__ + GHC.Prim.op_copyByteArrayToAddrzh__ GHC.Prim.op_copyByteArrayzh__ + GHC.Prim.op_indexCharArrayzh__ GHC.Prim.op_indexWord8Arrayzh__ + GHC.Prim.op_isByteArrayPinnedzh__ GHC.Prim.op_newByteArrayzh__ + GHC.Prim.op_newPinnedByteArrayzh__ GHC.Prim.op_sizzeofByteArrayzh__ + GHC.Prim.op_unsafeCoercezh__ GHC.Prim.op_unsafeFreezzeByteArrayzh__ + GHC.Prim.op_writeCharArrayzh__ GHC.Prim.op_writeWord8Arrayzh__ GHC.Ptr.Ptr + GHC.Real.fromIntegral GHC.ST.ST GHC.ST.runST GHC.Show.show GHC.Types.IO + GHC.Types.op_Czh__ GHC.Types.op_Izh__ GHC.Types.op_isTruezh__ GHC.Word.Word8 + GHC.Word.op_W8zh__ +*) diff --git a/examples/bytestring/lib/Data/ByteString/Unsafe.h2ci b/examples/bytestring/lib/Data/ByteString/Unsafe.h2ci new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Unsafe.h2ci @@ -0,0 +1 @@ +{} diff --git a/examples/bytestring/lib/Data/ByteString/Unsafe.v b/examples/bytestring/lib/Data/ByteString/Unsafe.v new file mode 100644 index 000000000..dd7a70393 --- /dev/null +++ b/examples/bytestring/lib/Data/ByteString/Unsafe.v @@ -0,0 +1,175 @@ +(* Default settings (from HsToCoq.Coq.Preamble) *) + +Generalizable All Variables. + +Unset Implicit Arguments. +Set Maximal Implicit Insertion. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Require Coq.Program.Tactics. +Require Coq.Program.Wf. + +(* Converted imports: *) + +Require Data.ByteString.Internal. +Require GHC.Base. +Require GHC.Num. +Require GHC.Prim. +Require GHC.Real. +Import GHC.Base.Notations. +Import GHC.Num.Notations. +Import GHC.Prim.Notations. + +(* No type declarations to convert. *) + +(* Converted value declarations: *) + +Definition unsafeHead : Data.ByteString.Internal.ByteString -> GHC.Word.Word8 := + fun '(Data.ByteString.Internal.BS x l) => + GHC.Base.assert (l GHC.Base.> #0) + (Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Foreign.Storable.peek p))). + +Definition unsafeTail + : Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun '(Data.ByteString.Internal.BS ps l) => + GHC.Base.assert (l GHC.Base.> #0) (Data.ByteString.Internal.BS + (GHC.ForeignPtr.plusForeignPtr ps #1) (l GHC.Num.- #1)). + +Definition unsafeInit + : Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun '(Data.ByteString.Internal.BS ps l) => + GHC.Base.assert (l GHC.Base.> #0) (Data.ByteString.Internal.BS ps (l GHC.Num.- + #1)). + +Definition unsafeLast : Data.ByteString.Internal.ByteString -> GHC.Word.Word8 := + fun '(Data.ByteString.Internal.BS x l) => + GHC.Base.assert (l GHC.Base.> #0) + (Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Foreign.Storable.peekByteOff p (l GHC.Num.- #1)))). + +Definition unsafeIndex + : Data.ByteString.Internal.ByteString -> GHC.Num.Int -> GHC.Word.Word8 := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | Data.ByteString.Internal.BS x l, i => + GHC.Base.assert (andb (i GHC.Base.>= #0) (i GHC.Base.< l)) + (Data.ByteString.Internal.accursedUnutterablePerformIO + (Data.ByteString.Internal.unsafeWithForeignPtr x (fun p => + Foreign.Storable.peekByteOff p i))) + end. + +Definition unsafeTake + : GHC.Num.Int -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | n, Data.ByteString.Internal.BS x l => + GHC.Base.assert (andb (#0 GHC.Base.<= n) (n GHC.Base.<= l)) + (Data.ByteString.Internal.BS x n) + end. + +Definition unsafeDrop + : GHC.Num.Int -> + Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | n, Data.ByteString.Internal.BS x l => + GHC.Base.assert (andb (#0 GHC.Base.<= n) (n GHC.Base.<= l)) + (Data.ByteString.Internal.BS (GHC.ForeignPtr.plusForeignPtr x n) (l GHC.Num.- + n)) + end. + +Definition unsafePackAddressLen + : GHC.Num.Int -> + _GHC.Prim.Addr#_ -> GHC.Types.IO Data.ByteString.Internal.ByteString := + fun len lop_addrzh__ => + GHC.ForeignPtr.newForeignPtr_ (GHC.Ptr.Ptr lop_addrzh__) GHC.Base.>>= + (fun p => GHC.Base.return_ (Data.ByteString.Internal.BS p len)). + +Definition unsafePackCStringFinalizer + : GHC.Ptr.Ptr GHC.Word.Word8 -> + GHC.Num.Int -> + GHC.Types.IO unit -> GHC.Types.IO Data.ByteString.Internal.ByteString := + fun p l f => + Foreign.Concurrent.newForeignPtr p f GHC.Base.>>= + (fun fp => GHC.Base.return_ (Data.ByteString.Internal.BS fp l)). + +Definition unsafeFinalize + : Data.ByteString.Internal.ByteString -> GHC.Types.IO unit := + fun '(Data.ByteString.Internal.BS p _) => GHC.ForeignPtr.finalizeForeignPtr p. + +Definition unsafePackCString + : Foreign.C.String.CString -> + GHC.Types.IO Data.ByteString.Internal.ByteString := + fun cstr => + GHC.ForeignPtr.newForeignPtr_ (GHC.Ptr.castPtr cstr) GHC.Base.>>= + (fun fp => + Data.ByteString.Internal.c_strlen cstr GHC.Base.>>= + (fun l => + GHC.Base.return_ (Data.ByteString.Internal.BS fp (GHC.Real.fromIntegral l)))). + +Definition unsafePackCStringLen + : Foreign.C.String.CStringLen -> + GHC.Types.IO Data.ByteString.Internal.ByteString := + fun '(pair ptr len) => + GHC.ForeignPtr.newForeignPtr_ (GHC.Ptr.castPtr ptr) GHC.Base.>>= + (fun fp => + GHC.Base.return_ (Data.ByteString.Internal.BS fp (GHC.Real.fromIntegral len))). + +Definition unsafePackMallocCString + : Foreign.C.String.CString -> + GHC.Types.IO Data.ByteString.Internal.ByteString := + fun cstr => + Foreign.ForeignPtr.Imp.newForeignPtr Data.ByteString.Internal.c_free_finalizer + (GHC.Ptr.castPtr cstr) GHC.Base.>>= + (fun fp => + Data.ByteString.Internal.c_strlen cstr GHC.Base.>>= + (fun len => + GHC.Base.return_ (Data.ByteString.Internal.BS fp (GHC.Real.fromIntegral len)))). + +Definition unsafePackMallocCStringLen + : Foreign.C.String.CStringLen -> + GHC.Types.IO Data.ByteString.Internal.ByteString := + fun '(pair cstr len) => + Foreign.ForeignPtr.Imp.newForeignPtr Data.ByteString.Internal.c_free_finalizer + (GHC.Ptr.castPtr cstr) GHC.Base.>>= + (fun fp => GHC.Base.return_ (Data.ByteString.Internal.BS fp len)). + +Definition unsafeUseAsCString {a : Type} + : Data.ByteString.Internal.ByteString -> + (Foreign.C.String.CString -> GHC.Types.IO a) -> GHC.Types.IO a := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | Data.ByteString.Internal.BS ps _, action => + Foreign.ForeignPtr.Imp.withForeignPtr ps (fun p => action (GHC.Ptr.castPtr p)) + end. + +Definition unsafeUseAsCStringLen {a : Type} + : Data.ByteString.Internal.ByteString -> + (Foreign.C.String.CStringLen -> GHC.Types.IO a) -> GHC.Types.IO a := + fun arg_0__ arg_1__ => + match arg_0__, arg_1__ with + | Data.ByteString.Internal.BS ps l, action => + Foreign.ForeignPtr.Imp.withForeignPtr ps (fun p => + action (pair (GHC.Ptr.castPtr p) l)) + end. + +(* External variables: + Type andb pair unit Data.ByteString.Internal.BS + Data.ByteString.Internal.ByteString + Data.ByteString.Internal.accursedUnutterablePerformIO + Data.ByteString.Internal.c_free_finalizer Data.ByteString.Internal.c_strlen + Data.ByteString.Internal.unsafeWithForeignPtr Foreign.C.String.CString + Foreign.C.String.CStringLen Foreign.Concurrent.newForeignPtr + Foreign.ForeignPtr.Imp.newForeignPtr Foreign.ForeignPtr.Imp.withForeignPtr + Foreign.Storable.peek Foreign.Storable.peekByteOff GHC.Base.assert + GHC.Base.op_zg__ GHC.Base.op_zgze__ GHC.Base.op_zgzgze__ GHC.Base.op_zl__ + GHC.Base.op_zlze__ GHC.Base.return_ GHC.ForeignPtr.finalizeForeignPtr + GHC.ForeignPtr.newForeignPtr_ GHC.ForeignPtr.plusForeignPtr GHC.Num.Int + GHC.Num.fromInteger GHC.Num.op_zm__ GHC.Prim.op_Addrzh__ GHC.Ptr.Ptr + GHC.Ptr.castPtr GHC.Real.fromIntegral GHC.Types.IO GHC.Word.Word8 +*) diff --git a/examples/bytestring/lib/README.md b/examples/bytestring/lib/README.md new file mode 100644 index 000000000..dcd89ce19 --- /dev/null +++ b/examples/bytestring/lib/README.md @@ -0,0 +1,2 @@ +This directory contains a Coq’ified version of the Haskell bytestring library +Do not edit files here! Instead, look in `examples/bytestring`. diff --git a/examples/bytestring/lib/_CoqProject b/examples/bytestring/lib/_CoqProject new file mode 100644 index 000000000..864f9ce23 --- /dev/null +++ b/examples/bytestring/lib/_CoqProject @@ -0,0 +1,6 @@ +-Q . "" +-Q ../../../base "" + +Data/ByteString/Builder/ASCII.v Data/ByteString/Builder/Extra.v Data/ByteString/Builder/Internal.v Data/ByteString/Builder/Prim/ASCII.v Data/ByteString/Builder/Prim/Binary.v Data/ByteString/Builder/Prim/Internal/Base16.v Data/ByteString/Builder/Prim/Internal/Floating.v Data/ByteString/Builder/Prim/Internal.v Data/ByteString/Internal.v Data/ByteString/Builder/Prim.v Data/ByteString/Builder.v Data/ByteString/Lazy/Internal.v Data/ByteString/Lazy.v Data/ByteString/Char8.v Data/ByteString/Lazy/Char8.v Data/ByteString/Lazy/Internal/Deque.v Data/ByteString/Short/Internal.v Data/ByteString/Short.v Data/ByteString/Unsafe.v Data/ByteString.v + + diff --git a/examples/bytestring/lib/edits b/examples/bytestring/lib/edits new file mode 120000 index 000000000..22253a458 --- /dev/null +++ b/examples/bytestring/lib/edits @@ -0,0 +1 @@ +../edits \ No newline at end of file From a69ccb3c1f23db22ac0ce6a99b9317ddfc097280 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Tue, 2 Nov 2021 22:01:34 -0400 Subject: [PATCH 2/2] GHC.Prim.Notations is not a module --- .gitignore | 1 + common.mk | 1 + examples/bytestring/edits | 5 +++++ .../lib/Data/ByteString/Builder/Extra.h2ci | 2 +- .../lib/Data/ByteString/Builder/Internal.h2ci | 14 +++++++------- .../lib/Data/ByteString/Builder/Prim/Internal.h2ci | 4 ++-- .../ByteString/Builder/Prim/Internal/Base16.h2ci | 2 +- .../bytestring/lib/Data/ByteString/Internal.h2ci | 2 +- .../lib/Data/ByteString/Lazy/Internal.h2ci | 2 +- .../lib/Data/ByteString/Lazy/Internal/Deque.h2ci | 2 +- .../lib/Data/ByteString/Short/Internal.h2ci | 6 +++--- 11 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 44869caef..9a9c580f2 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ ghc-head *.crashcoqide *.DS_Store +stack.yaml.lock diff --git a/common.mk b/common.mk index 0c7228156..360ecc6fd 100644 --- a/common.mk +++ b/common.mk @@ -21,3 +21,4 @@ HS_TO_COQ = cabal new-run --project-file=$(TOP)/cabal.project -v0 $(CABAL_OPTS) endif SHELL = bash +HS_TO_COQ = //home/quinn/Dropbox/Projects/haskell/hstocoq-bytestring/hs-to-coq/result/bin/hs-to-coq diff --git a/examples/bytestring/edits b/examples/bytestring/edits index 525d0e2e9..ac630b0ac 100644 --- a/examples/bytestring/edits +++ b/examples/bytestring/edits @@ -34,6 +34,11 @@ skip module GHC.IO.Encoding skip module GHC.IO.Handle.Text skip module GHC.IO.Handle +rename type GHC.Maybe.Maybe = option +rename value GHC.Maybe.Just = Some +rename value GHC.Maybe.Nothing = None + + # xiomatize module GHC.Ptr # xiomatize module GHC.ForeignPtr # xiomatize module GHC.IO.Handle.Types diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Extra.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Extra.h2ci index d2e9573de..a80b1b911 100644 --- a/examples/bytestring/lib/Data/ByteString/Builder/Extra.h2ci +++ b/examples/bytestring/lib/Data/ByteString/Builder/Extra.h2ci @@ -1,5 +1,5 @@ constructors: - Data.ByteString.Builder.Extra.Next: ! '[Qualified "Data.ByteString.Builder.Extra" + Data.ByteString.Builder.Extra.Next: '[Qualified "Data.ByteString.Builder.Extra" "Done",Qualified "Data.ByteString.Builder.Extra" "More",Qualified "Data.ByteString.Builder.Extra" "Chunk"]' constructorFields: diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Internal.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Internal.h2ci index c785978d4..fab756ce4 100644 --- a/examples/bytestring/lib/Data/ByteString/Builder/Internal.h2ci +++ b/examples/bytestring/lib/Data/ByteString/Builder/Internal.h2ci @@ -1,17 +1,17 @@ constructors: - Data.ByteString.Builder.Internal.AllocationStrategy: ! '[Qualified "Data.ByteString.Builder.Internal" + Data.ByteString.Builder.Internal.AllocationStrategy: '[Qualified "Data.ByteString.Builder.Internal" "AllocationStrategy"]' - Data.ByteString.Builder.Internal.Builder: ! '[Qualified "Data.ByteString.Builder.Internal" + Data.ByteString.Builder.Internal.Builder: '[Qualified "Data.ByteString.Builder.Internal" "Builder"]' - Data.ByteString.Builder.Internal.Buffer: ! '[Qualified "Data.ByteString.Builder.Internal" + Data.ByteString.Builder.Internal.Buffer: '[Qualified "Data.ByteString.Builder.Internal" "Buffer"]' - Data.ByteString.Builder.Internal.ChunkIOStream: ! '[Qualified "Data.ByteString.Builder.Internal" + Data.ByteString.Builder.Internal.ChunkIOStream: '[Qualified "Data.ByteString.Builder.Internal" "Finished",Qualified "Data.ByteString.Builder.Internal" "Yield1"]' - Data.ByteString.Builder.Internal.Put: ! '[Qualified "Data.ByteString.Builder.Internal" + Data.ByteString.Builder.Internal.Put: '[Qualified "Data.ByteString.Builder.Internal" "Put"]' - Data.ByteString.Builder.Internal.BufferRange: ! '[Qualified "Data.ByteString.Builder.Internal" + Data.ByteString.Builder.Internal.BufferRange: '[Qualified "Data.ByteString.Builder.Internal" "BufferRange"]' - Data.ByteString.Builder.Internal.BuildSignal: ! '[Qualified "Data.ByteString.Builder.Internal" + Data.ByteString.Builder.Internal.BuildSignal: '[Qualified "Data.ByteString.Builder.Internal" "Done",Qualified "Data.ByteString.Builder.Internal" "BufferFull",Qualified "Data.ByteString.Builder.Internal" "InsertChunk"]' constructorFields: diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.h2ci index df56fdc8e..001f13455 100644 --- a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.h2ci +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal.h2ci @@ -5,9 +5,9 @@ classTypes: Data.ByteString.Builder.Prim.Internal.Monoidal: fromList [] Data.ByteString.Builder.Prim.Internal.Contravariant: fromList [] constructors: - Data.ByteString.Builder.Prim.Internal.BoundedPrim: ! '[Qualified "Data.ByteString.Builder.Prim.Internal" + Data.ByteString.Builder.Prim.Internal.BoundedPrim: '[Qualified "Data.ByteString.Builder.Prim.Internal" "BP"]' - Data.ByteString.Builder.Prim.Internal.FixedPrim: ! '[Qualified "Data.ByteString.Builder.Prim.Internal" + Data.ByteString.Builder.Prim.Internal.FixedPrim: '[Qualified "Data.ByteString.Builder.Prim.Internal" "FP"]' constructorFields: Data.ByteString.Builder.Prim.Internal.BP: NonRecordFields 2 diff --git a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.h2ci b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.h2ci index 41d6ada00..56408995c 100644 --- a/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.h2ci +++ b/examples/bytestring/lib/Data/ByteString/Builder/Prim/Internal/Base16.h2ci @@ -1,5 +1,5 @@ constructors: - Data.ByteString.Builder.Prim.Internal.Base16.EncodingTable: ! '[Qualified "Data.ByteString.Builder.Prim.Internal.Base16" + Data.ByteString.Builder.Prim.Internal.Base16.EncodingTable: '[Qualified "Data.ByteString.Builder.Prim.Internal.Base16" "EncodingTable"]' constructorFields: Data.ByteString.Builder.Prim.Internal.Base16.EncodingTable: NonRecordFields 1 diff --git a/examples/bytestring/lib/Data/ByteString/Internal.h2ci b/examples/bytestring/lib/Data/ByteString/Internal.h2ci index dacfde74c..551ea5baf 100644 --- a/examples/bytestring/lib/Data/ByteString/Internal.h2ci +++ b/examples/bytestring/lib/Data/ByteString/Internal.h2ci @@ -1,5 +1,5 @@ constructors: - Data.ByteString.Internal.ByteString: ! '[Qualified "Data.ByteString.Internal" "BS"]' + Data.ByteString.Internal.ByteString: '[Qualified "Data.ByteString.Internal" "BS"]' constructorFields: Data.ByteString.Internal.BS: NonRecordFields 2 constructorTypes: diff --git a/examples/bytestring/lib/Data/ByteString/Lazy/Internal.h2ci b/examples/bytestring/lib/Data/ByteString/Lazy/Internal.h2ci index 90fd09a86..a37f453f5 100644 --- a/examples/bytestring/lib/Data/ByteString/Lazy/Internal.h2ci +++ b/examples/bytestring/lib/Data/ByteString/Lazy/Internal.h2ci @@ -1,5 +1,5 @@ constructors: - Data.ByteString.Lazy.Internal.ByteString: ! '[Qualified "Data.ByteString.Lazy.Internal" + Data.ByteString.Lazy.Internal.ByteString: '[Qualified "Data.ByteString.Lazy.Internal" "Empty",Qualified "Data.ByteString.Lazy.Internal" "Chunk"]' constructorFields: Data.ByteString.Lazy.Internal.Chunk: NonRecordFields 2 diff --git a/examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.h2ci b/examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.h2ci index ae8f8a9d5..d42e22618 100644 --- a/examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.h2ci +++ b/examples/bytestring/lib/Data/ByteString/Lazy/Internal/Deque.h2ci @@ -1,5 +1,5 @@ constructors: - Data.ByteString.Lazy.Internal.Deque.Deque: ! '[Qualified "Data.ByteString.Lazy.Internal.Deque" + Data.ByteString.Lazy.Internal.Deque.Deque: '[Qualified "Data.ByteString.Lazy.Internal.Deque" "Deque"]' constructorFields: Data.ByteString.Lazy.Internal.Deque.Deque: RecordFields [Qualified "Data.ByteString.Lazy.Internal.Deque" diff --git a/examples/bytestring/lib/Data/ByteString/Short/Internal.h2ci b/examples/bytestring/lib/Data/ByteString/Short/Internal.h2ci index a78aa1f15..f7de81b7c 100644 --- a/examples/bytestring/lib/Data/ByteString/Short/Internal.h2ci +++ b/examples/bytestring/lib/Data/ByteString/Short/Internal.h2ci @@ -1,9 +1,9 @@ constructors: - Data.ByteString.Short.Internal.MBA: ! '[Qualified "Data.ByteString.Short.Internal" + Data.ByteString.Short.Internal.MBA: '[Qualified "Data.ByteString.Short.Internal" "op_MBAzh__"]' - Data.ByteString.Short.Internal.ShortByteString: ! '[Qualified "Data.ByteString.Short.Internal" + Data.ByteString.Short.Internal.ShortByteString: '[Qualified "Data.ByteString.Short.Internal" "SBS"]' - Data.ByteString.Short.Internal.BA: ! '[Qualified "Data.ByteString.Short.Internal" + Data.ByteString.Short.Internal.BA: '[Qualified "Data.ByteString.Short.Internal" "op_BAzh__"]' constructorFields: Data.ByteString.Short.Internal.op_MBAzh__: NonRecordFields 1