on master help sign in
Relax the constraint on bindEitherTable to just Functor
ed39571Ollie Charles
src/Rel8/Query/Either.hs+4−3
@@ -9,6 +9,7 @@ module Rel8.Query.Either
9where
9where
10
10
11-- base
11-- base
12+import Data.Functor ( (<&>) )
12import Prelude
13import Prelude
13
14
14-- rel8
15-- rel8
@@ -40,11 +41,11 @@ keepRightTable e@(EitherTable _ _ b) = do
40 pure b
41 pure b
41
42
42
43
43−bindEitherTable :: (Table Expr a, Monad m)
44+bindEitherTable :: (Table Expr a, Functor m)
44 => (i -> m (EitherTable a b)) -> EitherTable a i -> m (EitherTable a b)
45 => (i -> m (EitherTable a b)) -> EitherTable a i -> m (EitherTable a b)
45bindEitherTable query e@(EitherTable input a i) = do
46bindEitherTable query e@(EitherTable input a i) = do
46− EitherTable output a' b <- query i
47+ query i <&> \(EitherTable output a' b) ->
47− pure $ EitherTable (input <> output) (bool a a' (isRightTable e)) b
48+ EitherTable (input <> output) (bool a a' (isRightTable e)) b
48
49
49
50
50bitraverseEitherTable :: (Table Expr c, Table Expr d)
51bitraverseEitherTable :: (Table Expr c, Table Expr d)