git.iko.soy/typeable/inflections-hs
on master help sign in
Documentation corrections
8820a16mrkkrp
Text/Inflections.hs+16−16
@@ -1,6 +1,6 @@
1-- |
1-- |
2-- Module : Text.Inflections
2-- Module : Text.Inflections
3−-- Description : Rails-like inflections library for common String transformations.
3+-- Description : Rails-like inflections library for common Text transformations.
4-- Copyright : (c) Justin Leitgeb
4-- Copyright : (c) Justin Leitgeb
5-- License : MIT
5-- License : MIT
6--
6--
@@ -8,7 +8,7 @@
8-- Stability : unstable
8-- Stability : unstable
9-- Portability : portable
9-- Portability : portable
10--
10--
11−-- This module provides methods for common String transformations, similar
11+-- This module provides methods for common 'Text' transformations, similar
12-- to the Inflections library found in Rails:
12-- to the Inflections library found in Rails:
13--
13--
14-- <http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html>
14-- <http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html>
@@ -17,7 +17,7 @@
17-- implementations in Rails' ActiveSupport, the philosophy of this library
17-- implementations in Rails' ActiveSupport, the philosophy of this library
18-- is fundamentally different. Where Rails tries to be as permissive as
18-- is fundamentally different. Where Rails tries to be as permissive as
19-- possible, and return a String when given any input, this library tries to
19-- possible, and return a String when given any input, this library tries to
20−-- output strings that make sense according to the function that is called.
20+-- output 'Text' that makes sense according to the function that is called.
21--
21--
22-- When you look closely at many of the functions in Rails' inflections
22-- When you look closely at many of the functions in Rails' inflections
23-- library, you will notice that many of them are partial. That is, they
23-- library, you will notice that many of them are partial. That is, they
@@ -33,7 +33,7 @@
33-- >>> "foo bar".underscore
33-- >>> "foo bar".underscore
34-- "foo bar"
34-- "foo bar"
35--
35--
36−-- The output isn't underscored - it contains a space! It turns out that
36+-- The output isn't underscored — it contains a space! It turns out that
37-- some of the functions from Inflections in ActiveSupport are /partial/.
37-- some of the functions from Inflections in ActiveSupport are /partial/.
38-- I.e., the outputs are really only specified for a certain range of the
38-- I.e., the outputs are really only specified for a certain range of the
39-- inputs allowed by the String type.
39-- inputs allowed by the String type.
@@ -42,7 +42,7 @@
42-- results by separating the parsing of strings into tokens from the
42-- results by separating the parsing of strings into tokens from the
43-- application of transformations. Let's see an example.
43-- application of transformations. Let's see an example.
44--
44--
45−-- First, we tokenize an underscored String using 'parseSnakeCase':
45+-- First, we tokenize an underscored 'Text' using 'parseSnakeCase':
46--
46--
47-- >>> parseSnakeCase [] "foo_bar"
47-- >>> parseSnakeCase [] "foo_bar"
48-- Right [Word "foo",Word "bar"]
48-- Right [Word "foo",Word "bar"]
@@ -79,8 +79,17 @@
79{-# LANGUAGE CPP #-}
79{-# LANGUAGE CPP #-}
80
80
81module Text.Inflections
81module Text.Inflections
82+ ( -- * Types and helpers
83+ Word
84+ , WordType (..)
85+ , mkWord
86+ , mkAcronym
87+ , unWord
88+ , SomeWord (..)
89+ , unSomeWord
90+ , InflectionException (..)
82− ( -- * Parsing
91+ -- * Parsing
83− parseSnakeCase
92+ , parseSnakeCase
84 , parseCamelCase
93 , parseCamelCase
85 -- * Rendering
94 -- * Rendering
86 , camelize
95 , camelize
@@ -97,15 +106,6 @@ module Text.Inflections
97 , transliterateCustom
106 , transliterateCustom
98 , ordinalize
107 , ordinalize
99 , ordinal
108 , ordinal
100− -- * Types and helpers
101− , Word
102− , WordType (..)
103− , mkWord
104− , mkAcronym
105− , unWord
106− , SomeWord (..)
107− , unSomeWord
108− , InflectionException (..)
109 -- * Often used combinators
109 -- * Often used combinators
110 , toUnderscore
110 , toUnderscore
111 , toDashed
111 , toDashed
Text/Inflections/Camelize.hs+2−2
@@ -29,7 +29,7 @@ import Control.Applicative
29--
29--
30-- >>> foo <- SomeWord <$> mkWord "foo"
30-- >>> foo <- SomeWord <$> mkWord "foo"
31-- >>> bar <- SomeWord <$> mkAcronym "bar"
31-- >>> bar <- SomeWord <$> mkAcronym "bar"
32−-- >>> bazz <- SomeWord <$> mkAcronym "bazz"
32+-- >>> bazz <- SomeWord <$> mkWord "bazz"
33-- >>> camelize [foo,bar,bazz]
33-- >>> camelize [foo,bar,bazz]
34-- "FoobarBazz"
34-- "FoobarBazz"
35camelize
35camelize
@@ -41,7 +41,7 @@ camelize = camelizeCustom True
41--
41--
42-- >>> foo <- SomeWord <$> mkWord "foo"
42-- >>> foo <- SomeWord <$> mkWord "foo"
43-- >>> bar <- SomeWord <$> mkAcronym "bar"
43-- >>> bar <- SomeWord <$> mkAcronym "bar"
44−-- >>> bazz <- SomeWord <$> mkAcronym "bazz"
44+-- >>> bazz <- SomeWord <$> mkWord "bazz"
45-- >>> camelizeCustom False [foo,bar,bazz]
45-- >>> camelizeCustom False [foo,bar,bazz]
46-- "foobarBazz"
46-- "foobarBazz"
47camelizeCustom
47camelizeCustom