Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Type and field annotations for Lorentz types.
Synopsis
- data AnnOptions = AnnOptions {
- fieldAnnModifier :: Text -> Text
- dropPrefix :: Text -> Text
- appendTo :: Text -> [Text] -> Text -> Text
- toCamel :: Text -> Text
- toPascal :: Text -> Text
- toSnake :: Text -> Text
- stripFieldPrefix :: Text -> Text
- ctorNameToAnnWithOptions :: forall ctor. (KnownSymbol ctor, HasCallStack) => AnnOptions -> FieldAnn
- data FollowEntrypointFlag
- data GenerateFieldAnnFlag
- class HasAnnotation a where
- getAnnotation :: FollowEntrypointFlag -> Notes (ToT a)
- annOptions :: Maybe AnnOptions
- class GHasAnnotation a where
- gGetAnnotation :: AnnOptions -> FollowEntrypointFlag -> GenerateFieldAnnFlag -> (Notes (GValueType a), FieldAnn, VarAnn)
- gGetAnnotationNoField :: forall a. (GHasAnnotation (GRep a), GValueType (GRep a) ~ ToT a) => FollowEntrypointFlag -> Notes (ToT a)
- insertTypeAnn :: forall (b :: T). TypeAnn -> Notes b -> Notes b
Documentation
data AnnOptions Source #
Allow customization of field annotation generated for a type
when declaring its HasAnnotation
instance.
AnnOptions | |
|
Instances
Default AnnOptions Source # | |
Defined in Lorentz.Annotation def :: AnnOptions # |
dropPrefix :: Text -> Text #
appendTo :: Text -> [Text] -> Text -> Text Source #
appendTo suffix fields field
appends the given suffix to field
if the field exists in the fields
list.
stripFieldPrefix :: Text -> Text #
ctorNameToAnnWithOptions :: forall ctor. (KnownSymbol ctor, HasCallStack) => AnnOptions -> FieldAnn Source #
data FollowEntrypointFlag Source #
Used in GHasAnnotation
and HasAnnotation
as a flag to track
whether or not it directly follows an entrypoint to avoid introducing
extra entrypoints.
data GenerateFieldAnnFlag Source #
Used in GHasAnnotation
as a flag to track whether or not field/constructor
annotations should be generated.
class HasAnnotation a where Source #
This class defines the type and field annotations for a given type. Right now the type annotations come from names in a named field, and field annotations are generated from the record fields.
Allows generic derivation. The type must have Generic
and IsoValue
instances.
>>>
data Foo = Foo
>>>
instance HasAnnotation Foo
... ... GHC.Generics.Rep Foo ... is stuck. Likely ... Generic Foo ... instance is missing or out of scope. ...
>>>
data Foo = Foo deriving (Generic, IsoValue)
>>>
instance HasAnnotation Foo
Nothing
getAnnotation :: FollowEntrypointFlag -> Notes (ToT a) Source #
default getAnnotation :: (GHasAnnotation (GRep a), GValueType (GRep a) ~ ToT a, GIsSumType (GRep a), TypeHasFieldNamingStrategy a) => FollowEntrypointFlag -> Notes (ToT a) Source #
Instances
class GHasAnnotation a where Source #
A Generic HasAnnotation
implementation
gGetAnnotation :: AnnOptions -> FollowEntrypointFlag -> GenerateFieldAnnFlag -> (Notes (GValueType a), FieldAnn, VarAnn) Source #
Instances
gGetAnnotationNoField :: forall a. (GHasAnnotation (GRep a), GValueType (GRep a) ~ ToT a) => FollowEntrypointFlag -> Notes (ToT a) Source #
Use this in the instance of HasAnnotation
when field annotations
should not be generated.
insertTypeAnn :: forall (b :: T). TypeAnn -> Notes b -> Notes b #