0 | module TyTTP.Core.Routing
 1 |
 2 | import public Control.Monad.Maybe
 3 | import TyTTP.Core.Context
 4 |
 5 | export
 6 | routes : Alternative m
 7 |   => List (
 8 |     Context me u v h1 s h2 a b
 9 |     -> m $ Context me' p' v' h1' s' h2' a' b'
10 |   )
11 |   -> Context me u v h1 s h2 a b
12 |   -> m $ Context me' p' v' h1' s' h2' a' b'
13 | routes handlers ctx = choiceMap (ctx) handlers
14 |
15 | export
16 | routes' : Monad m
17 |   => (
18 |     Context me u v h1 s h2 a b
19 |     -> m $ Context me' p' v' h1' s' h2' a' b'
20 |   )
21 |   -> List (
22 |     Context me u v h1 s h2 a b
23 |     -> MaybeT m $ Context me' p' v' h1' s' h2' a' b'
24 |   )
25 |   -> Context me u v h1 s h2 a b
26 |   -> m $ Context me' p' v' h1' s' h2' a' b'
27 | routes' def handlers ctx = do
28 |   Just result <- runMaybeT $ routes handlers ctx
29 |     | Nothing => def ctx
30 |   pure result
31 |
32 |