module Language.PureScript.Ide.Filter.Declaration ( DeclarationType(..) ) where import Protolude hiding (isPrefixOf) import Control.Monad.Fail (fail) import Data.Aeson (FromJSON(..), ToJSON(..), withText) data DeclarationType = Value | Type | Synonym | DataConstructor | TypeClass | ValueOperator | TypeOperator | Module deriving (Int -> DeclarationType -> ShowS [DeclarationType] -> ShowS DeclarationType -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [DeclarationType] -> ShowS $cshowList :: [DeclarationType] -> ShowS show :: DeclarationType -> String $cshow :: DeclarationType -> String showsPrec :: Int -> DeclarationType -> ShowS $cshowsPrec :: Int -> DeclarationType -> ShowS Show, DeclarationType -> DeclarationType -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: DeclarationType -> DeclarationType -> Bool $c/= :: DeclarationType -> DeclarationType -> Bool == :: DeclarationType -> DeclarationType -> Bool $c== :: DeclarationType -> DeclarationType -> Bool Eq, Eq DeclarationType DeclarationType -> DeclarationType -> Bool DeclarationType -> DeclarationType -> Ordering DeclarationType -> DeclarationType -> DeclarationType forall a. Eq a -> (a -> a -> Ordering) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> a) -> (a -> a -> a) -> Ord a min :: DeclarationType -> DeclarationType -> DeclarationType $cmin :: DeclarationType -> DeclarationType -> DeclarationType max :: DeclarationType -> DeclarationType -> DeclarationType $cmax :: DeclarationType -> DeclarationType -> DeclarationType >= :: DeclarationType -> DeclarationType -> Bool $c>= :: DeclarationType -> DeclarationType -> Bool > :: DeclarationType -> DeclarationType -> Bool $c> :: DeclarationType -> DeclarationType -> Bool <= :: DeclarationType -> DeclarationType -> Bool $c<= :: DeclarationType -> DeclarationType -> Bool < :: DeclarationType -> DeclarationType -> Bool $c< :: DeclarationType -> DeclarationType -> Bool compare :: DeclarationType -> DeclarationType -> Ordering $ccompare :: DeclarationType -> DeclarationType -> Ordering Ord) instance FromJSON DeclarationType where parseJSON :: Value -> Parser DeclarationType parseJSON = forall a. String -> (Text -> Parser a) -> Value -> Parser a withText String "Declaration type tag" forall a b. (a -> b) -> a -> b $ \case Text "value" -> forall (f :: * -> *) a. Applicative f => a -> f a pure DeclarationType Value Text "type" -> forall (f :: * -> *) a. Applicative f => a -> f a pure DeclarationType Type Text "synonym" -> forall (f :: * -> *) a. Applicative f => a -> f a pure DeclarationType Synonym Text "dataconstructor" -> forall (f :: * -> *) a. Applicative f => a -> f a pure DeclarationType DataConstructor Text "typeclass" -> forall (f :: * -> *) a. Applicative f => a -> f a pure DeclarationType TypeClass Text "valueoperator" -> forall (f :: * -> *) a. Applicative f => a -> f a pure DeclarationType ValueOperator Text "typeoperator" -> forall (f :: * -> *) a. Applicative f => a -> f a pure DeclarationType TypeOperator Text "module" -> forall (f :: * -> *) a. Applicative f => a -> f a pure DeclarationType Module Text s -> forall (m :: * -> *) a. MonadFail m => String -> m a fail (String "Unknown declaration type: " forall a. Semigroup a => a -> a -> a <> forall a b. (Show a, StringConv String b) => a -> b show Text s) instance ToJSON DeclarationType where toJSON :: DeclarationType -> Value toJSON = forall a. ToJSON a => a -> Value toJSON forall b c a. (b -> c) -> (a -> b) -> a -> c . \case DeclarationType Value -> Text "value" :: Text DeclarationType Type -> Text "type" DeclarationType Synonym -> Text "synonym" DeclarationType DataConstructor -> Text "dataconstructor" DeclarationType TypeClass -> Text "typeclass" DeclarationType ValueOperator -> Text "valueoperator" DeclarationType TypeOperator -> Text "typeoperator" DeclarationType Module -> Text "module"