]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Data/URI/Internal/Scheme.hs
Data.URI.Scheme
[Lucu.git] / Data / URI / Internal / Scheme.hs
diff --git a/Data/URI/Internal/Scheme.hs b/Data/URI/Internal/Scheme.hs
new file mode 100644 (file)
index 0000000..d77fdb5
--- /dev/null
@@ -0,0 +1,40 @@
+{-# LANGUAGE
+    DeriveDataTypeable
+  , GeneralizedNewtypeDeriving
+  , StandaloneDeriving
+  , UnicodeSyntax
+  #-}
+module Data.URI.Internal.Scheme
+    ( Scheme
+    , unsafeCreateScheme
+    )
+    where
+import Data.Ascii (CIAscii)
+import Data.CaseInsensitive
+import Data.Hashable
+import Data.String
+import Data.Typeable
+
+-- |'Scheme' names consist of a non-empty sequence of characters
+-- beginning with a letter and followed by any combination of letters,
+-- digits, plus (\'+\'), period (\'.\'), or hyphen (\'-\'):
+-- <http://tools.ietf.org/html/rfc3986#section-3.1>
+newtype Scheme = Scheme CIAscii
+    deriving ( Eq
+             , FoldCase
+             , Hashable
+             , Ord
+             , Show
+             , Typeable
+             )
+-- scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
+
+-- |'isString' is a fast but unsafe way to create 'Scheme' such that
+-- no validation on the string is performed.
+deriving instance IsString Scheme
+
+-- |Converts a 'CIAscii' to 'Scheme' without any validation on the
+-- string.
+unsafeCreateScheme ∷ CIAscii → Scheme
+{-# INLINE CONLIKE unsafeCreateScheme #-}
+unsafeCreateScheme = Scheme