fix the permutation parsers
This commit is contained in:
parent
8cc475240b
commit
af8ea544f6
|
@ -222,6 +222,7 @@ import Text.Megaparsec
|
||||||
,between
|
,between
|
||||||
)
|
)
|
||||||
import qualified Control.Monad.Combinators.Expr as E
|
import qualified Control.Monad.Combinators.Expr as E
|
||||||
|
import qualified Control.Monad.Permutations as P
|
||||||
|
|
||||||
import Control.Monad.Reader
|
import Control.Monad.Reader
|
||||||
(Reader(..)
|
(Reader(..)
|
||||||
|
@ -1485,8 +1486,10 @@ allows offset and fetch in either order
|
||||||
-}
|
-}
|
||||||
|
|
||||||
offsetFetch :: Parser (Maybe ScalarExpr, Maybe ScalarExpr)
|
offsetFetch :: Parser (Maybe ScalarExpr, Maybe ScalarExpr)
|
||||||
offsetFetch = undefined {-permute ((,) <$?> (Nothing, Just <$> offset)
|
offsetFetch =
|
||||||
<|?> (Nothing, Just <$> fetch))-}
|
P.runPermutation $ (,) <$> maybePermutation offset <*> maybePermutation fetch
|
||||||
|
where
|
||||||
|
maybePermutation p = P.toPermutationWithDefault Nothing (Just <$> p)
|
||||||
|
|
||||||
offset :: Parser ScalarExpr
|
offset :: Parser ScalarExpr
|
||||||
offset = keyword_ "offset" *> scalarExpr
|
offset = keyword_ "offset" *> scalarExpr
|
||||||
|
@ -1712,8 +1715,10 @@ refMatch = option DefaultReferenceMatch
|
||||||
,MatchPartial <$ keyword_ "partial"
|
,MatchPartial <$ keyword_ "partial"
|
||||||
,MatchSimple <$ keyword_ "simple"])
|
,MatchSimple <$ keyword_ "simple"])
|
||||||
refActions :: Parser (ReferentialAction,ReferentialAction)
|
refActions :: Parser (ReferentialAction,ReferentialAction)
|
||||||
refActions = undefined {-permute ((,) <$?> (DefaultReferentialAction, onUpdate)
|
refActions =
|
||||||
<|?> (DefaultReferentialAction, onDelete))-}
|
P.runPermutation $ (,)
|
||||||
|
<$> P.toPermutationWithDefault DefaultReferentialAction onUpdate
|
||||||
|
<*> P.toPermutationWithDefault DefaultReferentialAction onDelete
|
||||||
where
|
where
|
||||||
-- todo: left factor?
|
-- todo: left factor?
|
||||||
onUpdate = try (keywords_ ["on", "update"]) *> referentialAction
|
onUpdate = try (keywords_ ["on", "update"]) *> referentialAction
|
||||||
|
@ -1763,20 +1768,20 @@ sequenceGeneratorOptions =
|
||||||
-- such as cycle and nocycle
|
-- such as cycle and nocycle
|
||||||
-- sort out options which are sometimes not allowed
|
-- sort out options which are sometimes not allowed
|
||||||
-- as datatype, and restart with
|
-- as datatype, and restart with
|
||||||
undefined {-permute ((\a b c d e f g h j k -> catMaybes [a,b,c,d,e,f,g,h,j,k])
|
P.runPermutation ((\a b c d e f g h j k -> catMaybes [a,b,c,d,e,f,g,h,j,k])
|
||||||
<$?> nj startWith
|
<$> maybePermutation startWith
|
||||||
<|?> nj dataType
|
<*> maybePermutation dataType
|
||||||
<|?> nj restart
|
<*> maybePermutation restart
|
||||||
<|?> nj incrementBy
|
<*> maybePermutation incrementBy
|
||||||
<|?> nj maxValue
|
<*> maybePermutation maxValue
|
||||||
<|?> nj noMaxValue
|
<*> maybePermutation noMaxValue
|
||||||
<|?> nj minValue
|
<*> maybePermutation minValue
|
||||||
<|?> nj noMinValue
|
<*> maybePermutation noMinValue
|
||||||
<|?> nj scycle
|
<*> maybePermutation scycle
|
||||||
<|?> nj noCycle
|
<*> maybePermutation noCycle
|
||||||
)-}
|
)
|
||||||
where
|
where
|
||||||
nj p = (Nothing,Just <$> p)
|
maybePermutation p = P.toPermutationWithDefault Nothing (Just <$> p)
|
||||||
startWith = keywords_ ["start", "with"] >>
|
startWith = keywords_ ["start", "with"] >>
|
||||||
SGOStartWith <$> signedInteger
|
SGOStartWith <$> signedInteger
|
||||||
dataType = keyword_ "as" >>
|
dataType = keyword_ "as" >>
|
||||||
|
|
Loading…
Reference in a new issue