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.
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 operation associated with a type, class, or object that defines behavior and can be invoked through that association.
- hash mapused by · A hash map is a data structure that stores key-value pairs and uses keys to retrieve associated values.
- Mapused by · A map is an associative data structure that stores key-value pairs and supports retrieving values by key.
- type classkind of · A type class is an interface that defines operations and constraints for types, enabling ad hoc polymorphism.
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.

