~ubuntu-branches/ubuntu/wily/agda-stdlib/wily

« back to all changes in this revision

Viewing changes to ffi/IO/FFI.hs

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2013-05-27 19:29:25 UTC
  • mfrom: (8.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130527192925-q2tadfousmn0xeav
Tags: 0.7-2
Upload to unstable 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
module IO.FFI where
2
2
 
 
3
import Control.Exception (bracketOnError)
 
4
import System.IO
 
5
  (openFile, IOMode(ReadMode), hClose, hFileSize, hGetContents)
 
6
 
 
7
-- | A variant of IO with an extra dummy type parameter.
 
8
 
3
9
type AgdaIO a b = IO b
 
10
 
 
11
-- | Reads a finite file. Raises an exception if the file path refers
 
12
-- to a non-physical file (like @/dev/zero@).
 
13
 
 
14
readFiniteFile :: FilePath -> IO String
 
15
readFiniteFile f = do
 
16
  h <- openFile f ReadMode
 
17
  bracketOnError (return ()) (\_ -> hClose h) (\_ -> hFileSize h)
 
18
  hGetContents h