not-in-base-0.1.1: Useful utility functions that only depend on base.

NIB.String

Description

Contains useful generic functions not found elsewhere.

Synopsis

Documentation

class ToString a whereSource

Methods

toString :: a -> StringSource

removeBreak :: String -> StringSource

Remove all line breaks in a string

 "testtest" == removeBreak "test\n\rtest\r"

lowerFirst :: String -> StringSource

Convert first character in String to lower.

 lowerFirst "Foo" == "foo"
 lowerFirst "BaR" == "baR"
 lowerFirst "g0O" == "g0O".'

upperFirst :: String -> StringSource

Convert first character in String to upper.

 upperFirst "foo" == "Foo"
 upperFirst "bAr" == "BAr"
 upperFirst "G0O" == "G0O".'

spaceToBlank :: String -> StringSource

Convert every space (' ') in a string to a blank ('_') instead.

 spaceToBlank " " == "_"
 spaceToBlank " foo  " == "_foo__"
 spaceToBlank "b a r" == "b_a_r"

trimWs :: String -> StringSource

Trims whitespace from the beginning or end.

 trimWs "  foo  " == "foo"