Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danbroooks committed Nov 28, 2021
1 parent 5295e1f commit 85e2ee8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion persistent-test/src/TypeLitFieldDefsTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ specsWith runDb =
lbl <- getJust labelledKey
liftIO $ typeLitFieldDefsEntityLabelled lbl @?= oneLabelled
liftIO $ typeLitFieldDefsEntityLabelled lbl @?= twentyLabelled

8 changes: 6 additions & 2 deletions persistent/Database/Persist/Quasi/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ parseFieldType t0 =
parseNumericLit :: Char -> Text -> Maybe (ParseState FieldType)
parseNumericLit c t = do
guard (isDigit c && T.all isDigit t)
let (a, b) = T.break (\x -> isSpace x || x `elem` ("()[]"::String)) t
let (a, b) = breakAtNextSpace t
lit <- FTLit . IntTypeLit <$> readMaybe (T.cons c a)
pure $ PSSuccess lit b

parseTypeCon c t = do
guard (isUpper c || c == '\'')
let (a, b) = T.break (\x -> isSpace x || x `elem` ("()[]"::String)) t
let (a, b) = breakAtNextSpace t
pure $ PSSuccess (parseFieldTypePiece c a) b

goMany :: ([FieldType] -> a) -> Text -> ParseState a
Expand All @@ -145,6 +145,10 @@ parseFieldType t0 =
PSFail err -> PSFail err
PSDone -> PSSuccess (front []) t

breakAtNextSpace :: Text -> (Text, Text)
breakAtNextSpace =
T.break isSpace

parseFieldTypePiece :: Char -> Text -> FieldType
parseFieldTypePiece fstChar rest =
case fstChar of
Expand Down
2 changes: 0 additions & 2 deletions persistent/Database/Persist/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ import Database.Persist.PersistValue
-- this module is a bit of a kitchen sink of types and concepts. the guts of
-- persistent, just strewn across the table. in 2.13 let's get this cleaned up
-- and a bit more tidy.
--
-- not sure if the re-export of FieldTypeLit here is correct going forward, given the above
import Database.Persist.Types.Base
( Attr
, CascadeAction(..)
Expand Down

0 comments on commit 85e2ee8

Please sign in to comment.