Implement a Pure Functional Payment Event Pipeline

Problem

Juspay uses functional programming (Haskell/PureScript) extensively. Implement a pure functional pipeline that processes a stream of payment events.

Task

Given a list of payment events:

type Event = { txnId: String, amount: Float, status: String, gateway: String }

Implement the following without mutation or side effects:

  1. filterSuccessful — keep only status == "SUCCESS" events
  2. aggregateByGateway — sum amounts per gateway
  3. topGateways(n) — return top-n gateways by total volume
  4. Compose all three as a single pipeline

What Juspay evaluates

  • Use of map, filter, fold/reduce (no imperative loops)
  • Function composition
  • Immutable data transformations
  • Type safety and null handling

Bonus

Write this in Haskell, PureScript, or Scala using functional idioms.

added …
LeaderboardSalaryAccount