This commit is contained in:
Keagan McClelland
2021-01-14 12:00:48 -07:00
committed by Aiden McClelland
parent 16a4c41886
commit 070835c40e
3 changed files with 18 additions and 5 deletions

View File

@@ -56,6 +56,8 @@ instance Show Version where
let postfix = if q == 0 then "" else '.' : show q in show x <> "." <> show y <> "." <> show z <> postfix
instance IsString Version where
fromString s = either error id $ Atto.parseOnly parseVersion (T.pack s)
instance Read Version where
readsPrec i =
-- | A change in the value found at 'major' implies a breaking change in the API that this version number describes
major :: Version -> Word

View File

@@ -3,16 +3,17 @@ module Lib.Types.Emver.Orphans where
import Startlude
import Control.Monad.Fail
import Data.Aeson
import Lib.Types.Emver
import qualified Data.Attoparsec.Text as Atto
import qualified Data.Text as T
import Database.Persist
import Database.Persist.Sql
import qualified Data.Attoparsec.Text as Atto
import Control.Monad.Fail
import qualified Data.Text as T
import Web.HttpApiData
import Yesod.Core.Dispatch
import Lib.Types.Emver
instance ToJSON Version where
toJSON = String . show
instance FromJSON Version where
@@ -38,3 +39,10 @@ instance PersistFieldSql Version where
instance PathPiece VersionRange where
toPathPiece = show
fromPathPiece = hush . Atto.parseOnly parseRange
instance FromHttpApiData Version where
parseUrlPiece = first toS . Atto.parseOnly parseVersion
instance PathPiece Version where
toPathPiece = show
fromPathPiece = hush . Atto.parseOnly parseVersion

View File

@@ -59,4 +59,7 @@ BackupRecord sql=backup
IconDigest
Id AppId
tag (Digest MD5)
WelcomeAck
Id Version
|]