RE: Type of a HsExpr
Maybe you want tcRnExpr :: HscEnv - InteractiveContext - LHsExpr RdrName - IO (Messages, Maybe Type) from TcRnDriver? | -Original Message- | From: glasgow-haskell-users-boun...@haskell.org [mailto:glasgow-haskell-users- | boun...@haskell.org] On Behalf Of Sven Urbanski | Sent: 18 May 2011 18:14 | To: ghc-users | Subject: Type of a HsExpr | | Hi all, | | I'm having a problem similar to Ranjit in the mail parsing types. | | However, I want to get the type of an HsExpr: | | getType :: HsExpr - Type | | or something similar. | | This should basically do what :t does in ghci, but for any given | HsExpr (also it should not work on Strings). | | | Looking at the ghc sources, I found | | exprType :: CoreExpr - Type | | which is pretty close to what i need. | | | Another way of solving this, would be a function lik this: | | hsExpr2CoreExpr :: HsExpr - CoreExpr | | Than I could combine them like: | | exprType . hsExpr2CoreExpr | | | Any hints are very much appreciated, | | Sven | | ___ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
repa: fromVector
Hi, I'd like to use repa in a rather perverted mode, I guess: for my programs I need to be able to update arrays in place and repeatedly perform operations on them. Right now, it basically works like this (in ST): - create unboxed space using primitive (same as unboxed vectors) - unsafefreeze unboxed space - perform calculations on frozen, immutable space - write result into mutable space (which is shared with the unsafefrozen space) - In principle, this should work with repa as well, I think. The question is: does Repa.Internals.Base.fromVector any copying, or does it just use the unboxed vector as-is internally? should I expect any problems? ;-) Gruss, Christian pgp6KOMi3jSnI.pgp Description: PGP signature ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: repa: fromVector
It doesn't do any copying. On Thu, May 19, 2011 at 3:27 AM, Christian Höner zu Siederdissen choe...@tbi.univie.ac.at wrote: Hi, I'd like to use repa in a rather perverted mode, I guess: for my programs I need to be able to update arrays in place and repeatedly perform operations on them. Right now, it basically works like this (in ST): - create unboxed space using primitive (same as unboxed vectors) - unsafefreeze unboxed space - perform calculations on frozen, immutable space - write result into mutable space (which is shared with the unsafefrozen space) - In principle, this should work with repa as well, I think. The question is: does Repa.Internals.Base.fromVector any copying, or does it just use the unboxed vector as-is internally? should I expect any problems? ;-) Gruss, Christian ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: repa: fromVector
On 19/05/2011, at 8:27 PM, Christian Höner zu Siederdissen wrote: I'd like to use repa in a rather perverted mode, I guess: for my programs I need to be able to update arrays in place and repeatedly perform operations on them. Right now, it basically works like this (in ST): - create unboxed space using primitive (same as unboxed vectors) - unsafefreeze unboxed space - perform calculations on frozen, immutable space - write result into mutable space (which is shared with the unsafefrozen space) If you care deeply about inplace update, then you could use the parallel array filling functions directly. The ones in D.A.Repa.Internals.Eval*.hs. For 2D images, use the fillVectorBlockwiseP [1] or fillCursoredBlock2P. fillVectorBlockwiseP :: Elt a = IOVector a -- ^ vector to write elements into - (Int - a) -- ^ fn to evaluate an element at the given index - Int -- ^ width of image. - IO () -- | Fill a block in a 2D image, in parallel. -- Coordinates given are of the filled edges of the block. -- We divide the block into columns, and give one column to each thread. fillCursoredBlock2P :: Elt a = IOVector a -- ^ vector to write elements into - (DIM2 - cursor) -- ^ make a cursor to a particular element - (DIM2 - cursor - cursor) -- ^ shift the cursor by an offset - (cursor - a)-- ^ fn to evaluate an element at the given index. - Int -- ^ width of whole image - Int -- ^ x0 lower left corner of block to fill - Int -- ^ y0 (low x and y value) - Int -- ^ x1 upper right corner of block to fill - Int -- ^ y1 (high x and y value, index of last elem to fill) - IO () Actually, it might be worthwhile exporting these in the API anyway. [1] http://code.ouroborus.net/repa/repa-head/repa/Data/Array/Repa/Internals/EvalBlockwise.hs [2] http://code.ouroborus.net/repa/repa-head/repa/Data/Array/Repa/Internals/EvalCursored.hs ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users