hls-tactics-plugin-1.6.2.0: Wingman plugin for Haskell Language Server
Safe HaskellNone
LanguageHaskell2010

Wingman.Naming

Synopsis

Documentation

data Purpose Source #

A classification of a variable, for which we have specific naming rules. A variable can have multiple purposes simultaneously.

Constructors

Function [Type] Type 
Predicate 
Continuation 
Integral 
Number 
String 
List Type 
Maybe Type 
TyConned TyCon [Type]

Something of the form TC a b c

TyVarred TyVar [Type]

Something of the form m a b c

pattern IsFunction :: [Type] -> Type -> Type Source #

pattern IsString :: Type Source #

pattern IsMaybe :: Type -> Type Source #

pattern IsList :: Type -> Type Source #

pattern IsTyConned :: TyCon -> [Type] -> Type Source #

pattern IsTyVarred :: TyVar -> [Type] -> Type Source #

getPurposes :: Type -> [Purpose] Source #

Get the Purposes 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.

with :: Monoid a => Bool -> a -> a Source #

Return mempty if the give bool is false.

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

mkGoodName Source #

Arguments

:: 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.

getInScope :: Map OccName a -> [OccName] Source #

Which names are in scope?