I have been working in a project that has been using lists to calculate artificial neural network operations. Now, I would like to transform that to Data.Vector
to improve its efficiency. However, I have been having a trouble at the moment to implement Foreign.Storable
for a definition that is essential.
Ok, so first, I have used Data.Array.Repa
for the calculations, with a type synonym like the following (CAMTypes.hs
):
type NTTVU = Array U VShape NTT
Then later I wanted to use Data.Vector
as follows:
import qualified Data.Vector.Storable as VS
-- ...
trs = createThreshold 3 0 [9,8,7] :: NTTVU
However, I get the following error:
$> VS.singleton trs
*** Exception: Prelude.undefined
CallStack (from HasCallStack):
error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
undefined, called at ./Data/Vector/Storable/Mutable.hs:131:22 in vector-0.12.0.1-JlawpRjIcMJIYPJVsWriIA:Data.Vector.Storable.Mutable
CallStack (from -prof):
Data.Vector.Storable.Mutable.basicUnsafeNew.size (Data/Vector/Storable/Mutable.hs:131:7-36)
Data.Vector.Storable.Mutable.basicUnsafeNew (Data/Vector/Storable/Mutable.hs:(124,3)-(132,38))
Data.Vector.Storable.Mutable.CAF:lvl12_r7YZK (<no location info>)
I have already done the implementation for instance Storable NTTVU where
, but still complains; I enabled profiling, but does not tell me more about it; tried debugging by steps but no success as well. Hopefully someone knows a lot about it and how to solve it.
For more context, the whole project, and the related files: