<commit_before>{-# OPTIONS -cpp #-}
--
-- (c) The University of Glasgow 2002
--
-- Binary I/O library, with special tweaks for GHC
--
-- Based on the nhc98 Binary library, which is copyright
-- (c) <NAME> and <NAME>, University of York, 1998.
-- Under the terms of the license for that software, we must tell you
-- where you can obtain the original version of the Binary library, namely
--     http://www.cs.york.ac.uk/fp/nhc98/

module Binary
  ( {-type-}  Bin,
    {-class-} Binary(..),
    {-type-}  BinHandle,

   openBinIO, openBinIO_,
   openBinMem,
--   closeBin,

   getUserData,

   seekBin,
   tellBin,
   castBin,

   writeBinMem,
   readBinMem,

   isEOFBin,

   -- for writing instances:
   putByte,
   getByte,

   -- lazy Bin I/O
   lazyGet,
   lazyPut,

   -- GHC only:
   ByteArray(..),
   getByteArray,
   putByteArray,

   getBinFileWithDict,	-- :: Binary a => FilePath -> IO a
   putBinFileWithDict,	-- :: Binary a => FilePath -> Module -> a -> IO ()

  ) where

#include "HsVersions.h"

-- The *host* architecture version:
#include "MachDeps.h"

import {-# SOURCE #-} Module
import FastString
import Unique
import Panic
import UniqFM
import FastMutInt

#if __GLASGOW_HASKELL__ < 503
import DATA_IOREF
import DATA_BITS
import DATA_INT
import DATA_WORD
import Char
import Monad
import Exception
import GlaExts hiding (ByteArray, newByteArray, freezeByteArray)
import Array
import IO
import PrelIOBase		( IOError(..), IOErrorType(..)
#if __GLASGOW_HASKELL__ > 411
				, IOException(..)
#endif
				)
import PrelReal			( Ratio(..) )
import PrelIOBase	 	( IO(..) )
#else
import Data.Array.IO
import Data.Array
import Data.Bits
import Data.Int
import Data.Word
import Data.IORef
import Data.Char		( ord, chr )
import Data.Array.Base  	( unsafeRead, unsafeWrite )
import Control.Monad		( when )
import Control.Exception	( throwDyn )
import System.IO as IO
import System.IO.Unsafe		( unsafeInterleaveIO )
import System.IO.Error		( mkIOError, eofErrorType )
import GHC.Real			( Ratio(..) )
import GHC.Exts
import GHC.IOBase	 	( IO(..) )
import GHC.Word			( Word8(..) )
#endif

#if __GLASGOW_HASKELL__ < 601
-- openFileEx is available from the lang package, but we want to 
-- be independent of hslibs libraries.
import GHC.Handle		( openFileEx, IOModeEx(..) )
#else
import System.IO		( openBinaryFile )
#endif

#if __GLASGOW_HASKELL__ < 601
openBinaryFile f mode = openFileEx f (BinaryMode mode)
#endif

#if __GLASGOW_HASKELL__ < 503
type BinArray = MutableByteArray RealWorld Int
newArray_ bounds     = stToIO (newCharArray bounds)
unsafeWrite arr ix e = stToIO (writeWord8Array arr ix e)
unsafeRead  arr ix   = stToIO (readWord8Array arr ix)
#if __GLASGOW_HASKELL__ < 411
newByteArray#        = newCharArray#
#endif
hPutArray h arr sz   = hPutBufBAFull h arr sz
hGetArray h sz       = hGetBufBAFull h sz

mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> Exception
mkIOError t location maybe_hdl maybe_filename<commit_msg>[project @ 2003-06-24 09:43:23 by simonmar] Fix up compilation with GHC 5.02<commit_after>{-# OPTIONS -cpp #-}
--
-- (c) The University of Glasgow 2002
--
-- Binary I/O library, with special tweaks for GHC
--
-- Based on the nhc98 Binary library, which is copyright
-- (c) <NAME> and <NAME>, University of York, 1998.
-- Under the terms of the license for that software, we must tell you
-- where you can obtain the original version of the Binary library, namely
--     http://www.cs.york.ac.uk/fp/nhc98/

module Binary
  ( {-type-}  Bin,
    {-class-} Binary(..),
    {-type-}  BinHandle,

   openBinIO, openBinIO_,
   openBinMem,
--   closeBin,

   getUserData,

   seekBin,
   tellBin,
   castBin,

   writeBinMem,
   readBinMem,

   isEOFBin,

   -- for writing instances:
   putByte,
   getByte,

   -- lazy Bin I/O
   lazyGet,
   lazyPut,

   -- GHC only:
   ByteArray(..),
   getByteArray,
   putByteArray,

   getBinFileWithDict,	-- :: Binary a => FilePath -> IO a
   putBinFileWithDict,	-- :: Binary a => FilePath -> Module -> a -> IO ()

  ) where

#include "HsVersions.h"

-- The *host* architecture version:
#include "MachDeps.h"

import {-# SOURCE #-} Module
import FastString
import Unique
import Panic
import UniqFM
import FastMutInt

#if __GLASGOW_HASKELL__ < 503
import DATA_IOREF
import DATA_BITS
import DATA_INT
import DATA_WORD
import Char
import Monad
import Exception
import GlaExts hiding (ByteArray, newByteArray, freezeByteArray)
import Array
import IO
import PrelIOBase		( IOError(..), IOErrorType(..)
#if __GLASGOW_HASKELL__ > 411
				, IOException(..)
#endif
				)
import PrelReal			( Ratio(..) )
import PrelIOBase	 	( IO(..) )
import IOExts			( openFileEx, IOModeEx(..) )
#else
import Data.Array.IO
import Data.Array
import Data.Bits
import Data.Int
import Data.Word
import Data.IORef
import Data.Char		( ord, chr )
import Data.Array.Base  	( unsafeRead, unsafeWrite )
import Control.Monad		( when )
import Control.Exception	( throwDyn )
import System.IO as IO
import System.IO.Unsafe		( unsafeInterleaveIO )
import System.IO.Error		( mkIOError, eofErrorType )
import GHC.Real			( Ratio(..) )
import GHC.Exts
import GHC.IOBase	 	( IO(..) )
import GHC.Word			( Word8(..) )
#if __GLASGOW_HASKELL__ < 601
-- openFileEx is available from the lang package, but we want to 
-- be independent of hslibs libraries.
import GHC.Handle		( openFileEx, IOModeEx(..) )
#else
import System.IO		( openBinaryFile )
#endif
#endif

#if __GLASGOW_HASKELL__ < 601
openBinaryFile f mode = openFileEx f (BinaryMode mode)
#endif

#if __GLASGOW_HASKELL__ < 503
type BinArray = MutableByteArray RealWorld Int
newArray_ bounds     = stToIO (newCharArray bounds)
unsafeWrite arr ix e = stToIO (writeWord8Array arr ix e)
unsafeRead  arr ix   = stToIO (readWord8Array arr ix)
#if __GLASGOW_HASKELL__ < 411
newByteArray#        = newCharArray#
#endif
hPutArray h arr sz   = hPutBufBAFull h arr sz
hGetArray h sz       = hGetBufBAFull h sz

mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> Exception
mkIOError t location maybe_hdl maybe_filename
{'fraction_non_alphanumeric': 0.10310476506724224, 'fraction_numerical': 0.013780508052465548, 'mean_word_length': 3.4099560761346996, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5367926', 'n_tokens_mistral': 2246, 'n_tokens_neox': 2098, 'n_words': 657}