use explicit data type for sign in interval literals
This commit is contained in:
parent
d52b5efc8b
commit
c56a1c8fc8
|
@ -686,8 +686,8 @@ this. also fix the monad -> applicative
|
||||||
|
|
||||||
> intervalLit :: Parser ScalarExpr
|
> intervalLit :: Parser ScalarExpr
|
||||||
> intervalLit = try (keyword_ "interval" >> do
|
> intervalLit = try (keyword_ "interval" >> do
|
||||||
> s <- optionMaybe $ choice [True <$ symbol_ "+"
|
> s <- optionMaybe $ choice [Plus <$ symbol_ "+"
|
||||||
> ,False <$ symbol_ "-"]
|
> ,Minus <$ symbol_ "-"]
|
||||||
> lit <- singleQuotesOnlyStringTok
|
> lit <- singleQuotesOnlyStringTok
|
||||||
> q <- optionMaybe intervalQualifier
|
> q <- optionMaybe intervalQualifier
|
||||||
> mkIt s lit q)
|
> mkIt s lit q)
|
||||||
|
|
|
@ -45,7 +45,9 @@ which have been changed to try to improve the layout of the output.
|
||||||
> scalarExpr _ (NumLit s) = text s
|
> scalarExpr _ (NumLit s) = text s
|
||||||
> scalarExpr _ (IntervalLit s v f t) =
|
> scalarExpr _ (IntervalLit s v f t) =
|
||||||
> text "interval"
|
> text "interval"
|
||||||
> <+> me (\x -> if x then text "+" else text "-") s
|
> <+> me (\x -> text $ case x of
|
||||||
|
> Plus -> "+"
|
||||||
|
> Minus -> "-") s
|
||||||
> <+> quotes (text v)
|
> <+> quotes (text v)
|
||||||
> <+> intervalTypeField f
|
> <+> intervalTypeField f
|
||||||
> <+> me (\x -> text "to" <+> intervalTypeField x) t
|
> <+> me (\x -> text "to" <+> intervalTypeField x) t
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
> ,Name(..)
|
> ,Name(..)
|
||||||
> ,TypeName(..)
|
> ,TypeName(..)
|
||||||
> ,IntervalTypeField(..)
|
> ,IntervalTypeField(..)
|
||||||
|
> ,Sign(..)
|
||||||
> ,PrecMultiplier(..)
|
> ,PrecMultiplier(..)
|
||||||
> ,PrecUnits(..)
|
> ,PrecUnits(..)
|
||||||
> ,SetQuantifier(..)
|
> ,SetQuantifier(..)
|
||||||
|
@ -95,7 +96,7 @@
|
||||||
> -- | text of interval literal, units of interval precision,
|
> -- | text of interval literal, units of interval precision,
|
||||||
> -- e.g. interval 3 days (3)
|
> -- e.g. interval 3 days (3)
|
||||||
> | IntervalLit
|
> | IntervalLit
|
||||||
> {ilSign :: Maybe Bool -- ^ true if + used, false if - used
|
> {ilSign :: Maybe Sign -- ^ if + or - used
|
||||||
> ,ilLiteral :: String -- ^ literal text
|
> ,ilLiteral :: String -- ^ literal text
|
||||||
> ,ilFrom :: IntervalTypeField
|
> ,ilFrom :: IntervalTypeField
|
||||||
> ,ilTo :: Maybe IntervalTypeField
|
> ,ilTo :: Maybe IntervalTypeField
|
||||||
|
@ -250,6 +251,9 @@ in other places
|
||||||
> data IntervalTypeField = Itf String (Maybe (Integer, Maybe Integer))
|
> data IntervalTypeField = Itf String (Maybe (Integer, Maybe Integer))
|
||||||
> deriving (Eq,Show,Read,Data,Typeable)
|
> deriving (Eq,Show,Read,Data,Typeable)
|
||||||
|
|
||||||
|
> data Sign = Plus | Minus
|
||||||
|
> deriving (Eq,Show,Read,Data,Typeable)
|
||||||
|
|
||||||
> data PrecMultiplier = PrecK | PrecM | PrecG | PrecT | PrecP
|
> data PrecMultiplier = PrecK | PrecM | PrecG | PrecT | PrecP
|
||||||
> deriving (Eq,Show,Read,Data,Typeable)
|
> deriving (Eq,Show,Read,Data,Typeable)
|
||||||
> data PrecUnits = PrecCharacters
|
> data PrecUnits = PrecCharacters
|
||||||
|
|
|
@ -711,9 +711,9 @@ TODO: unicode escape
|
||||||
> ,("interval '1' day(3)"
|
> ,("interval '1' day(3)"
|
||||||
> ,IntervalLit Nothing "1" (Itf "day" $ Just (3,Nothing)) Nothing)
|
> ,IntervalLit Nothing "1" (Itf "day" $ Just (3,Nothing)) Nothing)
|
||||||
> ,("interval + '1' day(3)"
|
> ,("interval + '1' day(3)"
|
||||||
> ,IntervalLit (Just True) "1" (Itf "day" $ Just (3,Nothing)) Nothing)
|
> ,IntervalLit (Just Plus) "1" (Itf "day" $ Just (3,Nothing)) Nothing)
|
||||||
> ,("interval - '1' second(2,2)"
|
> ,("interval - '1' second(2,2)"
|
||||||
> ,IntervalLit (Just False) "1" (Itf "second" $ Just (2,Just 2)) Nothing)
|
> ,IntervalLit (Just Minus) "1" (Itf "second" $ Just (2,Just 2)) Nothing)
|
||||||
> ,("interval '1' year to month"
|
> ,("interval '1' year to month"
|
||||||
> ,IntervalLit Nothing "1" (Itf "year" Nothing)
|
> ,IntervalLit Nothing "1" (Itf "year" Nothing)
|
||||||
> (Just $ Itf "month" Nothing))
|
> (Just $ Itf "month" Nothing))
|
||||||
|
|
Loading…
Reference in a new issue