From 7bd11859aeab19130e51a1607fd262f6a23b58ca Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Mon, 20 Jun 2016 12:27:24 +0200 Subject: add DeriveDataTypeable extension to Exception --- src/Propellor/Types/Exception.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Types/Exception.hs b/src/Propellor/Types/Exception.hs index 3a810d55..9fdcab93 100644 --- a/src/Propellor/Types/Exception.hs +++ b/src/Propellor/Types/Exception.hs @@ -1,10 +1,11 @@ +{-# LANGUAGE DeriveDataTypeable #-} module Propellor.Types.Exception where import Data.Typeable import Control.Exception --- | Normally when an exception is encountered while propellor is --- ensuring a property, the property fails, but propellor robustly +-- | Normally when an exception is encountered while propellor is +-- ensuring a property, the property fails, but propellor robustly -- continues on to the next property. -- -- This is the only exception that will stop the entire propellor run, -- cgit v1.2.3 From 7be42508a596fc2caf55fc0a6596857fb7d60253 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Mon, 20 Jun 2016 12:33:49 +0200 Subject: Exception: import Control.Applicative (old ghc compatibility) --- src/Propellor/Exception.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Propellor') diff --git a/src/Propellor/Exception.hs b/src/Propellor/Exception.hs index 3ab783bf..c6eee099 100644 --- a/src/Propellor/Exception.hs +++ b/src/Propellor/Exception.hs @@ -10,6 +10,7 @@ import Utility.Exception import Control.Exception (AsyncException) import Control.Monad.Catch import Control.Monad.IO.Class (MonadIO) +import Control.Applicative -- | Catches all exceptions (except for `StopPropellorException` and -- `AsyncException`) and returns FailedChange. -- cgit v1.2.3 From c10ec2d3eb3b4195cc0d2234d2ac227dbd43629c Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Mon, 20 Jun 2016 12:35:52 +0200 Subject: Exception: import Prelude after Control.Applicative to prevent warning --- src/Propellor/Exception.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Propellor') diff --git a/src/Propellor/Exception.hs b/src/Propellor/Exception.hs index c6eee099..b297a740 100644 --- a/src/Propellor/Exception.hs +++ b/src/Propellor/Exception.hs @@ -11,6 +11,7 @@ import Control.Exception (AsyncException) import Control.Monad.Catch import Control.Monad.IO.Class (MonadIO) import Control.Applicative +import Prelude -- | Catches all exceptions (except for `StopPropellorException` and -- `AsyncException`) and returns FailedChange. -- cgit v1.2.3 From c5a1503c0c2eb1974e6d3491db61ed75ce2ddd61 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Mon, 20 Jun 2016 16:25:34 +0200 Subject: Exception: prevent use of Control.Applicative (ghc compatibility) --- src/Propellor/Exception.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Exception.hs b/src/Propellor/Exception.hs index b297a740..49977370 100644 --- a/src/Propellor/Exception.hs +++ b/src/Propellor/Exception.hs @@ -10,7 +10,6 @@ import Utility.Exception import Control.Exception (AsyncException) import Control.Monad.Catch import Control.Monad.IO.Class (MonadIO) -import Control.Applicative import Prelude -- | Catches all exceptions (except for `StopPropellorException` and @@ -30,4 +29,4 @@ catchPropellor' a onerr = a `catches` -- | Catches all exceptions (except for `StopPropellorException` and -- `AsyncException`). tryPropellor :: MonadCatch m => m a -> m (Either SomeException a) -tryPropellor a = (Right <$> a) `catchPropellor'` (pure . Left) +tryPropellor a = fmap Right a `catchPropellor'` (return . Left) -- cgit v1.2.3 From e0471e95ea3f3429eab57378712aab7e9794acb5 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Mon, 20 Jun 2016 16:30:24 +0200 Subject: Exception: prevent use of Functor --- src/Propellor/Exception.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Exception.hs b/src/Propellor/Exception.hs index 49977370..b62c558a 100644 --- a/src/Propellor/Exception.hs +++ b/src/Propellor/Exception.hs @@ -29,4 +29,4 @@ catchPropellor' a onerr = a `catches` -- | Catches all exceptions (except for `StopPropellorException` and -- `AsyncException`). tryPropellor :: MonadCatch m => m a -> m (Either SomeException a) -tryPropellor a = fmap Right a `catchPropellor'` (return . Left) +tryPropellor a = (return . Right =<< a) `catchPropellor'` (return . Left) -- cgit v1.2.3 From 255a52c13ccb0e78744c32c7cbb169682e2b947a Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Mon, 20 Jun 2016 16:33:34 +0200 Subject: Property: prevent ambiguous occurences --- src/Propellor/Property.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index f23fd3ba..7ee9397e 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -54,7 +54,7 @@ import System.Posix.Files import qualified Data.Hash.MD5 as MD5 import Data.List import Control.Applicative -import Data.Foldable +import Data.Foldable hiding (and, elem) import Prelude import Propellor.Types @@ -83,7 +83,7 @@ flagFile' p getflagfile = adjustPropertySatisfy p $ \satisfy -> do go _ _ True = return NoChange go satisfy flagfile False = do r <- satisfy - when (r == MadeChange) $ liftIO $ + when (r == MadeChange) $ liftIO $ unlessM (doesFileExist flagfile) $ do createDirectoryIfMissing True (takeDirectory flagfile) writeFile flagfile "" @@ -279,7 +279,7 @@ pickOS , SingI c -- Would be nice to have this constraint, but -- union will not generate metatypes lists with the same - -- order of OS's as is used everywhere else. So, + -- order of OS's as is used everywhere else. So, -- would need a type-level sort. --, Union a b ~ c ) @@ -297,7 +297,7 @@ pickOS a b = c `addChildren` [toChildProperty a, toChildProperty b] then getSatisfy b else unsupportedOS' matching Nothing _ = False - matching (Just o) p = + matching (Just o) p = Targeting (systemToTargetOS o) `elem` fromSing (proptype p) -- cgit v1.2.3