packages feed

keera-hails-mvc-environment-gtk 0.0.3.3 → 0.5.0

raw patch · 6 files changed

+292/−93 lines, 6 filesdep +directorydep +filepathdep +hlintdep ~basenew-uploader

Dependencies added: directory, filepath, hlint, process, regex-posix

Dependency ranges changed: base

Files

LICENSE view
@@ -1,4 +1,5 @@-Copyright (c)2012, Ivan Perez+Copyright (c) 2013-2020, Keera Studios Ltd+Copyright (c) 2010-2012, Ivan Perez  All rights reserved. @@ -13,9 +14,9 @@       disclaimer in the documentation and/or other materials provided       with the distribution. -    * Neither the name of Ivan Perez nor the names of other-      contributors may be used to endorse or promote products derived-      from this software without specific prior written permission.+    * Neither the name of Ivan Perez, nor the name of Keera Studios, nor the+      names of other contributors may be used to endorse or promote products+      derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
keera-hails-mvc-environment-gtk.cabal view
@@ -1,61 +1,114 @@--- hails.cabal auto-generated by cabal init. For additional options,--- see--- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.--- The name of the package.-Name:                keera-hails-mvc-environment-gtk+-- Copyright   : (C) Keera Studios Ltd, 2013+-- License     : All Rights Reserved+-- Maintainer  : support@keera.co.uk+--+cabal-version: >= 1.10+build-type:    Simple --- 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+name:          keera-hails-mvc-environment-gtk+version:       0.5.0+author:        Ivan Perez+maintainer:    support@keera.co.uk+homepage:      http://www.keera.co.uk/blog/community/+license:       BSD3+license-file:  LICENSE+category:      Development+synopsis:      Haskell on Gtk rails - Gtk-based global environment for MVC applications+description:+  Keera Hails is a rapid application development system.+  .+  The idea behind Hails is that you should be able to build cross platform+  applications with minimal effort, very quickly, and the result should be easy+  to maintain.+  .+  This package defines an environment that combines a model and a view, where+  the latter is implemented using GTK+. Users of this package can install+  additional conditions that keep both in sync using keera-hails-reactivevalues+  to define such conditions. --- A short (one-line) description of the package.-Synopsis:            Haskell on Gtk rails - Gtk-based global environment for MVC applications --- A longer description of the package.--- Description:         +source-repository head+ type: git+ location: git://github.com/keera-studios/keera-hails+ subdir: keera-hails-mvc-environment-gtk --- URL for the project homepage or repository.-Homepage:            http://www.keera.es/blog/community/ --- The license under which the package is released.-License:             BSD3+-- You can disable the hlint test suite with -f-test-hlint+flag test-hlint+  default: False+  manual:  True --- The file containing the license text.-License-file:        LICENSE+-- You can disable the haddock coverage test suite with -f-test-doc-coverage+flag test-doc-coverage+  default: False+  manual:  True --- The package author(s).-Author:              Ivan Perez --- An email address to which users can send suggestions, bug reports,--- and patches.-Maintainer:          ivan.perez@keera.es---- A copyright notice.--- Copyright:           --Category:            Development+library -Build-type:          Simple+  exposed-modules:+    Hails.MVC.GenericCombinedEnvironment+    Hails.MVC.DefaultGtkEnvironment --- Extra files to be distributed with the package, such as examples or--- a README.--- Extra-source-files:  +  build-depends:+      base >= 4 && < 5+    , keera-hails-mvc-model-protectedmodel+    , keera-hails-mvc-view+    , keera-hails-mvc-view-gtk --- Constraint on the version of Cabal needed to build this package.-Cabal-version:       >=1.2+  default-language: Haskell2010 -Library   hs-source-dirs: src/-  +   ghc-options: -Wall -fno-warn-unused-do-bind -O2 -  -- Modules exported by the library.-  Exposed-modules: Hails.MVC.GenericCombinedEnvironment-                 , Hails.MVC.DefaultGtkEnvironment-  -  -- Packages needed in order to build this package.-  Build-depends: base >= 4 && < 5-               , keera-hails-mvc-model-protectedmodel-               , keera-hails-mvc-view-               , keera-hails-mvc-view-gtk++test-suite hlint++  type:+    exitcode-stdio-1.0++  main-is:+    HLintMain.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/MVC/DefaultGtkEnvironment.hs view
@@ -1,18 +1,35 @@--- | The environment that contains both the view and the model.+-- | Environment that contains both a model and a view. --+--   Combined enviroments (CEnvs) are types that combine a model and+--   a view. They allow for easy installing of rules that keep both+--   in sync.+--+--   This module provides a slightly more abstract and convenient interface to+--   'Hails.MVC.GenericCombinedEnvironment', in which the view is extacted from+--   the wrapper when it is accessed.+--+-- Copyright   : (C) Keera Studios Ltd, 2013+-- License     : BSD3+-- Maintainer  : support@keera.co.uk module Hails.MVC.DefaultGtkEnvironment-   ( view-   , GEnv.model-   , GEnv.createCEnv-   , GEnv.installCondition-   , GEnv.installConditions-   )+    ( -- * Combined Environments (CEnvs)+      GEnv.CEnv+      -- * CEnv construction+    , GEnv.createCEnv+      -- * CEnv access+    , view+    , GEnv.model+      -- * CEnv updates+    , GEnv.installCondition+    , GEnv.installConditions+    )   where  -- Internal libraries-import qualified Hails.MVC.View.GtkView               as GtkView import qualified Hails.MVC.GenericCombinedEnvironment as GEnv-import           Hails.MVC.Model.ReactiveModel+import           Hails.MVC.Model.ReactiveModel        (Event)+import qualified Hails.MVC.View.GtkView               as GtkView +-- | View in the CEnv of an MVC application. view :: (GtkView.GtkGUI a, Event c) => GEnv.CEnv a b c -> a view = GtkView.getGUI . GEnv.view
src/Hails/MVC/GenericCombinedEnvironment.hs view
@@ -1,52 +1,63 @@--- | This module contains the necessary functions to manipulate a global--- environment that gives access to the view and the model in a MVC-structured--- program with a Gtk View.+-- | A combined environment combines a view and a model in a MVC-structured+--   application. The environment can be passed around to the controller, which+--   must update each side accordingly and keep both in sync. ----- It contains the necessary functions to create an environment--- that holds a View and a Protected Reactive Model.+--   In this package, the view is built using GTK, and the model is implemented+--   as a 'ProtectedModel' (a safe-thread structure with a fine-grained notion+--   of change). ----- Although this code is stable, the design is experimental. Usage in real--- applications should give way to better implementations.+-- Copyright   : (C) Keera Studios Ltd, 2013+-- License     : BSD3+-- Maintainer  : support@keera.co.uk module Hails.MVC.GenericCombinedEnvironment-   ( CEnv (view, model)-   , createCEnv-   , installConditions-   , installCondition-   )+    ( -- * Combined Environments (CEnvs)+      CEnv (view, model)+      -- * CEnv construction+    , createCEnv+      -- * CEnv updates+    , installCondition+    , installConditions+    )   where  -- Internal libraries-import Hails.MVC.View-import Hails.MVC.View.GtkView-import Hails.MVC.Model.ProtectedModel-import Hails.MVC.Model.ReactiveModel (Event)+import Hails.MVC.Model.ProtectedModel (ProtectedModel, startProtectedModel)+import Hails.MVC.Model.ReactiveModel  (Event)+import Hails.MVC.View                 (createView)+import Hails.MVC.View.GtkView         (GtkGUI, GtkView) --- | Given a GUI and a Type for the events, a CEnv contains a View and a--- Protected Model.+-- | Given a GUI and a type for the events that capture the changes inside the+--   model, a CEnv contains a view and a protected model. data (GtkGUI a, Event c) => CEnv a b c = CEnv-  { view  :: GtkView a-  , model :: ProtectedModel b c+  { view  :: GtkView a          -- ^ View in the CEnv of an MVC application.+  , model :: ProtectedModel b c -- ^ Model in the CEnv of an MVC application.   } --- | To create an Environment, we just need to provide the--- default internal model. The initialisation operations--- for the view and the protected model are called internally.+-- | Create a combined environment from a given model and initialize the+--   model and the view. The default model must be provided explicitly.+--   The initialisation operations for the view and the protected model+--   are called internally. createCEnv :: (GtkGUI a, Event c) => b -> IO (CEnv a b c)-createCEnv emptyBM = do-  m <- startProtectedModel emptyBM-  v <- createView-  return CEnv { view = v, model = m }+createCEnv emptyBM = CEnv <$> createView+                          <*> startProtectedModel emptyBM --- | Installs a condition in the Combined Environment.---+-- | Install a condition in a Combined Environment. Conditions, or+--   reactive rules, are used to keep both the model and the view+--   in sync.+ -- NOTE: This is an experimental function and might be removed in the future.-installCondition :: (GtkGUI a, Event c) => CEnv a b c -> (CEnv a b c -> IO()) -> IO()+installCondition :: (GtkGUI a, Event c)+                 => CEnv a b c+                 -> (CEnv a b c -> IO ())+                 -> IO () installCondition cenv cond = cond cenv --- | Installs several conditions in the Combined Environment.---+-- | Install several conditions in a Combined Environment. Conditions, or+--   reactive rules, are used to keep both the model and the view+--   in sync.+ -- FIXME: I really don't like the syntax---   installConditions cenv +--   installConditions cenv --      [ rv1 =:= rf1 --      , ... --      ]@@ -59,5 +70,8 @@ --   Which means that I would have to define a monad. -- -- NOTE: This is an experimental function and might be removed in the future.-installConditions :: (GtkGUI a, Event c) => CEnv a b c -> [ CEnv a b c -> IO() ] -> IO ()+installConditions :: (GtkGUI a, Event c)+                  => CEnv a b c+                  -> [CEnv a b c -> IO ()]+                  -> IO () installConditions cenv conds = mapM_ (installCondition cenv) conds
+ tests/HLintMain.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
+ 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"] ""