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:
filterSuccessful— keep onlystatus == "SUCCESS"eventsaggregateByGateway— sum amounts per gatewaytopGateways(n)— return top-n gateways by total volume- 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 …