Frequently asked questions and answers of Idris in Programming Technologies of Computer Science to enhance your skills, knowledge on the selected topic. We have compiled the best Idris Interview question and answer, trivia quiz, mcq questions, viva question, quizzes to prepare. Download Idris FAQs in PDF form online for academic course, jobs preparations and for certification exams .
Intervew Quizz is an online portal with frequently asked interview, viva and trivia questions and answers on various subjects, topics of kids, school, engineering students, medical aspirants, business management academics and software professionals.
Question-1. What is Idris?
Answer-1: Idris is a functional programming language with dependent types, similar to Agda and Haskell.
Question-2. What are dependent types in Idris?
Answer-2: Dependent types allow types to be defined based on values, enabling strong compile-time verification.
Question-3. What is the file extension for Idris source files?
Answer-3: .idr
Question-4. How do you define a function in Idris?
Answer-4: f : Type; f = expression, e.g., add : Int -> Int -> Int; add x y = x + y.
Question-5. What is totality checking in Idris?
Answer-5: It ensures functions are well-defined and terminate for all inputs.
Question-6. What is an inductive data type in Idris?
Answer-6: A type defined by constructors, e.g., `data Nat = Z
Question-7. What is the purpose of data in Idris?
Answer-7: It defines algebraic data types, e.g., `data Bool = True
Question-8. How do you pattern match in Idris?
Answer-8: Using case expressions, e.g., not : Bool -> Bool; not True = False; not False = True.
Question-9. What is Set in Idris?
Answer-9: Set represents the universe of types, similar to Agda's Set.
Question-10. How do you define a dependent pair in Idris?
Answer-10: Using (x : A ** B x), which is similar to Sigma types.
Question-11. How does Idris ensure correctness of programs?
Answer-11: By using dependent types to encode constraints in types.
Question-12. How do you define a record in Idris?
Answer-12: Using record Name where field fieldName : Type.
Question-13. What is interface in Idris?
Answer-13: It defines type classes, e.g., interface Eq a where (==) : a -> a -> Bool.
Question-14. What are implicit arguments in Idris?
Answer-14: Arguments enclosed in curly braces {} that are inferred automatically.
Question-15. What is a theorem in Idris?
Answer-15: A function that proves a property using dependent types.
Question-16. How do you define an indexed data type in Idris?
Answer-16: Using type parameters, e.g., `data Vec : Type -> Nat -> Type where Nil : Vec a Z
Question-17. What is an equality type in Idris?
Answer-17: x === y represents equality proofs.
Question-18. How do you prove equality in Idris?
Answer-18: Using Refl : x === x.
Question-19. What is auto in Idris?
Answer-19: A keyword that allows automatic solving of constraints.
Question-20. How do you handle interactive proofs in Idris?
Answer-20: Using the Idris REPL and interactive proof tactics.
Question-21. What is believe_me in Idris?
Answer-21: It is an unsafe escape hatch for type-checking, bypassing type safety.
Question-22. How does Idris handle side effects?
Answer-22: Using monads, such as IO for input/output operations.
Question-23. What is a pi type in Idris?
Answer-23: A dependent function type, written as (x : A) -> B x.
Question-24. How do you define an infinite data structure in Idris?
Answer-24: Using coinductive types or laziness with Stream.
Question-25. What is do notation in Idris?
Answer-25: A syntax for sequencing monadic computations, similar to Haskell.
Question-26. How do you define a polymorphic function in Idris?
Answer-26: Using type variables, e.g., id : a -> a; id x = x.
Question-27. What is a where clause in Idris?
Answer-27: It defines local helper functions, e.g., f x = y where y = x + 1.
Question-28. How do you define a higher-order function in Idris?
Answer-28: By passing functions as arguments, e.g., map : (a -> b) -> List a -> List b.
Question-29. What is Total in Idris?
Answer-29: It enforces that functions terminate and cover all cases.
Question-30. What is partial in Idris?
Answer-30: It allows defining non-total functions without termination proof.
Question-31. How do you work with lists in Idris?
Answer-31: Using `data List a = Nil
Question-32. What is Dec in Idris?
Answer-32: A type for decidable propositions, allowing proof checking.
Question-33. How do you define a monad in Idris?
Answer-33: Using interface Monad m where (>>=) : m a -> (a -> m b) -> m b.
Question-34. What is cong in Idris?
Answer-34: A function that applies equality proofs to functions.
Question-35. What is rewrite in Idris?
Answer-35: It is used in proofs to substitute equal terms.
Question-36. What is induction in Idris?
Answer-36: A proof technique using recursive pattern matching on data types.
Question-37. How do you enable dependent type checking in Idris?
Answer-37: It is enabled by default as part of the language.
Question-38. What is void in Idris?
Answer-38: A type that has no values, used to indicate impossible cases.
Question-39. How do you define a functor in Idris?
Answer-39: Using interface Functor f where map : (a -> b) -> f a -> f b.
Question-40. Can Idris compile to executable programs?
Answer-40: Yes, Idris can compile to C, JavaScript, and other backends.
Question-41. What is intros in Idris proof mode?
Answer-41: It introduces variables into a proof context.
Question-42. How do you define a custom operator in Idris?
Answer-42: Using (operator) : Type; (operator) x y = expression.
Question-43. What is hole in Idris?
Answer-43: A placeholder (?name) used to generate type suggestions in the REPL.
Question-44. How do you optimize Idris programs?
Answer-44: Using total functions, avoiding excessive dependent types, and enabling optimizations.
Question-45. What are homotopy types in Idris?
Answer-45: Higher-dimensional types used in homotopy type theory (HoTT).
Question-46. How do you prove a property about lists in Idris?
Answer-46: Using induction on list structure.
Question-47. What is a Nat in Idris?
Answer-47: A type representing natural numbers, defined as `data Nat = Z
Question-48. How do you install Idris?
Answer-48: Using apt-get install idris (Linux) or brew install idris (Mac).
Question-49. How do you run an Idris program?
Answer-49: Using idris filename.idr -o output && ./output.
Question-50. Where can you learn more about Idris?
Answer-50: The official site: https://www.idris-lang.org.
Frequently Asked Question and Answer on Idris
Idris Interview Questions and Answers in PDF form Online
Idris Questions with Answers
Idris Trivia MCQ Quiz