-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{-# LANGUAGE BlockArguments, GeneralizedNewtypeDeriving, TypeFamilies #-} | ||
|
||
-- | Take the | ||
module Shake.Digest (digestRules, getFileDigest) where | ||
|
||
import qualified Data.ByteString.Lazy as LazyBS | ||
import Data.Digest.Pure.SHA | ||
import Data.Typeable | ||
|
||
import Development.Shake.Classes (Hashable, Binary, NFData) | ||
import Development.Shake | ||
|
||
newtype FileDigest = FileDigest FilePath | ||
deriving (Show, Typeable, Eq, Hashable, Binary, NFData) | ||
|
||
type instance RuleResult FileDigest = String | ||
|
||
-- | Shake rules required for compiling KaTeX equations. | ||
digestRules :: Rules () | ||
digestRules = versioned 1 do | ||
_ <- addOracle \(FileDigest f) -> do | ||
need [f] | ||
take 8 . showDigest . sha256 <$> liftIO (LazyBS.readFile f) | ||
pure () | ||
|
||
-- | Get parsed preamble | ||
getFileDigest :: FilePath -> Action String | ||
getFileDigest = askOracle . FileDigest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters