Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Nicer fromSinglePiece instance

  • Loading branch information...
commit ef482f817605d8544c8a3f1737f8c0c07edee425 1 parent ec4f4af
@snoyberg snoyberg authored
View
8 packages/template/Database/Persist/TH.hs
@@ -27,6 +27,8 @@ import Control.Monad (forM)
import Control.Monad.IO.Control (MonadControlIO)
import qualified System.IO as SIO
import Data.Text (pack)
+import qualified Data.Text.Read
+import qualified Data.Text as T
-- | Converts a quasi-quoted syntax into a list of entity definitions, to be
-- used as input to the template haskell generation code (mkPersist).
@@ -595,7 +597,11 @@ instance Lift PersistUpdate where
lift Divide = [|Divide|]
instance SinglePiece PersistValue where
- fromSinglePiece = Just . PersistText
+ fromSinglePiece t =
+ case Data.Text.Read.signed Data.Text.Read.decimal t of
+ Right (i, t')
+ | T.null t' -> Just $ PersistInt64 i
+ _ -> Just $ PersistText t
toSinglePiece x =
case fromPersistValue x of
Left e -> error e
View
2  packages/template/persistent-template.cabal
@@ -1,5 +1,5 @@
name: persistent-template
-version: 0.5.0
+version: 0.5.0.1
license: BSD3
author: Michael Snoyman <michael@snoyman.com>
maintainer: Michael Snoyman <michael@snoyman.com>
Please sign in to comment.
Something went wrong with that request. Please try again.