]> gitweb @ CieloNegro.org - Lucu.git/commitdiff
Data.URI.Scheme
authorPHO <pho@cielonegro.org>
Thu, 12 Jan 2012 16:39:57 +0000 (01:39 +0900)
committerPHO <pho@cielonegro.org>
Thu, 12 Jan 2012 16:39:57 +0000 (01:39 +0900)
Ditz-issue: c80e79a2585ac20cc5ed677d70b6983a2842a81d

Data/URI.hs [new file with mode: 0644]
Data/URI/Internal/Scheme.hs [new file with mode: 0644]
Lucu.cabal

diff --git a/Data/URI.hs b/Data/URI.hs
new file mode 100644 (file)
index 0000000..11618bd
--- /dev/null
@@ -0,0 +1,7 @@
+-- |FIXME
+module Data.URI
+    ( Scheme
+    , unsafeCreateScheme
+    )
+    where
+import Data.URI.Internal.Scheme
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
index 6cbb16add53bf69a8b13eef5a2a8dc2e8f12fcea..cff6ae84a9cc42b154f295ba325907ab6418014e 100644 (file)
@@ -69,6 +69,7 @@ Library
         data-default               == 0.3.*,
         directory                  == 1.1.*,
         filepath                   == 1.2.*,
+        hashable                   == 1.1.*,
         mtl                        == 2.0.*,
         network                    == 2.3.*,
         old-time                   == 1.0.*,
@@ -89,6 +90,7 @@ Library
             -DHAVE_SSL
 
     Exposed-Modules:
+        Data.URI
         Data.Collections.Newtype.TH
         Network.HTTP.Lucu
         Network.HTTP.Lucu.Abortion
@@ -120,6 +122,7 @@ Library
         Network.HTTP.Lucu.Utils
 
     Other-Modules:
+        Data.URI.Internal.Scheme
         Network.HTTP.Lucu.Abortion.Internal
         Network.HTTP.Lucu.Chunk
         Network.HTTP.Lucu.ContentCoding