Haskell syntax, type classes, Maybe and Either, list functions, laziness, pattern matching and the IO monad.
34 cards · basic cards · AI-written, checked twice. Edit anything.
- What is the basic syntax for defining a function in Haskell?
Show answer
functionName param1 param2 = expression
- What does the :: symbol denote in Haskell?
Show answer
A type annotation or type signature
- What is a type class in Haskell?
Show answer
A collection of types that share common behaviors or properties
- How do you declare that a type is an instance of a type class?
Show answer
Using instance keyword: instance ClassName TypeName where ...
- What is the Maybe type used to represent?
Show answer
An optional value that either exists (Just value) or does not (Nothing)
- What are the two constructors for the Maybe type?
Show answer
Just and Nothing
- What is the Either type used to represent?
Show answer
A value that can be one of two types, commonly used for error handling
- What are the two constructors for the Either type?
Show answer
Left and Right
- What does the map function do to a list?
Show answer
Applies a function to each element of the list and returns a new list
- What does the filter function do?
Show answer
Keeps only the elements of a list that satisfy a predicate condition
- What does foldr do to a list?
Show answer
Combines all elements of a list from right to left using a function
- What is pattern matching in Haskell?
Show answer
Breaking down a value into its components by matching against patterns
- What does the case expression do?
Show answer
Allows pattern matching against different values within an expression
- What is a guard in Haskell?
Show answer
A boolean condition after | that determines whether an equation applies
- What does lazy evaluation mean?
Show answer
Expressions are only evaluated when their results are actually needed