-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Utilities for accessing and manipulating fields of records
--   
--   Automate generation of <tt>Accessor</tt>'s of the
--   <tt>data-accessor</tt> package by Template Haskell functions.
@package data-accessor-template
@version 0.2.1.13


-- | This module provides an automatic Template Haskell routine to scour
--   data type definitions and generate accessor objects for them
--   automatically.
module Data.Accessor.Template

-- | <tt>nameDeriveAccessors n f</tt> where <tt>n</tt> is the name of a
--   data type declared with <tt>data</tt> and <tt>f</tt> is a function
--   from names of fields in that data type to the name of the
--   corresponding accessor. If <tt>f</tt> returns <tt>Nothing</tt>, then
--   no accessor is generated for that field.
nameDeriveAccessors :: Name -> (String -> Maybe String) -> Q [Dec]

-- | <tt>deriveAccessors n</tt> where <tt>n</tt> is the name of a data type
--   declared with <tt>data</tt> looks through all the declared fields of
--   the data type, and for each field ending in an underscore generates an
--   accessor of the same name without the underscore.
--   
--   It is "nameDeriveAccessors" n f where <tt>f</tt> satisfies
--   
--   <pre>
--   f (s ++ "_") = Just s
--   f x = Nothing -- otherwise
--   </pre>
--   
--   For example, given the data type:
--   
--   <pre>
--   data Score = Score { p1Score_ :: Int
--   , p2Score_ :: Int
--   , rounds :: Int
--   }
--   </pre>
--   
--   <tt>deriveAccessors</tt> will generate the following objects:
--   
--   <pre>
--   p1Score :: Accessor Score Int
--   p1Score = Accessor p1Score_ (\x s -&gt; s { p1Score_ = x })
--   p2Score :: Accessor Score Int
--   p2Score = Accessor p2Score_ (\x s -&gt; s { p2Score_ = x })
--   </pre>
--   
--   It is used with Template Haskell syntax like:
--   
--   <pre>
--   $( deriveAccessors ''TypeName )
--   </pre>
--   
--   And will generate accessors when TypeName was declared using
--   <tt>data</tt> or <tt>newtype</tt>.
deriveAccessors :: Name -> Q [Dec]
