Browse Source

Cleaned extension directives

Marcos Dumay de Medeiros 8 years ago
parent
commit
99bba56ddf

+ 23 - 22
src/System/IO/Uniform.hs

@@ -1,13 +1,10 @@
 {-# LANGUAGE ExistentialQuantification #-}
--- {-# LANGUAGE OverloadedStrings #-}
--- {-# LANGUAGE ForeignFunctionInterface #-}
--- {-# LANGUAGE InterruptibleFFI #-}
--- {-# LANGUAGE EmptyDataDecls #-}
 
--- |
--- Uniform-IO provides a typeclass for uniform access of different types of targets,
--- and implementations for abstracting standard streams, files and network connections.
--- This module also provides TLS wraping over other IO targets.
+{- |
+Uniform-IO provides a typeclass for uniform access of different types of targets,
+and implementations for abstracting standard streams, files and network connections.
+This module also provides TLS wraping over other IO targets.
+-}
 module System.IO.Uniform (
   UniformIO(..),
   TlsSettings(..),
@@ -22,16 +19,17 @@ import System.IO.Error
 
 import Data.Default.Class
 
--- |
--- Typeclass for uniform IO targets.
+-- | Typeclass for uniform IO targets.
 class UniformIO a where
-  -- | uRead fd n
-  --
-  --  Reads a block of at most n bytes of data from the IO target.
-  --  Reading will block if there's no data available, but will return immediately
-  --  if any amount of data is availble.
-  --
-  --  Must thow System.IO.Error.EOFError if reading beihond EOF.
+  {- |
+  uRead fd n
+  
+  Reads a block of at most n bytes of data from the IO target.
+  Reading will block if there's no data available, but will return immediately
+  if any amount of data is availble.
+    
+  Must thow System.IO.Error.EOFError if reading beihond EOF.
+  -}
   uRead  :: a -> Int -> IO ByteString
   -- | uPut fd text
   --
@@ -67,11 +65,14 @@ data TlsSettings = TlsSettings {tlsPrivateKeyFile :: String, tlsCertificateChain
 instance Default TlsSettings where
   def = TlsSettings "" "" ""
   
--- | mapOverInput io block_size f initial
---   Reads io untill the end of file, evaluating a(i) <- f a(i-1) read_data
---   where a(0) = initial and the last value after io reaches EOF is returned.
---
---   Notice that the length of read_data might not be equal block_size.
+{- |
+mapOverInput io block_size f initial
+
+Reads io untill the end of file, evaluating a(i) <- f a(i-1) read_data
+where a(0) = initial and the last value after io reaches EOF is returned.
+
+Notice that the length of read_data might not be equal block_size.
+-}
 mapOverInput :: forall a io. UniformIO io => io -> Int -> (a -> ByteString -> IO a) -> a -> IO a
 mapOverInput io block f initial = do
   a <- tryIOError $ uRead io block

+ 1 - 5
src/System/IO/Uniform/ByteString.hs

@@ -1,8 +1,4 @@
--- {-# LANGUAGE OverloadedStrings #-}
--- {-# LANGUAGE ExistentialQuantification #-}
--- {-# LANGUAGE ForeignFunctionInterface #-}
--- {-# LANGUAGE InterruptibleFFI #-}
--- {-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 module System.IO.Uniform.ByteString (
   ByteStringIO,

+ 5 - 4
src/System/IO/Uniform/External.hs

@@ -1,6 +1,4 @@
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE InterruptibleFFI #-}
-{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE ForeignFunctionInterface, InterruptibleFFI, EmptyDataDecls #-}
 
 module System.IO.Uniform.External where
 
@@ -15,9 +13,12 @@ data Nethandler
 newtype BoundedPort = BoundedPort {lis :: (Ptr Nethandler)}
 data Ds
 data TlsDs
+-- | UniformIO IP connections.
 data SocketIO = SocketIO {sock :: (Ptr Ds)} | TlsSocketIO {bio :: (Ptr TlsDs)}
+-- | UniformIO type for file IO.
 newtype FileIO = FileIO {fd :: (Ptr Ds)}
-data StdIO
+-- | UniformIO that reads from stdin and writes to stdout.
+data StdIO = StdIO
 
 closeFd :: Fd -> IO ()
 closeFd (Fd f) = c_closeFd f

+ 0 - 6
src/System/IO/Uniform/File.hs

@@ -1,9 +1,3 @@
--- {-# LANGUAGE OverloadedStrings #-}
--- {-# LANGUAGE ExistentialQuantification #-}
--- {-# LANGUAGE ForeignFunctionInterface #-}
--- {-# LANGUAGE InterruptibleFFI #-}
--- {-# LANGUAGE EmptyDataDecls #-}
-
 module System.IO.Uniform.File (
   FileIO,
   openFile

+ 0 - 6
src/System/IO/Uniform/Network.hs

@@ -1,9 +1,3 @@
--- {-# LANGUAGE OverloadedStrings #-}
--- {-# LANGUAGE ExistentialQuantification #-}
--- {-# LANGUAGE ForeignFunctionInterface #-}
--- {-# LANGUAGE InterruptibleFFI #-}
--- {-# LANGUAGE EmptyDataDecls #-}
-
 module System.IO.Uniform.Network (
   SocketIO,
   BoundedPort,

+ 1 - 23
src/System/IO/Uniform/Std.hs

@@ -1,36 +1,14 @@
--- {-# LANGUAGE OverloadedStrings #-}
--- {-# LANGUAGE ExistentialQuantification #-}
--- {-# LANGUAGE ForeignFunctionInterface #-}
--- {-# LANGUAGE InterruptibleFFI #-}
--- {-# LANGUAGE EmptyDataDecls #-}
-
 module System.IO.Uniform.Std (
-  StdIO
+  StdIO(StdIO)
   ) where
 
 import System.IO.Uniform
 import System.IO.Uniform.External
 
 import Foreign
---import Foreign.C.Types
---import Foreign.C.String
 import Foreign.C.Error
---import qualified Data.IP as IP
---import Data.ByteString (ByteString)
 import qualified Data.ByteString as BS
---import qualified Data.ByteString.Lazy as LBS
---import qualified Data.ByteString.Builder as BSBuild
---import qualified Data.List as L
---import Control.Exception
---import Control.Applicative ((<$>))
---import Data.Monoid (mappend)
---import qualified Network.Socket as Soc
---import System.IO.Error
---import Control.Concurrent.MVar
-
---import Data.Default.Class
 
---import System.Posix.Types (Fd(..))
 -- | UniformIO that reads from stdin and writes to stdout.
 instance UniformIO StdIO where
   uRead _ n = do

+ 5 - 3
uniform-io.cabal

@@ -90,13 +90,15 @@ library
 
   -- LANGUAGE extensions used by modules in this package.
   other-extensions:
-      OverloadedStrings,
-      ExistentialQuantification,
+      OverloadedStrings
+      ExistentialQuantification
       ForeignFunctionInterface
+      InterruptibleFFI
+      EmptyDataDecls
   
   -- Other library packages from which modules are imported.
   build-depends:
-      base >=4.7 && <5.0,
+      base >=4.7 && <4.8,
       iproute >=1.4 && <2.0,
       bytestring >=0.10 && <1.0,
       network >=2.4 && <3.0,