Skip to content

Commit

Permalink
The unsafeShiftL function wasn't available before 7.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorycollins committed Sep 11, 2012
1 parent e9db828 commit 5008bfe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Snap/Internal/Parsing.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE OverloadedStrings #-}

Expand Down Expand Up @@ -467,7 +468,13 @@ strictize = S.concat . L.toChunks
unsafeFromHex :: (Enum a, Bits a) => ByteString -> a
unsafeFromHex = S.foldl' f 0
where
f !cnt !i = unsafeShiftL cnt 4 .|. nybble i
#if MIN_VERSION_base(4,5,0)
sl = unsafeShiftL
#else
sl = shiftL
#endif

f !cnt !i = sl cnt 4 .|. nybble i

nybble c | c >= '0' && c <= '9' = toEnum $! fromEnum c - fromEnum '0'
| c >= 'a' && c <= 'f' = toEnum $! 10 + fromEnum c - fromEnum 'a'
Expand Down

0 comments on commit 5008bfe

Please sign in to comment.