-- |FIXME: docs
class Dispatchable α where
- findResource ∷ α
- → CI Text
- → [ByteString]
- → IO (Maybe ([ByteString], ResourceDef))
+ dispatch ∷ α
+ → CI Text
+ → [ByteString]
+ → IO (Maybe ([ByteString], ResourceDef))
dispatcher ∷ α → Dispatcher
{-# INLINE dispatcher #-}
data Dispatcher = ∀α. Dispatchable α ⇒ Dispatcher α
instance Dispatchable Dispatcher where
- findResource (Dispatcher α) = findResource α
+ dispatch (Dispatcher α) = dispatch α
dispatcher = id
-- |FIXME: doc
{-# INLINEABLE mappend #-}
mappend (Dispatcher α) (Dispatcher β)
= dispatcher
- $ \host path → do r ← findResource α host path
+ $ \host path → do r ← dispatch α host path
case r of
Just _ → return r
- Nothing → findResource β host path
+ Nothing → dispatch β host path
instance Dispatchable (CI Text
→ [ByteString]
→ IO (Maybe ([ByteString], ResourceDef))) where
- findResource = id
+ dispatch = id
instance Dispatchable (CI Text → [ByteString] → IO (Maybe ResourceDef)) where
- findResource = ((((<$>) ∘ (<$>)) ((,) []) ∘) ∘)
+ dispatch = ((((<$>) ∘ (<$>)) ((,) []) ∘) ∘)
instance Dispatchable (CI Text → [ByteString] → Maybe ResourceDef) where
- findResource = (((return ∘ ((,) [] <$>)) ∘) ∘)
+ dispatch = (((return ∘ ((,) [] <$>)) ∘) ∘)
instance Dispatchable ([ByteString] → IO (Maybe ResourceDef)) where
- findResource = const ∘ (((<$>) ∘ (<$>)) ((,) []) ∘)
+ dispatch = const ∘ (((<$>) ∘ (<$>)) ((,) []) ∘)
instance Dispatchable ([ByteString] → Maybe ResourceDef) where
- findResource = const ∘ ((return ∘ ((,) [] <$>)) ∘)
+ dispatch = const ∘ ((return ∘ ((,) [] <$>)) ∘)
instance Dispatchable (IO (Maybe ResourceDef)) where
- findResource = const ∘ const ∘ ((<$>) ∘ (<$>)) ((,) [])
+ dispatch = const ∘ const ∘ ((<$>) ∘ (<$>)) ((,) [])
instance Dispatchable ResourceDef where
- findResource = const ∘ const ∘ return ∘ Just ∘ (,) []
+ dispatch = const ∘ const ∘ return ∘ Just ∘ (,) []