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 |
Synopsis
- makeUnionWrapper :: String -> Name -> Q [Dec]
- makeUnionWrapper' :: [String] -> Name -> Q [Dec]
Template Haskell procedures for building constructor wrappers
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)
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)