Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Purpose
- pattern IsPredicate :: Type
- pattern IsFunction :: [Type] -> Type -> Type
- pattern IsString :: Type
- pattern IsMaybe :: Type -> Type
- pattern IsList :: Type -> Type
- pattern IsTyConned :: TyCon -> [Type] -> Type
- pattern IsTyVarred :: TyVar -> [Type] -> Type
- getPurposes :: Type -> [Purpose]
- with :: Monoid a => Bool -> a -> a
- functionNames :: [String]
- purposeToName :: Purpose -> [String]
- mkTyName :: Type -> [String]
- mkTyConName :: TyCon -> String
- camelTerms :: String -> [String]
- getStem :: String -> String
- stem :: String -> String
- filterReplace :: (a -> Bool) -> a -> [a] -> [a]
- mkGoodName :: Set OccName -> Type -> OccName
- mkNumericSuffix :: Set OccName -> String -> String
- mkManyGoodNames :: Traversable t => Set OccName -> t Type -> t OccName
- getInScope :: Map OccName a -> [OccName]
Documentation
A classification of a variable, for which we have specific naming rules. A variable can have multiple purposes simultaneously.
pattern IsPredicate :: Type Source #
getPurposes :: Type -> [Purpose] Source #
Get the Purpose
s of a type. A type can have multiple purposes
simultaneously, so the order of purposes in this function corresponds to the
precedence of that naming rule. Which means, eg, that if a type is both
a Predicate
and a Function
, we should prefer to use the predicate naming
rules, since they come first.
functionNames :: [String] Source #
Names we can give functions
purposeToName :: Purpose -> [String] Source #
Get a ranked ordering of names for a given purpose.
mkTyConName :: TyCon -> String Source #
Get a good name for a type constructor.
camelTerms :: String -> [String] Source #
Split a string into its camel case components.
getStem :: String -> String Source #
A stem of a string is either a special-case shortened form, or a shortened first syllable. If the string is one syllable, we take the full word if it's short, or just the first two characters if it's long. Otherwise, just take the first syllable.
NOTE: There's no rhyme or reason here, I just experimented until I got results that were reasonably consistent with the names I would give things.
stem :: String -> String Source #
Get a special-case stem, or, failing that, give back the first syllable.
filterReplace :: (a -> Bool) -> a -> [a] -> [a] Source #
Maybe replace an element in the list if the predicate matches
:: Set OccName | Bindings in scope; used to ensure we don't shadow anything |
-> Type | The type to produce a name for |
-> OccName |
Produce a unique, good name for a type.
mkNumericSuffix :: Set OccName -> String -> String Source #
Given a desired name, compute a new name for it based on how many names in
scope conflict with it. Eg, if we want to name something x
, but already
have x
, x'
and x2
in scope, we will give back x3
.
mkManyGoodNames :: Traversable t => Set OccName -> t Type -> t OccName Source #
Like mkGoodName
but creates several apart names.