Skip to content

numtype-tf add reify/reflection function #41

@GoogleCodeExporter

Description

@GoogleCodeExporter
I want a function like:

import qualified Numeric.NumType.TF as N
import qualified Prelude as P

reifyNT :: Int -> (forall a. N.NumTypeI a => a -> r) -> r
reifyNT n f
    | n > 0 = reifyNT (n P.- 1) (f . N.incr)
    | n < 0 = reifyNT (P.negate n) (f . N.negate)
    | otherwise = f N.zero

Such that reifyNT n N.toNum == n. This doesn't work now because:

a. NumTypeI is not exported
b. ghc has no evidence for N.NumTypeI (N.Succ a) given N.NumTypeI a. I can't 
figure out superclass constraints that can make that happen.

The purpose of this is to be able to implement functions like:

cmap :: (ScaleCxt deltaE ri ri')
    => proxy deltaE
    -> (forall l m t i th n j e. 
        (N.NumType l, N.NumType m, N.NumType t, N.NumType i,
         N.NumType n, N.NumType j,
         e ~ Dim l m t i th n j) =>
           Quantity e a -> Quantity (Mul e deltaE) b)
    -> DimMat ri ci a -> DimMat ri' ci b
-- which does the same as cmap in hmatrix, but with matrices that have units

Original issue reported on code.google.com by vogt.a...@gmail.com on 23 Jan 2014 at 9:35

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions