-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Union 'alternative' or Either that has untagged JSON encoding.
--   
--   Parsing JSON with Aeson often requires decoding fields that have more
--   than one Haskell type.
--   
--   So we have: ``` data a :|: b = AltLeft a | AltLeft b printIt = print .
--   (fromJSON :: ByteString -&gt; Int :|: Bool) main = do printIt "1" --
--   AltLeft 1 printIt "true" -- AltRight True printIt "null" -- errors!
--   ``` To generate types for larger JSON documents, you might use
--   `json-autotype`.
--   
--   This is separate package so that users do not have to keep
--   `json-autotype` as runtime dependency.
--   
--   See <a>https://github.com/mgajda/json-autotype</a>
@package json-alt
@version 1.0.0


-- | This module defines data type (a :|: b) that behaves all like
--   <tt>Either</tt>, except that has no tag in JSON representation as used
--   by <tt>FromJSON</tt> and <tt>ToJSON</tt>.
module Data.Aeson.AutoType.Alternative

-- | Data type (a :|: b) that behaves all like <tt>Either</tt>, except that
--   has no tag in JSON representation as used by <tt>FromJSON</tt> and
--   <tt>ToJSON</tt>.
data a :|: b
AltLeft :: a -> (:|:) a b
AltRight :: b -> (:|:) a b
infixr 5 :|:

-- | Convert to <tt>Either</tt> datatype.
toEither :: (a :|: b) -> Either a b

-- | Convert from <tt>Either</tt> datatype.
fromEither :: Either a b -> a :|: b

-- | Deconstruct the type with two functions corresponding to constructors.
--   This is like <tt>either</tt>.
alt :: (a -> c) -> (b -> c) -> (a :|: b) -> c
infixr 5 `alt`
instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (a Data.Aeson.AutoType.Alternative.:|: b)
instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (a Data.Aeson.AutoType.Alternative.:|: b)
instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (a Data.Aeson.AutoType.Alternative.:|: b)
instance (Data.Aeson.Types.ToJSON.ToJSON a, Data.Aeson.Types.ToJSON.ToJSON b) => Data.Aeson.Types.ToJSON.ToJSON (a Data.Aeson.AutoType.Alternative.:|: b)
instance (Data.Aeson.Types.FromJSON.FromJSON a, Data.Aeson.Types.FromJSON.FromJSON b) => Data.Aeson.Types.FromJSON.FromJSON (a Data.Aeson.AutoType.Alternative.:|: b)
