| Copyright | (c) Sirui Lu 2021-2023 | 
|---|---|
| License | BSD-3-Clause (see the LICENSE file) | 
| Maintainer | siruilu@cs.washington.edu | 
| Stability | Experimental | 
| Portability | GHC only | 
| Safe Haskell | Trustworthy | 
| Language | Haskell2010 | 
Grisette.Core.TH
Description
Synopsis
- makeUnionWrapper :: String -> Name -> Q [Dec]
 - makeUnionWrapper' :: [String] -> Name -> Q [Dec]
 
Template Haskell procedures for building constructor wrappers
Arguments
| :: String | Prefix for generated wrappers  | 
| -> Name | The type to generate the wrappers for  | 
| -> Q [Dec] | 
Generate constructor wrappers that wraps the result in a union-like monad.
$(makeUnionWrapper "mrg" ''Maybe)
generates
mrgNothing :: (SymBoolOp bool, Monad u, Mergeable bool t, MonadUnion bool u) => u (Maybe t) mrgNothing = mrgSingle Nothing mrgJust :: (SymBoolOp bool, Monad u, Mergeable bool t, MonadUnion bool u) => t -> u (Maybe t) mrgJust = \x -> mrgSingle (Just x)
Arguments
| :: [String] | Names for generated wrappers  | 
| -> Name | The type to generate the wrappers for  | 
| -> Q [Dec] | 
Generate constructor wrappers that wraps the result in a union-like monad with provided names.
$(makeUnionWrapper' ["mrgTuple2"] ''(,))
generates
mrgTuple2 :: (SymBoolOp bool, Monad u, Mergeable bool t1, Mergeable bool t2, MonadUnion bool u) => t1 -> t2 -> u (t1, t2) mrgTuple2 = \v1 v2 -> mrgSingle (v1, v2)