{-# 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 ()
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