[#20] Add 'isSuccessful' predicate (#22)

Resolves #20
This commit is contained in:
Veronika Romashkina 2020-08-31 12:50:27 +01:00 committed by GitHub
parent 9fb7d02c13
commit 928f56359b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 7 deletions

View File

@ -18,11 +18,11 @@ jobs:
- "8.2.2"
- "8.4.4"
- "8.6.5"
- "8.8.3"
- "8.10.1"
- "8.8.4"
- "8.10.2"
exclude:
- os: macOS-latest
ghc: 8.8.3
ghc: 8.8.4
- os: macOS-latest
ghc: 8.6.5
- os: macOS-latest
@ -62,7 +62,7 @@ jobs:
strategy:
matrix:
stack: ["2.1.3"]
ghc: ["8.8.3"]
ghc: ["8.10.2"]
steps:
- uses: actions/checkout@v2

View File

@ -3,6 +3,12 @@
`shellmet` uses [PVP Versioning][1].
The changelog is available [on GitHub][2].
## Unreleased
* [#20](https://github.com/kowainik/shellmet/issues/20):
Add `isSuccess` function to show if the command succeded.
* Upgrade GHC from `8.8.3` to `8.8.4`, `8.10.1` to `8.10.2`.
## 0.0.3.1 — May 7, 2020
* [#18](https://github.com/kowainik/shellmet/issues/18):

View File

@ -17,8 +17,8 @@ extra-doc-files: README.md
tested-with: GHC == 8.2.2
GHC == 8.4.4
GHC == 8.6.5
GHC == 8.8.3
GHC == 8.10.1
GHC == 8.8.4
GHC == 8.10.2
source-repository head
type: git

View File

@ -20,6 +20,7 @@ module Shellmet
( ($|)
, ($^)
, ($?)
, isSuccess
) where
import Control.Exception (catch)
@ -80,3 +81,13 @@ infixl 4 $?
($?) :: IO a -> IO a -> IO a
action $? handler = action `catch` \(_ :: IOError) -> handler
{-# INLINE ($?) #-}
{- | Returns the indicator of if the command succeded or not.
>>> isSuccess $ "echo" ["Hello world!"]
echo 'Hello world!'
Hello world!
True
-}
isSuccess :: IO a -> IO Bool
isSuccess action = (True <$ action) $? pure False

View File

@ -1 +1 @@
resolver: lts-15.11
resolver: nightly-2020-08-30