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).
Reverse vector iteration: for [n - 1, n - 2 .. 0] vs foldr'
Folding sequence: vector (VU.foldM'_ f s (VU.generate n id)) vs list (foldM_ f s [0 .. n - 1])
Newer style
return
withpure
fmap
with<$>
Associated modulus values
GHC.TypeLits
vsGHC.TypeNats
Prefer the latter, which requires less type conversion from
Nat
.KnownNat
vsAllowAmbiguousTypes
vsTagged
Prefer
KnownNat
for 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.corece
vs newtype constructorsPrefer newtype constructors that helps us with typing. There's no performance difference (probably).
for [n - 1, n - 2 .. 0]
vsfoldr'
VU.foldM'_ f s (VU.generate n id)
) vs list (foldM_ f s [0 .. n - 1]
)The text was updated successfully, but these errors were encountered: