Skip to content

Misc coding styles and niche optimizations #32

@toyboot4e

Description

@toyboot4e

Newer style

  • Replace return with pure
  • Replace fmap with <$>

Associated modulus values

  • 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])
  • Vector initialization: replicate + copy, unsafeNew + copy + manual filling vs grow -> manual filling

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions