0.2.5 initial commit

Makefile incomplete
This commit is contained in:
Aiden McClelland
2020-11-23 13:44:28 -07:00
commit 95d3845906
503 changed files with 53448 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
module Orphans.Digest where
import Startlude
import Crypto.Hash
import Data.ByteArray
import Data.ByteArray.Encoding
import Data.String.Interpolate.IsString
import Database.Persist.Sql
import Web.HttpApiData
instance HashAlgorithm a => PersistField (Digest a) where
toPersistValue = PersistByteString . convert
fromPersistValue (PersistByteString bs) =
note [i|Invalid Digest: #{decodeUtf8 $ convertToBase Base16 bs}|] . digestFromByteString $ bs
fromPersistValue other = Left $ "Invalid Digest: " <> show other
instance HashAlgorithm a => PersistFieldSql (Digest a) where
sqlType _ = SqlBlob
instance HashAlgorithm a => ToHttpApiData (Digest a) where
toUrlPiece = decodeUtf8 . convertToBase Base16

18
agent/src/Orphans/UUID.hs Normal file
View File

@@ -0,0 +1,18 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Orphans.UUID where
import Startlude
import Data.UUID
import Database.Persist.Sql
import Yesod.Core
instance PathPiece UUID where
toPathPiece = show
fromPathPiece = readMaybe
instance PersistField UUID where
toPersistValue = PersistText . show
fromPersistValue (PersistText t) = note "Invalid UUID" $ readMaybe t
fromPersistValue other = Left $ "Invalid UUID: " <> show other
instance PersistFieldSql UUID where
sqlType _ = SqlString