Replies: 10 comments 16 replies
-
This seems safe: withVector :: (V.Vector a -> r) -> LV.Vector a %1 -> (r , LV.Vector a)
withVector f = Unsafe.Linear.toLinear \v -> (,v) $! f (L.unur (LV.freeze v)) I also suggest renaming Vector to Stack, it's a less overloaded and unambiguous |
Beta Was this translation helpful? Give feedback.
-
Shouldn't size ideally be 0-multiplicity on the vector? Edit: Probably nonsense, but typing Get at 0-multiplicity could be convenient, although unsafe if laziness allows keeping stale references around |
Beta Was this translation helpful? Give feedback.
-
Is it just not possible to use let to bind linear names? |
Beta Was this translation helpful? Give feedback.
-
Some more experiments In order to get a State containing linear vectors going It seems mandatory (?) to define lens with a passthrough v = LLens.lens \(IEnv p t i l f c) -> (p , \(r,x) -> (r , IEnv x t i l f c))
v' = LLens.lens \(IEnv p t i l f c) -> (p , \x -> IEnv x t i l f c)
-- Now normal stateful lenses can be defined and can call Linear.Vector.size
l %%= f = state (LLens.over l f)
eg = (v %%= LV.size) >>= \(L.Ur sz) -> .. Am I missing anything? |
Beta Was this translation helpful? Give feedback.
-
Welcome! I took the liberty to convert this into a discussion because there's too much going on for an issue. |
Beta Was this translation helpful? Give feedback.
-
Why does freeze return a Ur ? That seems redundant to me since no API's care about duplicating standard vectors |
Beta Was this translation helpful? Give feedback.
-
data Next a seed = End seed | Skip seed | Next (L.Ur a) seed
unfoldSeed :: (seed %1 -> Next a seed) -> seed %1 -> (V.Vector a , seed)
unfoldSeed fn s0 = let
go (stack , step) = case fn step of
Next (L.Ur v) seedN -> Right (LV.push v stack , seedN)
Skip s -> Right (stack , s)
End s -> Left ((,s) <$> LV.freeze stack)
in L.unur $ LV.empty \v0 -> tailRecurse1 go (v0 , s0) This is already decent, but I want %p on the existential Our favorite Ur hack doesn't work here as something is lost (probably ghc incompetence with this firstclass polymorphism on the multiplicity) I think I want |
Beta Was this translation helpful? Give feedback.
-
Remarkable oversight • No instance for ‘Prelude.Monad (StateT IEnv Prelude.Identity)’
arising from a do statement
There are instances for similar types:
instance [safe] Prelude.Monad m =>
Prelude.Monad (Prelude.StateT s m) |
Beta Was this translation helpful? Give feedback.
-
Are Type applications supposed to work?
|
Beta Was this translation helpful? Give feedback.
-
This is rough:
The design with Ur is fundamentally imprecise, We want "The input linear variable dies here", not "all linearity dies here" |
Beta Was this translation helpful? Give feedback.
-
Here is the use-case:
Is there a natural way of doing this? In particular it seems difficult to ensure functions using the duplicated frozen vector terminate before proceeding
Beta Was this translation helpful? Give feedback.
All reactions