meta-misc-0.1.0.2: Utility library providing miscellaneous meta-programming utilities.

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Util.Cons

Synopsis

Documentation

decons :: Name -> Q Exp Source

Generate a deconstructor that takes as input a value and returns Maybe the deconstructed value.

This functions as a Data Constructor inverter. If the number of parameters of a constructor is not equal to 1, Maybe a tuple is returned.-- The result of this function is defined only when

Example:

$(decons 'Right) (Right "foo") :: Maybe String
$(decons '(:)) "bar" :: Maybe (Char, String)