Skip to content

Commit

Permalink
Support base64-1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjaguarpaw committed Feb 5, 2024
1 parent cef96be commit 90e8ed7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/Stan/Observation.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE CPP #-}

{- |
Copyright: (c) 2020 Kowainik
SPDX-License-Identifier: MPL-2.0
Expand Down Expand Up @@ -40,6 +42,9 @@ import Stan.Report.Settings (OutputSettings (..), Verbosity (..), isHidden)
import Stan.Severity (prettyShowSeverity, severityColour)

import qualified Crypto.Hash.SHA1 as SHA1
#if MIN_VERSION_base64(1,0,0)
import qualified Data.Base64.Types
#endif
import qualified Data.ByteString.Base64 as Base64
import qualified Data.ByteString.Char8 as BS
import qualified Data.HashSet as HS
Expand Down Expand Up @@ -269,6 +274,14 @@ mkObservationId insId moduleName srcSpan = Id $ Text.intercalate "-"
, show (srcSpanStartLine srcSpan) <> ":" <> show (srcSpanStartCol srcSpan)
]

#if MIN_VERSION_base64(1,0,0)
extractBase64 :: Data.Base64.Types.Base64 k a -> a
extractBase64 = Data.Base64.Types.extractBase64
#else
extractBase64 :: a -> a
extractBase64 = id
#endif

{- | Hash module name to a short string of length @6@. Hashing
algorithm is the following:
Expand All @@ -279,6 +292,7 @@ algorithm is the following:
hashModuleName :: ModuleName -> Text
hashModuleName =
Text.take 6
. extractBase64
. Base64.encodeBase64
. SHA1.hash
. encodeUtf8
Expand Down
2 changes: 1 addition & 1 deletion stan.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ library
Stan.Hie.Debug908

build-depends: array ^>= 0.5
, base64 ^>= 0.4.1
, base64 >= 0.4.1 && < 2.1
, blaze-html ^>= 0.9.1
, bytestring >= 0.10 && < 0.13
, clay >= 0.14 && < 0.16
Expand Down

0 comments on commit 90e8ed7

Please sign in to comment.