{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE TypeOperators #-}
module Language.LSP.Types.Common (
type (|?) (..)
, toEither
, List (..)
, Empty (..)
, Int32
, UInt ) where
import Control.Applicative
import Control.DeepSeq
import Data.Aeson
import Data.Hashable
import Data.Int (Int32)
import Data.Mod.Word
import Text.Read (Read(readPrec))
import GHC.Generics hiding (UInt)
import GHC.TypeNats hiding (Mod)
import Data.Bifunctor (bimap)
newtype UInt = UInt (Mod (2^31))
deriving newtype (Integer -> UInt
UInt -> UInt
UInt -> UInt -> UInt
(UInt -> UInt -> UInt)
-> (UInt -> UInt -> UInt)
-> (UInt -> UInt -> UInt)
-> (UInt -> UInt)
-> (UInt -> UInt)
-> (UInt -> UInt)
-> (Integer -> UInt)
-> Num UInt
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: UInt -> UInt -> UInt
+ :: UInt -> UInt -> UInt
$c- :: UInt -> UInt -> UInt
- :: UInt -> UInt -> UInt
$c* :: UInt -> UInt -> UInt
* :: UInt -> UInt -> UInt
$cnegate :: UInt -> UInt
negate :: UInt -> UInt
$cabs :: UInt -> UInt
abs :: UInt -> UInt
$csignum :: UInt -> UInt
signum :: UInt -> UInt
$cfromInteger :: Integer -> UInt
fromInteger :: Integer -> UInt
Num, UInt
UInt -> UInt -> Bounded UInt
forall a. a -> a -> Bounded a
$cminBound :: UInt
minBound :: UInt
$cmaxBound :: UInt
maxBound :: UInt
Bounded, Int -> UInt
UInt -> Int
UInt -> [UInt]
UInt -> UInt
UInt -> UInt -> [UInt]
UInt -> UInt -> UInt -> [UInt]
(UInt -> UInt)
-> (UInt -> UInt)
-> (Int -> UInt)
-> (UInt -> Int)
-> (UInt -> [UInt])
-> (UInt -> UInt -> [UInt])
-> (UInt -> UInt -> [UInt])
-> (UInt -> UInt -> UInt -> [UInt])
-> Enum UInt
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: UInt -> UInt
succ :: UInt -> UInt
$cpred :: UInt -> UInt
pred :: UInt -> UInt
$ctoEnum :: Int -> UInt
toEnum :: Int -> UInt
$cfromEnum :: UInt -> Int
fromEnum :: UInt -> Int
$cenumFrom :: UInt -> [UInt]
enumFrom :: UInt -> [UInt]
$cenumFromThen :: UInt -> UInt -> [UInt]
enumFromThen :: UInt -> UInt -> [UInt]
$cenumFromTo :: UInt -> UInt -> [UInt]
enumFromTo :: UInt -> UInt -> [UInt]
$cenumFromThenTo :: UInt -> UInt -> UInt -> [UInt]
enumFromThenTo :: UInt -> UInt -> UInt -> [UInt]
Enum, UInt -> UInt -> Bool
(UInt -> UInt -> Bool) -> (UInt -> UInt -> Bool) -> Eq UInt
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UInt -> UInt -> Bool
== :: UInt -> UInt -> Bool
$c/= :: UInt -> UInt -> Bool
/= :: UInt -> UInt -> Bool
Eq, Eq UInt
Eq UInt =>
(UInt -> UInt -> Ordering)
-> (UInt -> UInt -> Bool)
-> (UInt -> UInt -> Bool)
-> (UInt -> UInt -> Bool)
-> (UInt -> UInt -> Bool)
-> (UInt -> UInt -> UInt)
-> (UInt -> UInt -> UInt)
-> Ord UInt
UInt -> UInt -> Bool
UInt -> UInt -> Ordering
UInt -> UInt -> UInt
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
$ccompare :: UInt -> UInt -> Ordering
compare :: UInt -> UInt -> Ordering
$c< :: UInt -> UInt -> Bool
< :: UInt -> UInt -> Bool
$c<= :: UInt -> UInt -> Bool
<= :: UInt -> UInt -> Bool
$c> :: UInt -> UInt -> Bool
> :: UInt -> UInt -> Bool
$c>= :: UInt -> UInt -> Bool
>= :: UInt -> UInt -> Bool
$cmax :: UInt -> UInt -> UInt
max :: UInt -> UInt -> UInt
$cmin :: UInt -> UInt -> UInt
min :: UInt -> UInt -> UInt
Ord)
deriving stock ((forall x. UInt -> Rep UInt x)
-> (forall x. Rep UInt x -> UInt) -> Generic UInt
forall x. Rep UInt x -> UInt
forall x. UInt -> Rep UInt x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UInt -> Rep UInt x
from :: forall x. UInt -> Rep UInt x
$cto :: forall x. Rep UInt x -> UInt
to :: forall x. Rep UInt x -> UInt
Generic)
deriving anyclass (UInt -> ()
(UInt -> ()) -> NFData UInt
forall a. (a -> ()) -> NFData a
$crnf :: UInt -> ()
rnf :: UInt -> ()
NFData)
instance Hashable UInt where hashWithSalt :: Int -> UInt -> Int
hashWithSalt Int
s (UInt Mod (2 ^ 31)
n) = Int -> Word -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
s (Mod 2147483648 -> Word
forall (m :: Nat). Mod m -> Word
unMod Mod 2147483648
Mod (2 ^ 31)
n)
instance Show UInt where
show :: UInt -> String
show (UInt Mod (2 ^ 31)
u) = Word -> String
forall a. Show a => a -> String
show (Word -> String) -> Word -> String
forall a b. (a -> b) -> a -> b
$ Mod 2147483648 -> Word
forall (m :: Nat). Mod m -> Word
unMod Mod 2147483648
Mod (2 ^ 31)
u
instance Read UInt where
readPrec :: ReadPrec UInt
readPrec = Integer -> UInt
forall a. Num a => Integer -> a
fromInteger (Integer -> UInt) -> ReadPrec Integer -> ReadPrec UInt
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReadPrec Integer
forall a. Read a => ReadPrec a
readPrec
instance Real UInt where
toRational :: UInt -> Rational
toRational (UInt Mod (2 ^ 31)
u) = Word -> Rational
forall a. Real a => a -> Rational
toRational (Word -> Rational) -> Word -> Rational
forall a b. (a -> b) -> a -> b
$ Mod 2147483648 -> Word
forall (m :: Nat). Mod m -> Word
unMod Mod 2147483648
Mod (2 ^ 31)
u
instance Integral UInt where
quotRem :: UInt -> UInt -> (UInt, UInt)
quotRem (UInt Mod (2 ^ 31)
x) (UInt Mod (2 ^ 31)
y) = (Word -> UInt) -> (Word -> UInt) -> (Word, Word) -> (UInt, UInt)
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap Word -> UInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word -> UInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral ((Word, Word) -> (UInt, UInt)) -> (Word, Word) -> (UInt, UInt)
forall a b. (a -> b) -> a -> b
$ Word -> Word -> (Word, Word)
forall a. Integral a => a -> a -> (a, a)
quotRem (Mod 2147483648 -> Word
forall (m :: Nat). Mod m -> Word
unMod Mod 2147483648
Mod (2 ^ 31)
x) (Mod 2147483648 -> Word
forall (m :: Nat). Mod m -> Word
unMod Mod 2147483648
Mod (2 ^ 31)
y)
toInteger :: UInt -> Integer
toInteger (UInt Mod (2 ^ 31)
u) = Word -> Integer
forall a. Integral a => a -> Integer
toInteger (Word -> Integer) -> Word -> Integer
forall a b. (a -> b) -> a -> b
$ Mod 2147483648 -> Word
forall (m :: Nat). Mod m -> Word
unMod Mod 2147483648
Mod (2 ^ 31)
u
instance ToJSON UInt where
toJSON :: UInt -> Value
toJSON UInt
u = Integer -> Value
forall a. ToJSON a => a -> Value
toJSON (UInt -> Integer
forall a. Integral a => a -> Integer
toInteger UInt
u)
instance FromJSON UInt where
parseJSON :: Value -> Parser UInt
parseJSON Value
v = Integer -> UInt
forall a. Num a => Integer -> a
fromInteger (Integer -> UInt) -> Parser Integer -> Parser UInt
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Integer
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
data a |? b = InL a
| InR b
deriving (ReadPrec [a |? b]
ReadPrec (a |? b)
Int -> ReadS (a |? b)
ReadS [a |? b]
(Int -> ReadS (a |? b))
-> ReadS [a |? b]
-> ReadPrec (a |? b)
-> ReadPrec [a |? b]
-> Read (a |? b)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall a b. (Read a, Read b) => ReadPrec [a |? b]
forall a b. (Read a, Read b) => ReadPrec (a |? b)
forall a b. (Read a, Read b) => Int -> ReadS (a |? b)
forall a b. (Read a, Read b) => ReadS [a |? b]
$creadsPrec :: forall a b. (Read a, Read b) => Int -> ReadS (a |? b)
readsPrec :: Int -> ReadS (a |? b)
$creadList :: forall a b. (Read a, Read b) => ReadS [a |? b]
readList :: ReadS [a |? b]
$creadPrec :: forall a b. (Read a, Read b) => ReadPrec (a |? b)
readPrec :: ReadPrec (a |? b)
$creadListPrec :: forall a b. (Read a, Read b) => ReadPrec [a |? b]
readListPrec :: ReadPrec [a |? b]
Read,Int -> (a |? b) -> ShowS
[a |? b] -> ShowS
(a |? b) -> String
(Int -> (a |? b) -> ShowS)
-> ((a |? b) -> String) -> ([a |? b] -> ShowS) -> Show (a |? b)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b. (Show a, Show b) => Int -> (a |? b) -> ShowS
forall a b. (Show a, Show b) => [a |? b] -> ShowS
forall a b. (Show a, Show b) => (a |? b) -> String
$cshowsPrec :: forall a b. (Show a, Show b) => Int -> (a |? b) -> ShowS
showsPrec :: Int -> (a |? b) -> ShowS
$cshow :: forall a b. (Show a, Show b) => (a |? b) -> String
show :: (a |? b) -> String
$cshowList :: forall a b. (Show a, Show b) => [a |? b] -> ShowS
showList :: [a |? b] -> ShowS
Show,(a |? b) -> (a |? b) -> Bool
((a |? b) -> (a |? b) -> Bool)
-> ((a |? b) -> (a |? b) -> Bool) -> Eq (a |? b)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall a b. (Eq a, Eq b) => (a |? b) -> (a |? b) -> Bool
$c== :: forall a b. (Eq a, Eq b) => (a |? b) -> (a |? b) -> Bool
== :: (a |? b) -> (a |? b) -> Bool
$c/= :: forall a b. (Eq a, Eq b) => (a |? b) -> (a |? b) -> Bool
/= :: (a |? b) -> (a |? b) -> Bool
Eq,Eq (a |? b)
Eq (a |? b) =>
((a |? b) -> (a |? b) -> Ordering)
-> ((a |? b) -> (a |? b) -> Bool)
-> ((a |? b) -> (a |? b) -> Bool)
-> ((a |? b) -> (a |? b) -> Bool)
-> ((a |? b) -> (a |? b) -> Bool)
-> ((a |? b) -> (a |? b) -> a |? b)
-> ((a |? b) -> (a |? b) -> a |? b)
-> Ord (a |? b)
(a |? b) -> (a |? b) -> Bool
(a |? b) -> (a |? b) -> Ordering
(a |? b) -> (a |? b) -> a |? b
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
forall a b. (Ord a, Ord b) => Eq (a |? b)
forall a b. (Ord a, Ord b) => (a |? b) -> (a |? b) -> Bool
forall a b. (Ord a, Ord b) => (a |? b) -> (a |? b) -> Ordering
forall a b. (Ord a, Ord b) => (a |? b) -> (a |? b) -> a |? b
$ccompare :: forall a b. (Ord a, Ord b) => (a |? b) -> (a |? b) -> Ordering
compare :: (a |? b) -> (a |? b) -> Ordering
$c< :: forall a b. (Ord a, Ord b) => (a |? b) -> (a |? b) -> Bool
< :: (a |? b) -> (a |? b) -> Bool
$c<= :: forall a b. (Ord a, Ord b) => (a |? b) -> (a |? b) -> Bool
<= :: (a |? b) -> (a |? b) -> Bool
$c> :: forall a b. (Ord a, Ord b) => (a |? b) -> (a |? b) -> Bool
> :: (a |? b) -> (a |? b) -> Bool
$c>= :: forall a b. (Ord a, Ord b) => (a |? b) -> (a |? b) -> Bool
>= :: (a |? b) -> (a |? b) -> Bool
$cmax :: forall a b. (Ord a, Ord b) => (a |? b) -> (a |? b) -> a |? b
max :: (a |? b) -> (a |? b) -> a |? b
$cmin :: forall a b. (Ord a, Ord b) => (a |? b) -> (a |? b) -> a |? b
min :: (a |? b) -> (a |? b) -> a |? b
Ord,(forall x. (a |? b) -> Rep (a |? b) x)
-> (forall x. Rep (a |? b) x -> a |? b) -> Generic (a |? b)
forall x. Rep (a |? b) x -> a |? b
forall x. (a |? b) -> Rep (a |? b) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a b x. Rep (a |? b) x -> a |? b
forall a b x. (a |? b) -> Rep (a |? b) x
$cfrom :: forall a b x. (a |? b) -> Rep (a |? b) x
from :: forall x. (a |? b) -> Rep (a |? b) x
$cto :: forall a b x. Rep (a |? b) x -> a |? b
to :: forall x. Rep (a |? b) x -> a |? b
Generic)
infixr |?
toEither :: a |? b -> Either a b
toEither :: forall a b. (a |? b) -> Either a b
toEither (InL a
a) = a -> Either a b
forall a b. a -> Either a b
Left a
a
toEither (InR b
b) = b -> Either a b
forall a b. b -> Either a b
Right b
b
instance (ToJSON a, ToJSON b) => ToJSON (a |? b) where
toJSON :: (a |? b) -> Value
toJSON (InL a
x) = a -> Value
forall a. ToJSON a => a -> Value
toJSON a
x
toJSON (InR b
x) = b -> Value
forall a. ToJSON a => a -> Value
toJSON b
x
instance (FromJSON a, FromJSON b) => FromJSON (a |? b) where
parseJSON :: Value -> Parser (a |? b)
parseJSON Value
v = b -> a |? b
forall a b. b -> a |? b
InR (b -> a |? b) -> Parser b -> Parser (a |? b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser b
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v Parser (a |? b) -> Parser (a |? b) -> Parser (a |? b)
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> a -> a |? b
forall a b. a -> a |? b
InL (a -> a |? b) -> Parser a -> Parser (a |? b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser a
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
instance (NFData a, NFData b) => NFData (a |? b)
newtype List a = List [a]
deriving stock (Functor List
Foldable List
(Functor List, Foldable List) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> List a -> f (List b))
-> (forall (f :: * -> *) a.
Applicative f =>
List (f a) -> f (List a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> List a -> m (List b))
-> (forall (m :: * -> *) a. Monad m => List (m a) -> m (List a))
-> Traversable List
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => List (m a) -> m (List a)
forall (f :: * -> *) a. Applicative f => List (f a) -> f (List a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> List a -> m (List b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> List a -> f (List b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> List a -> f (List b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> List a -> f (List b)
$csequenceA :: forall (f :: * -> *) a. Applicative f => List (f a) -> f (List a)
sequenceA :: forall (f :: * -> *) a. Applicative f => List (f a) -> f (List a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> List a -> m (List b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> List a -> m (List b)
$csequence :: forall (m :: * -> *) a. Monad m => List (m a) -> m (List a)
sequence :: forall (m :: * -> *) a. Monad m => List (m a) -> m (List a)
Traversable,(forall x. List a -> Rep (List a) x)
-> (forall x. Rep (List a) x -> List a) -> Generic (List a)
forall x. Rep (List a) x -> List a
forall x. List a -> Rep (List a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (List a) x -> List a
forall a x. List a -> Rep (List a) x
$cfrom :: forall a x. List a -> Rep (List a) x
from :: forall x. List a -> Rep (List a) x
$cto :: forall a x. Rep (List a) x -> List a
to :: forall x. Rep (List a) x -> List a
Generic)
deriving newtype (Int -> List a -> ShowS
[List a] -> ShowS
List a -> String
(Int -> List a -> ShowS)
-> (List a -> String) -> ([List a] -> ShowS) -> Show (List a)
forall a. Show a => Int -> List a -> ShowS
forall a. Show a => [List a] -> ShowS
forall a. Show a => List a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> List a -> ShowS
showsPrec :: Int -> List a -> ShowS
$cshow :: forall a. Show a => List a -> String
show :: List a -> String
$cshowList :: forall a. Show a => [List a] -> ShowS
showList :: [List a] -> ShowS
Show,ReadPrec [List a]
ReadPrec (List a)
Int -> ReadS (List a)
ReadS [List a]
(Int -> ReadS (List a))
-> ReadS [List a]
-> ReadPrec (List a)
-> ReadPrec [List a]
-> Read (List a)
forall a. Read a => ReadPrec [List a]
forall a. Read a => ReadPrec (List a)
forall a. Read a => Int -> ReadS (List a)
forall a. Read a => ReadS [List a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Read a => Int -> ReadS (List a)
readsPrec :: Int -> ReadS (List a)
$creadList :: forall a. Read a => ReadS [List a]
readList :: ReadS [List a]
$creadPrec :: forall a. Read a => ReadPrec (List a)
readPrec :: ReadPrec (List a)
$creadListPrec :: forall a. Read a => ReadPrec [List a]
readListPrec :: ReadPrec [List a]
Read,List a -> List a -> Bool
(List a -> List a -> Bool)
-> (List a -> List a -> Bool) -> Eq (List a)
forall a. Eq a => List a -> List a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => List a -> List a -> Bool
== :: List a -> List a -> Bool
$c/= :: forall a. Eq a => List a -> List a -> Bool
/= :: List a -> List a -> Bool
Eq,Eq (List a)
Eq (List a) =>
(List a -> List a -> Ordering)
-> (List a -> List a -> Bool)
-> (List a -> List a -> Bool)
-> (List a -> List a -> Bool)
-> (List a -> List a -> Bool)
-> (List a -> List a -> List a)
-> (List a -> List a -> List a)
-> Ord (List a)
List a -> List a -> Bool
List a -> List a -> Ordering
List a -> List a -> List a
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
forall a. Ord a => Eq (List a)
forall a. Ord a => List a -> List a -> Bool
forall a. Ord a => List a -> List a -> Ordering
forall a. Ord a => List a -> List a -> List a
$ccompare :: forall a. Ord a => List a -> List a -> Ordering
compare :: List a -> List a -> Ordering
$c< :: forall a. Ord a => List a -> List a -> Bool
< :: List a -> List a -> Bool
$c<= :: forall a. Ord a => List a -> List a -> Bool
<= :: List a -> List a -> Bool
$c> :: forall a. Ord a => List a -> List a -> Bool
> :: List a -> List a -> Bool
$c>= :: forall a. Ord a => List a -> List a -> Bool
>= :: List a -> List a -> Bool
$cmax :: forall a. Ord a => List a -> List a -> List a
max :: List a -> List a -> List a
$cmin :: forall a. Ord a => List a -> List a -> List a
min :: List a -> List a -> List a
Ord,NonEmpty (List a) -> List a
List a -> List a -> List a
(List a -> List a -> List a)
-> (NonEmpty (List a) -> List a)
-> (forall b. Integral b => b -> List a -> List a)
-> Semigroup (List a)
forall b. Integral b => b -> List a -> List a
forall a. NonEmpty (List a) -> List a
forall a. List a -> List a -> List a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall a b. Integral b => b -> List a -> List a
$c<> :: forall a. List a -> List a -> List a
<> :: List a -> List a -> List a
$csconcat :: forall a. NonEmpty (List a) -> List a
sconcat :: NonEmpty (List a) -> List a
$cstimes :: forall a b. Integral b => b -> List a -> List a
stimes :: forall b. Integral b => b -> List a -> List a
Semigroup,Semigroup (List a)
List a
Semigroup (List a) =>
List a
-> (List a -> List a -> List a)
-> ([List a] -> List a)
-> Monoid (List a)
[List a] -> List a
List a -> List a -> List a
forall a. Semigroup (List a)
forall a. List a
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall a. [List a] -> List a
forall a. List a -> List a -> List a
$cmempty :: forall a. List a
mempty :: List a
$cmappend :: forall a. List a -> List a -> List a
mappend :: List a -> List a -> List a
$cmconcat :: forall a. [List a] -> List a
mconcat :: [List a] -> List a
Monoid,(forall a b. (a -> b) -> List a -> List b)
-> (forall a b. a -> List b -> List a) -> Functor List
forall a b. a -> List b -> List a
forall a b. (a -> b) -> List a -> List b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> List a -> List b
fmap :: forall a b. (a -> b) -> List a -> List b
$c<$ :: forall a b. a -> List b -> List a
<$ :: forall a b. a -> List b -> List a
Functor,(forall m. Monoid m => List m -> m)
-> (forall m a. Monoid m => (a -> m) -> List a -> m)
-> (forall m a. Monoid m => (a -> m) -> List a -> m)
-> (forall a b. (a -> b -> b) -> b -> List a -> b)
-> (forall a b. (a -> b -> b) -> b -> List a -> b)
-> (forall b a. (b -> a -> b) -> b -> List a -> b)
-> (forall b a. (b -> a -> b) -> b -> List a -> b)
-> (forall a. (a -> a -> a) -> List a -> a)
-> (forall a. (a -> a -> a) -> List a -> a)
-> (forall a. List a -> [a])
-> (forall a. List a -> Bool)
-> (forall a. List a -> Int)
-> (forall a. Eq a => a -> List a -> Bool)
-> (forall a. Ord a => List a -> a)
-> (forall a. Ord a => List a -> a)
-> (forall a. Num a => List a -> a)
-> (forall a. Num a => List a -> a)
-> Foldable List
forall a. Eq a => a -> List a -> Bool
forall a. Num a => List a -> a
forall a. Ord a => List a -> a
forall m. Monoid m => List m -> m
forall a. List a -> Bool
forall a. List a -> Int
forall a. List a -> [a]
forall a. (a -> a -> a) -> List a -> a
forall m a. Monoid m => (a -> m) -> List a -> m
forall b a. (b -> a -> b) -> b -> List a -> b
forall a b. (a -> b -> b) -> b -> List a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => List m -> m
fold :: forall m. Monoid m => List m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> List a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> List a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> List a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> List a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> List a -> b
foldr :: forall a b. (a -> b -> b) -> b -> List a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> List a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> List a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> List a -> b
foldl :: forall b a. (b -> a -> b) -> b -> List a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> List a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> List a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> List a -> a
foldr1 :: forall a. (a -> a -> a) -> List a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> List a -> a
foldl1 :: forall a. (a -> a -> a) -> List a -> a
$ctoList :: forall a. List a -> [a]
toList :: forall a. List a -> [a]
$cnull :: forall a. List a -> Bool
null :: forall a. List a -> Bool
$clength :: forall a. List a -> Int
length :: forall a. List a -> Int
$celem :: forall a. Eq a => a -> List a -> Bool
elem :: forall a. Eq a => a -> List a -> Bool
$cmaximum :: forall a. Ord a => List a -> a
maximum :: forall a. Ord a => List a -> a
$cminimum :: forall a. Ord a => List a -> a
minimum :: forall a. Ord a => List a -> a
$csum :: forall a. Num a => List a -> a
sum :: forall a. Num a => List a -> a
$cproduct :: forall a. Num a => List a -> a
product :: forall a. Num a => List a -> a
Foldable)
instance NFData a => NFData (List a)
instance (ToJSON a) => ToJSON (List a) where
toJSON :: List a -> Value
toJSON (List [a]
ls) = [a] -> Value
forall a. ToJSON a => a -> Value
toJSON [a]
ls
instance (FromJSON a) => FromJSON (List a) where
parseJSON :: Value -> Parser (List a)
parseJSON Value
Null = List a -> Parser (List a)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ([a] -> List a
forall a. [a] -> List a
List [])
parseJSON Value
v = [a] -> List a
forall a. [a] -> List a
List ([a] -> List a) -> Parser [a] -> Parser (List a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser [a]
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
data Empty = Empty deriving (Empty -> Empty -> Bool
(Empty -> Empty -> Bool) -> (Empty -> Empty -> Bool) -> Eq Empty
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Empty -> Empty -> Bool
== :: Empty -> Empty -> Bool
$c/= :: Empty -> Empty -> Bool
/= :: Empty -> Empty -> Bool
Eq,Eq Empty
Eq Empty =>
(Empty -> Empty -> Ordering)
-> (Empty -> Empty -> Bool)
-> (Empty -> Empty -> Bool)
-> (Empty -> Empty -> Bool)
-> (Empty -> Empty -> Bool)
-> (Empty -> Empty -> Empty)
-> (Empty -> Empty -> Empty)
-> Ord Empty
Empty -> Empty -> Bool
Empty -> Empty -> Ordering
Empty -> Empty -> Empty
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
$ccompare :: Empty -> Empty -> Ordering
compare :: Empty -> Empty -> Ordering
$c< :: Empty -> Empty -> Bool
< :: Empty -> Empty -> Bool
$c<= :: Empty -> Empty -> Bool
<= :: Empty -> Empty -> Bool
$c> :: Empty -> Empty -> Bool
> :: Empty -> Empty -> Bool
$c>= :: Empty -> Empty -> Bool
>= :: Empty -> Empty -> Bool
$cmax :: Empty -> Empty -> Empty
max :: Empty -> Empty -> Empty
$cmin :: Empty -> Empty -> Empty
min :: Empty -> Empty -> Empty
Ord,Int -> Empty -> ShowS
[Empty] -> ShowS
Empty -> String
(Int -> Empty -> ShowS)
-> (Empty -> String) -> ([Empty] -> ShowS) -> Show Empty
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Empty -> ShowS
showsPrec :: Int -> Empty -> ShowS
$cshow :: Empty -> String
show :: Empty -> String
$cshowList :: [Empty] -> ShowS
showList :: [Empty] -> ShowS
Show)
instance ToJSON Empty where
toJSON :: Empty -> Value
toJSON Empty
Empty = Value
Null
instance FromJSON Empty where
parseJSON :: Value -> Parser Empty
parseJSON Value
Null = Empty -> Parser Empty
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Empty
Empty
parseJSON (Object Object
o) | Object
o Object -> Object -> Bool
forall a. Eq a => a -> a -> Bool
== Object
forall a. Monoid a => a
mempty = Empty -> Parser Empty
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Empty
Empty
parseJSON Value
_ = String -> Parser Empty
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"expected 'null' or '{}'"