From: PHO Date: Mon, 14 Nov 2011 06:11:05 +0000 (+0900) Subject: docs X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=619b606;p=Lucu.git docs Ditz-issue: e0312227f40a0fa92d4c5d69a64dad473f54389a --- diff --git a/Network/HTTP/Lucu/Resource/Dispatcher.hs b/Network/HTTP/Lucu/Resource/Dispatcher.hs index 13080ee..7b1ac43 100644 --- a/Network/HTTP/Lucu/Resource/Dispatcher.hs +++ b/Network/HTTP/Lucu/Resource/Dispatcher.hs @@ -28,14 +28,15 @@ class Dispatchable α where {-# INLINE dispatcher #-} dispatcher = Dispatcher --- |FIXME: doc +-- |Container type for 'Dispatchable' type class. data Dispatcher = ∀α. Dispatchable α ⇒ Dispatcher α instance Dispatchable Dispatcher where dispatch (Dispatcher α) = dispatch α dispatcher = id --- |FIXME: doc +-- |@a `'mappend'` b@ first tries to find a resource with @a@, and if +-- it returns 'Nothing', tries @b@ next. instance Monoid Dispatcher where {-# INLINE mempty #-} mempty = dispatcher () @@ -48,30 +49,33 @@ instance Monoid Dispatcher where Just _ → return r Nothing → dispatch β host path +-- |An IO-based dispatcher returning resource paths as well as +-- 'ResourceDef's. instance Dispatchable (CI Text → [ByteString] → IO (Maybe ([ByteString], ResourceDef))) where dispatch = id +-- |An IO-based dispatcher. instance Dispatchable (CI Text → [ByteString] → IO (Maybe ResourceDef)) where dispatch = ((((<$>) ∘ (<$>)) ((,) []) ∘) ∘) +-- |A pure dispatcher. instance Dispatchable (CI Text → [ByteString] → Maybe ResourceDef) where dispatch = (((return ∘ ((,) [] <$>)) ∘) ∘) +-- |An IO-based dispatcher ignoring host names. instance Dispatchable ([ByteString] → IO (Maybe ResourceDef)) where dispatch = const ∘ (((<$>) ∘ (<$>)) ((,) []) ∘) +-- |A pure dispatcher ignoring host names. instance Dispatchable ([ByteString] → Maybe ResourceDef) where dispatch = const ∘ ((return ∘ ((,) [] <$>)) ∘) -instance Dispatchable (IO (Maybe ResourceDef)) where - dispatch = const ∘ const ∘ ((<$>) ∘ (<$>)) ((,) []) - -- |The constant dispatcher returning always the same 'ResourceDef'. instance Dispatchable ResourceDef where dispatch = const ∘ const ∘ return ∘ Just ∘ (,) [] -- |The empty dispatcher returning always 'Nothing'. instance Dispatchable () where - dispatch _ _ _ = return Nothing \ No newline at end of file + dispatch _ _ _ = return Nothing