on master help sign in
cleanup some warnings and cement reliance on update parseTimeM (requires GHC 7.10 with new time module)
commit6b30742137f00a7c060a5172c2311435a5613c4e authorAgentM <agentm@themactionfaction.com> dateSat 19 Sep 2015, 22:22 (11 years ago) parent7cd02a2
4 files changed+8−9
ProjectM36/Atom.hs+2−4 ProjectM36/Base.hs+1 ProjectM36/Relation/Show/CSV.hs+2−2 TutorialD/Interpreter/RelationalExpr.hs+3−3
ProjectM36/Atom.hs+2−4
@@ -5,7 +5,6 @@ import ProjectM36.Error
55import qualified Data.Text as T
66import Text.Read (readMaybe)
77import Data.Time.Format
8−--import System.Locale
98
109relationForAtom :: Atom -> Either RelationalError Relation
1110relationForAtom (RelationAtom rel) = Right rel
@@ -34,14 +33,13 @@ atomFromString BoolAtomType strIn = case strIn of
3433 _ -> Left (ParseError "Failed to parse boolean")
3534atomFromString (RelationAtomType _) _ = Left $ ParseError "Nested relation parsing not supported"
3635atomFromString DateTimeAtomType strIn =
37− --deprecated in time 1.5- needs update for GHC 7.10
38− case parseTime defaultTimeLocale "%Y-%m-%d %H:%M:%S" strIn of
36+ case parseTimeM False defaultTimeLocale "%Y-%m-%d %H:%M:%S" strIn of
3937 Just utctime -> Right $ DateTimeAtom utctime
4038 Nothing -> Left $ ParseError "Failed to parse datetime"
4139atomFromString DoubleAtomType strIn = case readMaybe strIn of
4240 Just d -> Right $ DoubleAtom d
4341 Nothing -> Left (ParseError "Failed to parse double")
44−atomFromString DateAtomType strIn = case parseTime defaultTimeLocale "%Y-%m-%d" strIn of
42+atomFromString DateAtomType strIn = case parseTimeM False defaultTimeLocale "%Y-%m-%d" strIn of
4543 Just date -> Right $ DateAtom date
4644 Nothing -> Left $ ParseError "Failed to parse datetime"
4745atomFromString AnyAtomType _ = Left $ ParseError "Parsing AnyAtomType is not supported"
ProjectM36/Base.hs+1
@@ -1,4 +1,5 @@
11{-# LANGUAGE GADTs,DeriveGeneric,GeneralizedNewtypeDeriving #-}
2+{-# OPTIONS_GHC -fno-warn-orphans #-}
23module ProjectM36.Base where
34import qualified Data.Map as M
45import qualified Data.HashSet as HS
ProjectM36/Relation/Show/CSV.hs+2−2
@@ -3,11 +3,11 @@ import ProjectM36.Base
33import ProjectM36.Attribute
44import Data.Csv
55import ProjectM36.Tuple
6−import qualified Data.HashSet as HS
76import qualified Data.ByteString.Lazy as BS
87import qualified Data.Vector as V
98import ProjectM36.Error
109import qualified Data.Text.Encoding as TE
10+{-# OPTIONS_GHC -fno-warn-orphans #-}
1111
1212--spit out error for relations without attributes (since relTrue and relFalse cannot be distinguished then as CSV) and for relations with relation-valued attributes
1313relationAsCSV :: Relation -> Either RelationalError BS.ByteString
@@ -25,7 +25,7 @@ relationAsCSV (Relation attrs tupleSet) = if relValAttrs /= [] then --check for
2525instance ToRecord RelationTuple where
2626 toRecord tuple = toRecord $ map toField (V.toList $ tupleAtoms tuple)
2727-}
28−
28+
2929instance ToNamedRecord RelationTuple where
3030 toNamedRecord tuple = namedRecord $ map (\(k,v) -> TE.encodeUtf8 k .= v) (tupleAssocs tuple)
3131
TutorialD/Interpreter/RelationalExpr.hs+3−3
@@ -173,7 +173,7 @@ restrictionPredicateP = buildExpressionParser predicateOperators predicateTerm
173173 [Infix (reservedOp "or" >> return OrPredicate) AssocLeft]
174174 ]
175175 predicateTerm = parens restrictionPredicateP
176− <|> try restrictionAtomExprP
176+ <|> try restrictionAtomExprP
177177 <|> try restrictionAttributeEqualityP
178178 <|> try relationalBooleanExprP
179179
@@ -245,7 +245,7 @@ dateTimeAtomP = do
245245 reserved "::datetime"
246246 return dateTimeString
247247 --deprecated in time 1.5- needs update for GHC 7.10
248− case parseTime defaultTimeLocale "%Y-%m-%d %H:%M:%S" dateTimeString' of
248+ case parseTimeM False defaultTimeLocale "%Y-%m-%d %H:%M:%S" dateTimeString' of
249249 Just utctime -> return $ DateTimeAtom utctime
250250 Nothing -> fail "Failed to parse datetime"
251251
@@ -255,7 +255,7 @@ dateAtomP = do
255255 dateString <- quotedString
256256 reserved "::date"
257257 return dateString
258− case parseTime defaultTimeLocale "%Y-%m-%d" dateString' of
258+ case parseTimeM False defaultTimeLocale "%Y-%m-%d" dateString' of
259259 Just utctime -> return $ DateAtom utctime
260260 Nothing -> fail "Failed to parse date"
261261