Eq
Eq is a type-level interface or trait that specifies or provides equality comparison for values of a type.
Type-Driven Development with Idris
An Idris interface whose methods specify equality and inequality comparisons for a type.
- How it is used
- Constrains generic functions to types that support equality and inequality comparisons.
- How deep it goes
- Works through a missing-implementation error, a constrained function, and a custom interface implementation.
- Examples
- Uses list occurrence counting, a Matter implementation, and an exercise comparing Shape values.
- What you can do after
- Apply Eq in Idris to constrain generic functions and implement comparisons for custom types.
Learn Haskell by Example
Eq is a Haskell type class defining equality and inequality operations for values that can be compared.
- How it is used
- Uses equality constraints to implement membership checks and graph operations over arbitrary comparable values.
- How deep it goes
- Defines both methods, instance requirements, type restrictions, and constrained container instances, but does not detail equality algorithms.
- Examples
- Demonstrates GHCi inspection, associative-list membership, graph node lookup, and Eq instances for primitive and container types.
- What you can do after
- Apply it via Eq constraints to write functions that compare values and search associative lists or graph structures.
Also covered in
What to know first
- genericsGenerics are programming-language constructs parameterized by types, allowing definitions to apply to multiple concrete types while preserving type relationships.
Related concepts
- Idris interfacekind of · An Idris interface specifies generic operations that can have implementations for different types.
- interface implementationimplemented by · An interface implementation provides definitions for the methods of an interface for a particular type or context.
- methodhas part · A method is a callable function or operation associated with a type, class, or object and invoked through that association.
- hash mapused by · A hash map is a data structure that stores key-value associations and uses a hash function to support lookup by key.
- Mapused by · A map is an associative data structure that stores key-value associations and supports retrieving values by key.
- type classkind of · A type class defines a set of operations that types can support, enabling a common interface and ad hoc polymorphism.
Questions about Eq
What is Eq?
Eq is a type-level interface or trait that specifies or provides equality comparison for values of a type.
Which Manning books explain Eq?
Type-Driven Development with Idris and Learn Haskell by Example.
What should I know before learning Eq?
Manning books that teach Eq usually introduce generics first.
What is Eq a kind of?
Eq is a kind of Idris interface. An Idris interface specifies generic operations that can have implementations for different types.
What are the parts of Eq?
Eq includes method.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

