]> gitweb @ CieloNegro.org - Lucu.git/blob - Data/URI/Internal/Scheme.hs
Data.URI.Scheme
[Lucu.git] / Data / URI / Internal / Scheme.hs
1 {-# LANGUAGE
2     DeriveDataTypeable
3   , GeneralizedNewtypeDeriving
4   , StandaloneDeriving
5   , UnicodeSyntax
6   #-}
7 module Data.URI.Internal.Scheme
8     ( Scheme
9     , unsafeCreateScheme
10     )
11     where
12 import Data.Ascii (CIAscii)
13 import Data.CaseInsensitive
14 import Data.Hashable
15 import Data.String
16 import Data.Typeable
17
18 -- |'Scheme' names consist of a non-empty sequence of characters
19 -- beginning with a letter and followed by any combination of letters,
20 -- digits, plus (\'+\'), period (\'.\'), or hyphen (\'-\'):
21 -- <http://tools.ietf.org/html/rfc3986#section-3.1>
22 newtype Scheme = Scheme CIAscii
23     deriving ( Eq
24              , FoldCase
25              , Hashable
26              , Ord
27              , Show
28              , Typeable
29              )
30 -- scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
31
32 -- |'isString' is a fast but unsafe way to create 'Scheme' such that
33 -- no validation on the string is performed.
34 deriving instance IsString Scheme
35
36 -- |Converts a 'CIAscii' to 'Scheme' without any validation on the
37 -- string.
38 unsafeCreateScheme ∷ CIAscii → Scheme
39 {-# INLINE CONLIKE unsafeCreateScheme #-}
40 unsafeCreateScheme = Scheme