F# Data


NameUtils

Tools for generating nice member names that follow F# & .NET naming conventions

Functions and values

Function or valueDescription
niceCamelName s
Signature: s:string -> string

Turns a given non-empty string into a nice 'camelCase' identifier

nicePascalName s
Signature: s:string -> string

Turns a given non-empty string into a nice 'PascalCase' identifier

pluralize s
Signature: s:string -> string

Return the plural of an English word

singularize s
Signature: s:string -> string

Return the singular of an English word

trimHtml s
Signature: s:string -> string

Trim HTML tags from a given string and replace all of them with spaces Multiple tags are replaced with just a single space. (This is a recursive implementation that is somewhat faster than regular expression.)

uniqueGenerator niceName
Signature: niceName:('?132982 -> string) -> '?132982 -> string
Type parameters: '?132982

Given a function to format names (such as niceCamelName or nicePascalName) returns a name generator that never returns duplicate name (by appending an index to already used names)

This function is curried and should be used with partial function application:

let makeUnique = uniqueGenerator nicePascalName
let n1 = makeUnique "sample-name"
let n2 = makeUnique "sample-name"
Fork me on GitHub