Skip to content

Documentation of toTitle needs update #291

Closed

Description

It appears the change proposed in issue 167 got committed so that title-casing only takes place after spaces. However, the documentation still reads: "The first letter of the input is converted to title case, as is every subsequent letter that immediately follows a non-letter".

Activity

  1. Bodigrim commented on May 18, 2022

    @Bodigrim
    Contributor

    I think the easiest thing to do is to quote in haddocks a reference (but slow) impementation of toTitle:

    referenceToTitle _ [] = []
    referenceToTitle False (y : ys)
    | C.isLetter y = C.toUpper y : referenceToTitle True ys
    | otherwise = y : referenceToTitle False ys
    referenceToTitle True (y : ys)
    | C.isLetter y = C.toLower y : referenceToTitle True ys
    | otherwise = y : referenceToTitle (not (C.isSpace y)) ys

  2. swinilohani616-dot commented on Nov 18, 2026

    @swinilohani616-dot
    Contributor

    I've opened #720 for this. It rewrites the toTitle docs to say what it actually does: only the first letter of each word is title cased, and words are split on white space, so "hello-world" becomes "Hello-world". As suggested above, it also includes the reference implementation the tests use for ASCII input. Same change in Data.Text.Lazy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions