1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 13:02:37 +03:00

Merge pull request #2331 from github/add-fromright-fromleft

Add fromRight/fromLeft to Prologue and according hlint rules.
This commit is contained in:
Patrick Thomson 2019-01-11 15:45:58 -05:00 committed by GitHub
commit dfa73e5e50
3 changed files with 8 additions and 3 deletions

View File

@ -67,6 +67,8 @@
# Conveniences
- warning: {lhs: maybe a pure, rhs: maybeM a, name: Use maybeM}
- warning: {lhs: either (const a) id, rhs: fromRight a, name: use fromRight}
- warning: {lhs: either id (const a), rhs: fromLeft a, name: use fromRight}
# Applicative style
- warning: {lhs: f <$> pure a <*> b, rhs: f a <$> b, name: Avoid redundant pure}

View File

@ -2,21 +2,23 @@
module Data.ImportPath (IsRelative(..), ImportPath(..), importPath, toName, defaultAlias) where
import Prologue
import Data.Aeson
import qualified Data.Text as T
import Data.Abstract.Name
import Proto3.Suite
import qualified Proto3.Wire.Decode as Decode
import qualified Proto3.Wire.Encode as Encode
import Data.Abstract.Path (stripQuotes)
import System.FilePath.Posix
import Data.Abstract.Name
import Data.Abstract.Path (stripQuotes)
data IsRelative = Unknown | Relative | NonRelative
deriving (Bounded, Enum, Finite, MessageField, Named, Eq, Generic, Hashable, Ord, Show, ToJSON, NFData)
instance Primitive IsRelative where
encodePrimitive = Encode.enum
decodePrimitive = either (const def) id <$> Decode.enum
decodePrimitive = fromRight def <$> Decode.enum
primType _ = Named (Single (nameOf (Proxy @IsRelative)))
instance HasDefault IsRelative where

View File

@ -16,6 +16,7 @@ import Data.Bits as X
import Data.ByteString as X (ByteString)
import Data.Coerce as X
import Data.Functor.Both as X (Both (Both), runBothWith)
import Data.Either as X (fromLeft, fromRight)
import Data.IntMap as X (IntMap)
import Data.IntSet as X (IntSet)
import Data.Ix as X (Ix (..))