You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GHC.TypeLits vs GHC.TypeNats
Prefer the latter, which requires less type conversion from Nat.
KnownNat vs AllowAmbiguousTypes vs Tagged
Prefer KnownNat for simplicity.
Performance
Index iteration: VU.forM_ (VU.generate n id) vs forM_ [0 .. n - 1]
Latter was a bit faster on AtCoder, even beter than to Bundle, although there's slow for_ warnings.
corece vs newtype constructors
Prefer newtype constructors that helps us with typing. There's no performance difference (probably).n
Side effect-only mutable vector iteration: for_ [0 .. n - 1] vs VGM.forM_
Reverse vector iteration: for [n - 1, n - 2 .. 0] vs VGM.foldr' vs VU.streamR
[-] Slice of vector should be in the same scope, or else too slow not sure
Folding sequence: vector (VU.foldM'_ f s (VU.generate n id)) vs list (foldM_ f s [0 .. n - 1])
Newer style
returnwithpurefmapwith<$>Associated modulus values
GHC.TypeLitsvsGHC.TypeNatsPrefer the latter, which requires less type conversion from
Nat.KnownNatvsAllowAmbiguousTypesvsTaggedPrefer
KnownNatfor simplicity.Performance
VU.forM_ (VU.generate n id)vsforM_ [0 .. n - 1]Latter was a bit faster on AtCoder, even beter than to
Bundle, although there'sslow for_warnings.corecevs newtype constructorsPrefer newtype constructors that helps us with typing. There's no performance difference (probably).n
for_ [0 .. n - 1]vsVGM.forM_for [n - 1, n - 2 .. 0]vsVGM.foldr'vsVU.streamRSlice of vector should be in the same scope, or else too slownot sureVU.foldM'_ f s (VU.generate n id)) vs list (foldM_ f s [0 .. n - 1])