X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FResource%2FDispatcher.hs;h=7b1ac43f485436734a249aa2e6b4228374bae4fe;hp=13080ee1da3a0e9fe32bca44152e6375cb774a58;hb=619b60675f5aca122ca49a2089ee20aeb2f6717f;hpb=6cc54ccef706a0eba367e63c8b4248df81010f2a 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