|
1 | 1 | module Routing.Match where
|
2 | 2 |
|
| 3 | +import Prelude |
3 | 4 |
|
4 |
| -import Prelude (class Applicative, class Apply, class Functor, pure, bind, const, one, id, unit, ($), (<<<), (<$>), (<>), (*), (==)) |
5 |
| -import Data.Either (Either(..)) |
6 |
| -import Data.Tuple (Tuple(..), snd) |
7 |
| -import Data.Maybe (Maybe(..)) |
8 |
| -import Data.List (List(..), reverse) |
9 | 5 | import Control.Alt (class Alt, (<|>))
|
10 |
| -import Control.Plus (class Plus) |
11 | 6 | import Control.Alternative (class Alternative)
|
12 |
| -import Global (readFloat, isNaN) |
13 |
| -import Data.Semiring.Free (Free(), free) |
| 7 | +import Control.Plus (class Plus) |
| 8 | + |
| 9 | +import Data.Either (Either(..)) |
14 | 10 | import Data.Foldable (foldl)
|
| 11 | +import Data.List (List(..), reverse) |
| 12 | +import Data.Map as M |
| 13 | +import Data.Maybe (Maybe(..)) |
| 14 | +import Data.Newtype (class Newtype, unwrap) |
| 15 | +import Data.Semiring.Free (Free(), free) |
| 16 | +import Data.Tuple (Tuple(..), snd) |
15 | 17 | import Data.Validation.Semiring (V, invalid, unV)
|
16 |
| -import Data.Newtype (unwrap) |
17 |
| - |
18 | 18 |
|
19 |
| -import Data.Map as M |
| 19 | +import Global (readFloat, isNaN) |
20 | 20 |
|
21 |
| -import Routing.Types (Route, RoutePart(..)) |
22 | 21 | import Routing.Match.Class (class MatchClass)
|
23 | 22 | import Routing.Match.Error (MatchError(..), showMatchError)
|
| 23 | +import Routing.Types (Route, RoutePart(..)) |
24 | 24 |
|
25 | 25 | newtype Match a = Match (Route -> V (Free MatchError) (Tuple Route a))
|
26 |
| -unMatch :: forall a. Match a -> (Route -> V (Free MatchError) (Tuple Route a)) |
27 |
| -unMatch (Match a) = a |
| 26 | + |
| 27 | +-- Manual instance due to the `Route` synonym in the above |
| 28 | +instance newtypeMatch :: Newtype (Match a) (List RoutePart -> V (Free MatchError) (Tuple (List RoutePart) a)) where |
| 29 | + wrap = Match |
| 30 | + unwrap (Match m) = m |
28 | 31 |
|
29 | 32 | instance matchMatchClass :: MatchClass Match where
|
30 | 33 | lit input = Match \route ->
|
|
0 commit comments