keera-hails-reactive-network 0.0.3.3 → 0.1
raw patch · 4 files changed
+180/−10 lines, 4 filesdep +bytestringdep +directorydep +filepathdep ~basenew-uploaderPVP ok
version bump matches the API change (PVP)
Dependencies added: bytestring, directory, filepath, hlint, network-bsd, process, regex-posix
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- keera-hails-reactive-network.cabal +62/−9
- src/Hails/Network.hs +4/−1
- tests/HaddockCoverage.hs +91/−0
- tests/hlint.hs +23/−0
keera-hails-reactive-network.cabal view
@@ -7,16 +7,16 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.0.3.3+Version: 0.1 -- A short (one-line) description of the package. Synopsis: Haskell on Rails - Sockets as Reactive Values -- A longer description of the package.--- Description: +Description: A layer to create RVs that connect to network sockets. -- URL for the project homepage or repository.-Homepage: http://www.keera.es/blog/community/+Homepage: http://www.keera.co.uk/blog/community/ -- The license under which the package is released. License: BSD3@@ -29,10 +29,10 @@ -- An email address to which users can send suggestions, bug reports, -- and patches.-Maintainer: ivan.perez@keera.es+Maintainer: ivan.perez@keera.co.uk -- A copyright notice.--- Copyright: +-- Copyright: Category: Development @@ -40,20 +40,73 @@ -- Extra files to be distributed with the package, such as examples or -- a README.--- Extra-source-files: +-- Extra-source-files: -- Constraint on the version of Cabal needed to build this package.-Cabal-version: >=1.2+cabal-version: >= 1.10 Library+ default-language: Haskell2010+ hs-source-dirs: src/- + ghc-options: -Wall -fno-warn-unused-do-bind -O2 -- Modules exported by the library. Exposed-modules: Hails.Network- + -- Packages needed in order to build this package. Build-depends: base >= 4 && < 5+ , bytestring , keera-hails-reactivevalues , network+ , network-bsd++source-repository head+ type: git+ location: git://github.com/keera-studios/keera-hails+ subdir: keera-hails-reactive-network++-- You can disable the hlint test suite with -f-test-hlint+flag test-hlint+ default: False+ manual: True++-- You can disable the haddock coverage test suite with -f-test-doc-coverage+flag test-doc-coverage+ default: False+ manual: True++test-suite hlint+ type: exitcode-stdio-1.0+ main-is: hlint.hs+ hs-source-dirs: tests+ if !flag(test-hlint)+ buildable: False+ else+ build-depends:+ base,+ hlint >= 1.7++ default-language: Haskell2010+++-- Verify that the code is thoroughly documented+test-suite haddock-coverage+ type: exitcode-stdio-1.0+ main-is: HaddockCoverage.hs+ ghc-options: -Wall+ hs-source-dirs: tests++ if !flag(test-doc-coverage)+ buildable: False+ else+ build-depends:+ base >= 4 && < 5,+ directory,+ filepath,+ process,+ regex-posix++ default-language: Haskell2010+
src/Hails/Network.hs view
@@ -1,9 +1,11 @@ module Hails.Network where +import Data.String (fromString) import Data.List import Data.ReactiveValue import Network.BSD import Network.Socket+import Network.Socket.ByteString (sendTo) -- | Create a UDP sink (a write-only reactive value). udpSink :: HostName -> String -> IO (ReactiveFieldWrite IO String)@@ -18,7 +20,8 @@ -- Send command let sendstr :: String -> IO () sendstr [] = return ()- sendstr omsg = do sent <- sendTo sock omsg (addrAddress serveraddr)+ sendstr omsg = do let bsMsg = fromString omsg+ sent <- sendTo sock bsMsg (addrAddress serveraddr) sendstr (genericDrop sent omsg) return $ ReactiveFieldWrite sendstr
+ tests/HaddockCoverage.hs view
@@ -0,0 +1,91 @@+-----------------------------------------------------------------------------+-- |+-- Module : Main (HaddockCoverage)+-- Copyright : (C) 2015 Ivan Perez+-- License : BSD-style (see the file LICENSE)+-- Maintainer : Ivan Perez <ivan.perez@keera.co.uk>+-- Stability : provisional+-- Portability : portable+--+-- Copyright notice: This file borrows code+-- https://hackage.haskell.org/package/lens-4.7/src/tests/doctests.hsc+-- which is itself licensed BSD-style as well.+--+-- Run haddock on a source tree and report if anything in any+-- module is not documented.+-----------------------------------------------------------------------------+module Main where++import Control.Applicative+import Control.Monad+import Data.List+import System.Directory+import System.Exit+import System.FilePath+import System.IO+import System.Process+import Text.Regex.Posix++main :: IO ()+main = do+ -- Find haskell modules+ -- TODO: Ideally cabal should do this (provide us with the+ -- list of modules). An alternative would be to use cabal haddock+ -- but that would need a --no-html argument or something like that.+ -- Alternatively, we could use cabal haddock with additional arguments.+ --+ -- See:+ -- https://github.com/keera-studios/haddock/commit/d5d752943c4e5c6c9ffcdde4dc136fcee967c495+ -- https://github.com/haskell/haddock/issues/309#issuecomment-150811929+ files <- getSources++ let haddockArgs = [ "--no-warnings", "--ignore-all-exports" ] ++ files+ let cabalArgs = [ "exec", "--", "haddock" ] ++ haddockArgs+ (code, out, _err) <- readProcessWithExitCode "cabal" cabalArgs ""++ -- Filter out coverage lines, and find those that denote undocumented+ -- modules.+ --+ -- TODO: is there a way to annotate a function as self-documenting,+ -- in the same way we do with ANN for hlint?+ let isIncompleteModule :: String -> Bool+ isIncompleteModule line = isCoverageLine line && not (line =~ "^ *100%")+ where isCoverageLine :: String -> Bool+ isCoverageLine line = line =~ "^ *[0-9]+%"++ let incompleteModules :: [String]+ incompleteModules = filter isIncompleteModule $ lines out++ -- Based on the result of haddock, report errors and exit.+ -- Note that, unline haddock, this script does not+ -- output anything to stdout. It uses stderr instead+ -- (as it should).+ case (code, incompleteModules) of+ (ExitSuccess , []) -> return ()+ -- (ExitFailure _, _) -> exitFailure+ (_ , _) -> do+ hPutStrLn stderr "The following modules are not fully documented:"+ mapM_ (hPutStrLn stderr) incompleteModules+ exitFailure++getSources :: IO [FilePath]+getSources = filter isHaskellFile <$> go "src"+ where+ go dir = do+ (dirs, files) <- getFilesAndDirectories dir+ (files ++) . concat <$> mapM go dirs++ isHaskellFile fp = (isSuffixOf ".hs" fp || isSuffixOf ".lhs" fp)+ && not (any (`isSuffixOf` fp) excludedFiles)++ excludedFiles = [ ]++getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])+getFilesAndDirectories dir = do+ c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir+ (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c++-- find-based implementation (not portable)+--+-- getSources :: IO [FilePath]+-- getSources = fmap lines $ readProcess "find" ["src/", "-iname", "*hs"] ""
+ tests/hlint.hs view
@@ -0,0 +1,23 @@+-----------------------------------------------------------------------------+-- |+-- Module : Main (hlint)+-- Copyright : (C) 2013 Edward Kmett+-- License : BSD-style (see the file LICENSE)+-- Maintainer : Edward Kmett <ekmett@gmail.com>+-- Stability : provisional+-- Portability : portable+--+-- This module runs HLint on the lens source tree.+-----------------------------------------------------------------------------+module Main where++import Control.Monad+import Language.Haskell.HLint+import System.Environment+import System.Exit++main :: IO ()+main = do+ args <- getArgs+ hints <- hlint $ ["src", "--cross", "--hint=tests/HLint.hs" ] ++ args+ unless (null hints) exitFailure