InterviewStack.io LogoInterviewStack.io

Functional Programming Questions

Functional-style programming: pure functions, immutability, higher-order functions, closures, currying and partial application, and memoization, along with functional reactive patterns. Covers reasoning about code as composed transformations rather than mutable state, whether in a dedicated functional language or a multi-paradigm one. Increasingly probed for frontend and data-heavy work.

MediumTechnical
144 practiced

During a code review you find a module that uses unsafePerformIO to cache a value and several partial functions like fromJust. Explain the risks associated with such code and propose concrete refactorings to make it safer and more maintainable, including how you'd test the refactor.

MediumTechnical
88 practiced

Design a Serializable typeclass in Haskell with functions serialize :: a -> ByteString and deserialize :: ByteString -> Either String a. Provide instances for Int and Maybe a (given Serializable a). Discuss how you would handle versioning and backwards compatibility at the typeclass level.

HardTechnical
88 practiced

You're given a legacy codebase where most business logic is embedded inside IO actions. Propose an architecture to move to a pure core that separates effects from logic (e.g., using a tagless-final interpreter or free monads). Describe the migration steps, how to incrementally extract pure functions, and how to handle testing and backward compatibility.

MediumTechnical
89 practiced

Build a small parser for simple arithmetic expressions containing integers, + and *, and parentheses using Parsec or Megaparsec. Provide parser code for expr, term, and factor and show how to parse and evaluate the expression into an Int result. Mention operator precedence handling.

HardTechnical
99 practiced

Explain the free monad and the tagless-final (aka finally tagless) encoding for building embedded DSLs in Haskell. Discuss trade-offs in terms of ease of defining interpreters, performance, type safety, and testability. Sketch a small DSL for logging with both approaches.

Unlock Full Question Bank

Get access to all 40 Functional Programming interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.