Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- defaultMain :: IO ()
- runCmd :: Command -> IO ()
- inputScriptChunkLength :: Int
- runCmdTranslate :: TranslateArgs -> IO ()
- writeShebanged :: String -> [ByteString] -> IO ()
- makeExecutable :: FilePath -> IO ()
- chunkByteString :: Int -> ByteString -> [ByteString]
- runCmdExec :: ExecArgs -> IO ()
- findNextScript :: FilePath -> Int -> IO (Maybe FilePath)
- getShebangedIndex :: FilePath -> Either String Int
- split :: forall a. (a -> Bool) -> [a] -> NonEmpty [a]
Documentation
We need things from QuickCheck for some of the tests.
>>>
import Test.QuickCheck
defaultMain :: IO () Source #
inputScriptChunkLength :: Int Source #
The length of chunks of the input script.
The input script will be chunked into parts of this many bytes, then base-64 encoded (which increases the length by about 33%). This base-64-encoded string will then be put into the shebang line of all the shebanged scripts.
Note that Linux has a limit on how long a shebang line can be, so in practice this has to be below 150 characters or so.
runCmdTranslate :: TranslateArgs -> IO () Source #
writeShebanged :: String -> [ByteString] -> IO () Source #
makeExecutable :: FilePath -> IO () Source #
chunkByteString :: Int -> ByteString -> [ByteString] Source #
runCmdExec :: ExecArgs -> IO () Source #
split :: forall a. (a -> Bool) -> [a] -> NonEmpty [a] Source #
Split a list based on a predicate.
>>>
split (== ' ') "hello world my name is bob"
"hello" :| ["world","my","name","is","bob"]
A predicate of
splits on everything, leaving you with
a list of empty lists, with one more entry than your original list:const
True
>>>
split (const True) "bye"
"" :| ["","",""]
A predicate of
produces no splits:const
False
>>>
split (const False) "bye"
"bye" :| []
An empty list doesn't get split, regardless of the predicate:
\(Fun _ f) -> split f "" == ("" :| [])