-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Generates Matchable instances using TemplateHaskell -- -- This package provides TemplateHaskell function to generate instances -- of Matchable and Bimatchable type classes, which are -- from "matchable" package. @package matchable-th @version 0.2 module Data.Matchable.TH -- | This function transforms multiple instance declarations written in -- StandaloneDeriving format to instances derived by -- TemplateHaskell. -- --

Example

-- --
--   {-# LANGUAGE DeriveFunctor #-}
--   {-# LANGUAGE StandaloneDeriving #-}
--   [-# LANGUAGE TemplateHaskell #-}
--   data Foo a b = Foo a b (Either a b)
--      deriving (Show, Eq, Functor)
--   
--   
-- -- To use deriveInstances for Foo, write as below: -- --
--   deriveInstances [d|
--     deriving instance Eq a => Eq1 (Foo a)
--     deriving instance Eq a => Matchable (Foo a)
--     deriving instance Eq2 Foo
--     deriving instance Bifunctor Foo
--     deriving instance Bimatchable Foo
--     |]
--   
--   
deriveInstances :: Q [Dec] -> Q [Dec] -- | Build an instance of Matchable for a data type. -- -- e.g. -- --
--   data Exp a = Plus a a | Times a a
--   deriveMatchable ''Exp
--   
-- -- will create -- --
--   instance Matchable Exp where
--     zipMatchWith f (Plus  l1 l2) (Plus  r1 r2) = pure Plus  * f l1 r1 * f l2 r2
--     zipMatchWith f (Times l1 l2) (Times r1 r2) = pure Times * f l1 r1 * f l2 r2
--     zipMatchWith _ _ _ = Nothing
--   
deriveMatchable :: Name -> Q [Dec] makeZipMatchWith :: Name -> ExpQ -- | Build an instance of Bimatchable for a data type. -- -- e.g. -- --
--   data Sum a b = InL a | InR b
--   deriveMatchable ''Sum
--   
-- -- will create -- --
--   instance Matchable Sum where
--     bizipMatchWith f _ (InL l1) (InL r1) = pure InL $ f l1 r1
--     bizipMatchWith _ g (InR l1) (InR r1) = pure InR $ g l1 r1
--   
deriveBimatchable :: Name -> Q [Dec] makeBizipMatchWith :: Name -> ExpQ makeLiftEq :: Name -> Q Exp makeLiftEq2 :: Name -> Q Exp