Skip to content

Commit

Permalink
Version 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
ddssff committed Jun 9, 2019
1 parent f5b8f36 commit 3614e9a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 30 deletions.
12 changes: 6 additions & 6 deletions Appraisal/AcidCache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass, DeriveFunctor, DeriveGeneric #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DeriveDataTypeable #-}
Expand Down Expand Up @@ -47,7 +48,7 @@ import Control.Lens ((%=), at, makeLenses, makePrisms, view)
import Data.Generics (Data, Proxy, Typeable)
import Data.Map.Strict as Map (delete, difference, fromSet, insert, intersection, Map, union)
import Data.SafeCopy -- (deriveSafeCopy, extension, Migrate(..), SafeCopy)
import Extra.Serialize (label, Serialize)
import Data.Serialize.Get (label)
import GHC.Generics (Generic)
#if !__GHCJS__
import Control.Monad.Catch (bracket, {-MonadCatch,-} MonadMask)
Expand Down Expand Up @@ -76,6 +77,7 @@ $(makeLenses ''CacheMap)

$(deriveSafeCopy 1 'base ''CacheValue)
#if 0
-- Need an Ord key constraint here for some reason.
$(deriveSafeCopy 2 'extension ''CacheMap)
-- $(safeCopyInstance 2 'extension [t|CacheMap|])
#else
Expand All @@ -88,7 +90,7 @@ instance (Ord key, SafeCopy key, SafeCopy val, SafeCopy err) => SafeCopy (CacheM
getCopy
= contain
((label "Appraisal.AcidCache.CacheMap:")
(do safeget <- getSafeGet
(do safeget <- getSafeGet @(Map key (CacheValue err val))
(return CacheMap <*> safeget)))
version = 2
kind = extension
Expand Down Expand Up @@ -149,8 +151,8 @@ withCache path f = bracket (liftIOError (openCache path)) (liftIOError . createC
-- | Note that class 'HasCache' and the 'cacheInsert' function return
-- values containing a 'FileError', but the monad m only has the
-- constraint HasFileError.
class (Ord key, SafeCopy key, Typeable key, Show key, Serialize key,
SafeCopy val, Typeable val, Serialize val,
class (Ord key, SafeCopy key, Typeable key, Show key,
SafeCopy val, Typeable val,
SafeCopy err, Typeable err, MonadIO m) => HasCache key val err m where
askCacheAcid :: m (AcidState (CacheMap key val err))
buildCacheValue :: key -> m (CacheValue err val)
Expand Down Expand Up @@ -187,7 +189,5 @@ cacheDelete _ keys = do

deriving instance (Data err, Data val) => Data (CacheValue err val)
deriving instance (Ord key, Data key, Data val, Data err) => Data (CacheMap key val err)
deriving instance (Serialize err, Serialize val) => Serialize (CacheValue err val)
deriving instance (Ord key, Serialize err, Serialize key, Serialize val) => Serialize (CacheMap key val err)
deriving instance (Show err, Show val) => Show (CacheValue err val)
deriving instance (Show key, Show val, Show err) => Show (CacheMap key val err)
6 changes: 2 additions & 4 deletions Appraisal/FileCache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ import Data.Monoid ( (<>) )
import Data.SafeCopy (base, deriveSafeCopy)
import Data.Text (pack, unpack)
import Extra.Except
import Extra.Serialize (deriveSerializeViaSafeCopy)
import qualified Language.Haskell.TH.Lift as TH (deriveLiftMany)
import Network.URI ( URI(..), URIAuth(..), parseRelativeReference, parseURI )
import Network.URI ( URI(..), parseRelativeReference, parseURI )
import System.FilePath ( (</>) )
import System.Log.Logger ( logM, Priority(DEBUG, ERROR) )
import System.Unix.FilePath ( (<++>) )
Expand Down Expand Up @@ -128,8 +127,7 @@ $(concat <$>
, deriveSafeCopy 1 'base ''FileSource
, deriveSafeCopy 2 'base ''File
, TH.deriveLiftMany [''FileSource, ''File]
, deriveSerializeViaSafeCopy [t|FileSource|]
, deriveSerializeViaSafeCopy [t|File|] ])
])

-- |Return the remote URI if the file resulted from downloading a URI.
fileURI :: File -> Maybe URI
Expand Down
3 changes: 0 additions & 3 deletions Appraisal/FileError.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import qualified Data.ByteString as P
#endif
import Data.Data (Data)
import Data.SafeCopy (base, deriveSafeCopy)
import Extra.Serialize (Serialize)
import Data.Text (pack, Text, unpack)
import Extra.Except (HasIOException(fromIOException))
import Extra.Orphans ({-instance Serialize Text-})
Expand Down Expand Up @@ -92,7 +91,5 @@ $(deriveSafeCopy 1 'base ''FileError)

deriving instance Data FileError
deriving instance Data CommandInfo
deriving instance Serialize FileError
deriving instance Serialize CommandInfo
deriving instance Show FileError
deriving instance Show CommandInfo
16 changes: 0 additions & 16 deletions Appraisal/Image.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ import Data.Map (Map)
import Data.Monoid ((<>))
import Data.Ratio ((%), approxRational)
import Data.SafeCopy (base, deriveSafeCopy, SafeCopy(..), safeGet, safePut)
import Extra.Serialize (Serialize(..))
import Data.Text (Text)
import Data.Text.Encoding (decodeUtf8)
import Extra.Serialize (deriveSerializeViaSafeCopy)
import Language.Haskell.TH (Ppr(ppr))
import Language.Haskell.TH.Lift (deriveLiftMany)
import Language.Haskell.TH.PprLib (ptext)
Expand Down Expand Up @@ -501,10 +499,6 @@ parseExtractBBOutput = do
creationDate :: Parsec Text () ()
creationDate = string "%%CreationDate:" >> many (noneOf "\n") >> newline >> return ()

instance SafeCopy a => Serialize (SaneSize a) where
get = safeGet
put = safePut

$(concat <$>
sequence
[ makeLenses ''ImageFile
Expand All @@ -527,16 +521,6 @@ $(concat <$>
''Dimension,
''SaneSize
]

, deriveSerializeViaSafeCopy [t|ImageSize|]
, deriveSerializeViaSafeCopy [t|Dimension|]
, deriveSerializeViaSafeCopy [t|Units|]
, deriveSerializeViaSafeCopy [t|ImageCrop|]
-- , deriveSerializeViaSafeCopy [t|forall a. SaneSize a|]
, deriveSerializeViaSafeCopy [t|ImageFile|]
, deriveSerializeViaSafeCopy [t|ImageType|]
, deriveSerializeViaSafeCopy [t|ImageKey|]

, makeLenses ''ImageSize
, makeLenses ''SaneSize
])
Expand Down
2 changes: 1 addition & 1 deletion image-cache.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: image-cache
Version: 0.12
Version: 0.13
License: AllRightsReserved
Copyright: (c) 2014, SeeReason Partners LLC
Author: David Fox <[email protected]>
Expand Down

0 comments on commit 3614e9a

Please sign in to comment.