Capitalize first letter of a string
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- haskell
- Ambito
- backend-api-design
Direzione di ricerca
Inizia esaminando il comportamento esistente di toTitle e le alternative in Scala e Kotlin proposte nell’issue. Confronta la gestione delle stringhe vuote, delle maiuscole e minuscole e dei caratteri Unicode, quindi determina l’API desiderata e documentane il comportamento. Il lavoro è completato quando l’approccio è stato concordato e il comportamento risultante della libreria è coperto da test pertinenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I am quite surprised by the absence of the common function to capitalize the first letter of a string. Yes, we have toTitle but its behaviour is different to what we have in other languages. Moreover, docs haven't any hints on that topic. Should a library user implement such method himself? If it is not implemented yet then what problems have this approach?
For example, Scala implements the method as following:
/** Returns this string with first character converted to upper case.
* If the first character of the string is capitalized, it is returned unchanged.
* This method does not convert characters outside the Basic Multilingual Plane (BMP).
*/
def capitalize: String =
if (s == null || s.length == 0 || !s.charAt(0).isLower) s
else updated(0, s.charAt(0).toUpper)
Kotlin developers decided that method has non-reliable behaviour in different circumstances, so they deprecated similar method and instead introduced more flexible alternative replaceFirstChar that delegates choosing the type of conversion to user:
public inline fun String.replaceFirstChar(transform: (Char) -> Char): String {
return if (isNotEmpty()) transform(this[0]) + substring(1) else this
}
// Now instead of capitalize() they suggest to use something like:
replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }
We could have something like that in text library. It will help Haskell learners with the knowledge of other languages to adapt to Haskell more quickly.
- Lingua principale
- Haskell
- Stelle
- 424
- Fork
- 167
- Merge medio
- 1g 21h
- PR unite (30g)
- 6
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di haskell/text
-
Relax constraints on decimal / hexadecimal from Data.Text.Read and Data.Text.Lazy.ReadForse già presa @Lysxia l’ha presa 148 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
-
Shrinking is Insanely Slow for `write_read`Forse già presa @BebeSparkelSparkel l’ha presa 926 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 30/100
Tutte le issue di haskell/text
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
haskell/bytestring#730 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
seal-harness/seal-harness#399 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
fmidue/codeworld-tasks#124 ·
-
allow haskell-src-exts-1.24Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
reflex-frp/reflex#563 ·