Search code examples
haskellaccelerate-haskell

Exp a -> a in Haskell Accelerate


Is there a function with such type signature: Exp a -> a in accelerate library for Haskell?

For example, I have an expression:

max = maximum mat !! 0

where mat :: Acc (Matrix Int)

Then, max has type Exp Int, but I'd like max to be expressed a simple haskell's Int.


Solution

  • You will first need to convert the Exp into an Acc, then run that, and finally index the resulting array:

    indexArray (run (unit max)) Z
    

    Perhaps it is easier then to use the maximum array directly:

    indexArray (run (maximum mat)) (0 :. Z)