express-0.1.4: Dynamically-typed expressions involving applications and variables.
Copyright(c) 2019-2021 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellNone
LanguageHaskell2010

Data.Express.Utils.TH

Description

Template Haskell utilities.

Synopsis

Documentation

typeArity :: Name -> Q Int Source #

Given a type name, return the number of arguments taken by that type. Examples in partially broken TH:

arity ''Int        === Q 0
arity ''Int->Int   === Q 0
arity ''Maybe      === Q 1
arity ''Either     === Q 2
arity ''Int->      === Q 1

This works for Data's and Newtype's and it is useful when generating typeclass instances.