Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

OCaml Module 11

Advanced types interview questions

2 interview questions on advanced types from OCaml: short warm-ups, then what each harder question tests, the first step of a good answer and its follow-ups.

2 questions: 1 warm-up and 1 with a model answer · Levels: Fresher to senior

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    What is a GADT, and how does it differ from a plain variant?

    Answered in the lesson Generalised algebraic data types (GADTs)

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Mid to senior

    You are modelling a filter clause with And, Or, Not and primitives such as Equals and Contains. Every primitive takes string arguments and every clause evaluates to a bool. A teammate wants a GADT; another argues for a plain variant. How would you decide?

    What it tests
    Picking the shape by what the compiler would refine with the index, rather than by habit; weighing the extra text and messages against the compile-time guarantees.
    First step
    List what the GADT index would carry here: with every primitive taking a string and every clause evaluating to bool, the index would be bool for every constructor. The GADT would then rule out no case the plain variant would allow, so the extra apparatus pays for nothing.
    Follow-ups

    From the lesson Generalised algebraic data types (GADTs)

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 5 minutes

All OCaml interview questions · The OCaml track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.