{-# LANGUAGE MultiParamTypeClasses
,FunctionalDependencies #-}{-
Copyright (C) 2007 John Goerzen <jgoerzen@complete.org>
All rights reserved.
For license and copyright information, see the file COPYRIGHT
-}{- |
Module : Data.ListLike.IO
Copyright : Copyright (C) 2007 John Goerzen
License : BSD3
Maintainer : John Goerzen <jgoerzen@complete.org>
Stability : provisional
Portability: portable
String-like functions
Written by John Goerzen, jgoerzen\@complete.org
-}moduleData.ListLike.IO(ListLikeIO(..))whereimportPreludehiding(length,head,last,null,tail,map,filter,concat,any,lookup,init,all,foldl,foldr,foldl1,foldr1,maximum,minimum,iterate,span,break,takeWhile,dropWhile,reverse,zip,zipWith,sequence,sequence_,mapM,mapM_,concatMap,and,or,sum,product,repeat,replicate,cycle,take,drop,splitAt,elem,notElem,unzip,lines,words,unlines,unwords,putStr,getContents)importqualifiedSystem.IOasIOimportData.ListLike.Base{- | An extension to 'ListLike' for those data types that support
I\/O. These functions mirror those in "System.IO" for the most part. They
also share the same names; see the comments in "Data.ListLike" for help
importing them.
Note that some types may not be capable of lazy reading or writing.
Therefore, the usual semantics of "System.IO" functions regarding laziness
may or may not be available from a particular implementation.
Minimal complete definition:
* hGetLine
* hGetContents
* hGet
* hGetNonBlocking
* hPutStr
-}class(ListLikefullitem)=>ListLikeIOfullitem|full->itemwhere{- | Reads a line from the specified handle -}hGetLine::IO.Handle->IOfull-- | Read entire handle contents. May be done lazily like-- 'System.IO.hGetContents'.hGetContents::IO.Handle->IOfull-- | Read specified number of bytes. See 'System.IO.hGet' for-- particular semantics.hGet::IO.Handle->Int->IOfull-- | Non-blocking read. See 'System.IO.hGetNonBlocking' for more.hGetNonBlocking::IO.Handle->Int->IOfull-- | Writing entire data.hPutStr::IO.Handle->full->IO()-- | Write data plus newline character.hPutStrLn::IO.Handle->full->IO()hPutStrLnfpx=dohPutStrfpxIO.hPutStrLnfp""-- | Read one linegetLine::IOfullgetLine=hGetLineIO.stdin-- | Read entire content from stdin. See 'hGetContents'.getContents::IOfullgetContents=hGetContentsIO.stdin-- | Write data to stdout.putStr::full->IO()putStr=hPutStrIO.stdout-- | Write data plus newline character to stdout.putStrLn::full->IO()putStrLn=hPutStrLnIO.stdout-- | Interact with stdin and stdout by using a function to transform-- input to output. May be lazy. See 'System.IO.interact' for more.interact::(full->full)->IO()interactfunc=doc<-getContentsputStr(funcc)-- | Read file. May be lazy.readFile::FilePath->IOfullreadFilefn=dofp<-IO.openFilefnIO.ReadModehGetContentsfp-- | Write data to file.writeFile::FilePath->full->IO()writeFilefnx=dofp<-IO.openFilefnIO.WriteModehPutStrfpxIO.hClosefp-- | Append data to file.appendFile::FilePath->full->IO()appendFilefnx=dofp<-IO.openFilefnIO.AppendModehPutStrfpxIO.hClosefp