-- |
-- Module      : Data.Array.Accelerate.Analysis.Hash.TH
-- Copyright   : [2017..2020] The Accelerate Team
-- License     : BSD3
--
-- Maintainer  : Trevor L. McDonell <trevor.mcdonell@gmail.com>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)
--

module Data.Array.Accelerate.Analysis.Hash.TH (

  hashQ,
  hashWithSaltQ,

) where

import Data.Hashable
import Language.Haskell.TH


hashQ :: Hashable a => a -> ExpQ
hashQ :: a -> ExpQ
hashQ = Int -> ExpQ
intE (Int -> ExpQ) -> (a -> Int) -> a -> ExpQ
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Int
forall a. Hashable a => a -> Int
hash

hashWithSaltQ :: Hashable a => Int -> a -> ExpQ
hashWithSaltQ :: Int -> a -> ExpQ
hashWithSaltQ Int
s a
x = Int -> ExpQ
intE (Int -> a -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
s a
x)

intE :: Int -> ExpQ
intE :: Int -> ExpQ
intE = Lit -> ExpQ
litE (Lit -> ExpQ) -> (Int -> Lit) -> Int -> ExpQ
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Lit
integerL (Integer -> Lit) -> (Int -> Integer) -> Int -> Lit
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral