{"id":{"repo_id":"chalmers","oai_identifier":"oai:odr.chalmers.se:20.500.12380/302035"},"canonical_url":"https://search.ndltd.org/etd/chalmers/oai:odr.chalmers.se:20.500.12380/302035","repository":{"repo_id":"chalmers","name":"Chalmers University of Technology","base_url":"https://odr.chalmers.se/oai/request"},"display":{"title":"Deriving Via Type-directed instances","abstract":"Type classes are at the heart of Haskell and constitute a language of type-directed behaviour. The programmer defines behaviour for each type by defining a class instance where the compiler transparently fills in the blanks with code. Types guide this process. Each type has a single instance: what if there is more than one way to act? The established approach is to wrap such a type in a newtype, ensuring it has the same memory representation. newtypes require require laborious manual wrapping and unwrapping which have no effect at runtime. Haskell’s deriving construct allows easily generating instances that follow a common pattern by simply listing the classes you want derived. At present, GHC only supports deriving a few classes. The only alternative is to write it by hand. This thesis offers an alternative: the language extension -XDerivingVia (appeared in GHC 8.6 ) and the GHCi command :instances (appeared in GHC 8.10 ) which lists instances of types. The Deriving Via introduces a new deriving strategy via which allows deriving classes from one or more ‘via types’. These types must be identical (at runtime) to the type we are deriving for. We instantiate behaviour at a via type and then coerce it to our type. The :instances command lists candidates that can be derived via a given type. That enables programmers to compose instances from named programming patterns, thereby turning deriving into a high-level domain-specific language for defining instances. Deriving Via leverages newtypes—an already familiar tool of the Haskell trade—to declare recurring patterns in a way that both feels natural and allows a high degree of abstraction.","abstract_html":"Type classes are at the heart of Haskell and constitute a language of type-directed behaviour. The programmer defines behaviour for each type by defining a class instance where the compiler transparently fills in the blanks with code. Types guide this process. Each type has a single instance: what if there is more than one way to act? The established approach is to wrap such a type in a newtype, ensuring it has the same memory representation. newtypes require require laborious manual wrapping and unwrapping which have no effect at runtime. Haskell’s deriving construct allows easily generating instances that follow a common pattern by simply listing the classes you want derived. At present, GHC only supports deriving a few classes. The only alternative is to write it by hand. This thesis offers an alternative: the language extension -XDerivingVia (appeared in GHC 8.6 ) and the GHCi command :instances (appeared in GHC 8.10 ) which lists instances of types. The Deriving Via introduces a new deriving strategy via which allows deriving classes from one or more ‘via types’. These types must be identical (at runtime) to the type we are deriving for. We instantiate behaviour at a via type and then coerce it to our type. The :instances command lists candidates that can be derived via a given type. That enables programmers to compose instances from named programming patterns, thereby turning deriving into a high-level domain-specific language for defining instances. Deriving Via leverages newtypes—an already familiar tool of the Haskell trade—to declare recurring patterns in a way that both feels natural and allows a high degree of abstraction.","abstract_has_math":false,"creators":["Blöndal, Baldur"],"institution":null,"degree_name":null,"degree_level":"H","degree_discipline":null,"degree_department":"Chalmers tekniska högskola / Institutionen för data och informationsteknik","school":null,"contributors":[],"advisors":["Sheeran, Mary"],"committee_chairs":[],"committee_members":["Sheeran, Mary"],"year":2020,"date_issued":"2020","date_published":"2020","updated_at":"2026-11-19T03:01:43Z","subjects":["Thesis","deriving","Haskell","program synthesis","type classes","safe coercions"],"languages":["eng"],"rights":[],"rights_urls":[],"identifier_entries":[{"key":"dc:identifier.coursecode","label":"Dc Identifier Coursecode","values":["MPALG"],"render_values":[{"text":"MPALG","href":null,"code":true}]}],"person_identifier_entries":[]},"links":{"outbound_url":"https://hdl.handle.net/20.500.12380/302035","outbound_label":"Handle","outbound_source":"dc:identifier.uri","record_url":"https://hdl.handle.net/20.500.12380/302035","record_label":"Repository record","record_kind":"handle","record_source":"dc:identifier.uri","access_status":null,"embargo_until":null,"access_note":null},"oai_pmh_record":{"url":"https://union.ndltd.org/oai-pmh/?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai%3Aunion.ndltd.org%3Arepo%3Achalmers%3Aoai%3Aodr.chalmers.se%3A20.500.12380%2F302035","prefix":"oai_dc"},"source_record":{"url":"https://odr.chalmers.se/oai/request?verb=GetRecord&metadataPrefix=dim&identifier=oai%3Aodr.chalmers.se%3A20.500.12380%2F302035","prefix":"dim"},"metadata_groups":[{"id":"people","label":"People","entries":[{"key":"dc:contributor.committeemember","label":"Committee Member","values":["Sheeran, Mary"]},{"key":"dc:contributor.department","label":"Department","values":["Chalmers tekniska högskola / Institutionen för data och informationsteknik"]},{"key":"dc:contributor.supervisor","label":"Supervisor","values":["Sheeran, Mary"]},{"key":"dc:creator","label":"Author","values":["Blöndal, Baldur"]}]},{"id":"academic_context","label":"Academic Context","entries":[{"key":"dc:date.accessioned","label":"Dc Date Accessioned","values":["2020-11-03T13:15:40Z"]},{"key":"dc:date.available","label":"Dc Date Available","values":["2020-11-03T13:15:40Z"]},{"key":"dc:date.issued","label":"Date","values":["2020"]},{"key":"dc:date.submitted","label":"Dc Date Submitted","values":["2020"]},{"key":"dc:publisher.program","label":"Dc Publisher Program","values":["Computer science – algorithms, languages and logic (MPALG), MSc"]},{"key":"dc:type.degree","label":"Dc Type Degree","values":["Examensarbete för masterexamen"]},{"key":"thesis:degree_level","label":"Degree Level","values":["H"]}]},{"id":"subjects_keywords","label":"Subjects and Keywords","entries":[{"key":"dc:subject","label":"Dc Subject","values":["Thesis","deriving","Haskell","program synthesis","type classes","safe coercions"]},{"key":"dc:subject.uppsok","label":"Dc Subject Uppsok","values":["Technology"]}]},{"id":"language_rights","label":"Language and Rights","entries":[{"key":"dc:language.iso","label":"Language (ISO)","values":["eng"]}]},{"id":"identifiers","label":"Identifiers","entries":[{"key":"dc:identifier.coursecode","label":"Dc Identifier Coursecode","values":["MPALG"]},{"key":"dc:identifier.uri","label":"Identifier URI","values":["https://hdl.handle.net/20.500.12380/302035"]}]},{"id":"additional","label":"Additional Metadata","entries":[{"key":"dc:description.abstract","label":"Abstract","values":["Type classes are at the heart of Haskell and constitute a language of type-directed behaviour. The programmer defines behaviour for each type by defining a class instance where the compiler transparently fills in the blanks with code. Types guide this process. Each type has a single instance: what if there is more than one way to act? The established approach is to wrap such a type in a newtype, ensuring it has the same memory representation. newtypes require require laborious manual wrapping and unwrapping which have no effect at runtime. Haskell’s deriving construct allows easily generating instances that follow a common pattern by simply listing the classes you want derived. At present, GHC only supports deriving a few classes. The only alternative is to write it by hand. This thesis offers an alternative: the language extension -XDerivingVia (appeared in GHC 8.6 ) and the GHCi command :instances (appeared in GHC 8.10 ) which lists instances of types. The Deriving Via introduces a new deriving strategy via which allows deriving classes from one or more ‘via types’. These types must be identical (at runtime) to the type we are deriving for. We instantiate behaviour at a via type and then coerce it to our type. The :instances command lists candidates that can be derived via a given type. That enables programmers to compose instances from named programming patterns, thereby turning deriving into a high-level domain-specific language for defining instances. Deriving Via leverages newtypes—an already familiar tool of the Haskell trade—to declare recurring patterns in a way that both feels natural and allows a high degree of abstraction."]},{"key":"dc:title","label":"Title","values":["Deriving Via Type-directed instances"]},{"key":"others:access_status","label":"Others Access Status","values":["open.access"]}]}],"canonical_facts":{"dc:contributor.committeemember":["Sheeran, Mary"],"dc:contributor.department":["Chalmers tekniska högskola / Institutionen för data och informationsteknik"],"dc:contributor.supervisor":["Sheeran, Mary"],"dc:creator":["Blöndal, Baldur"],"dc:date.accessioned":["2020-11-03T13:15:40Z"],"dc:date.available":["2020-11-03T13:15:40Z"],"dc:date.issued":["2020"],"dc:date.submitted":["2020"],"dc:description.abstract":["Type classes are at the heart of Haskell and constitute a language of type-directed behaviour. The programmer defines behaviour for each type by defining a class instance where the compiler transparently fills in the blanks with code. Types guide this process. Each type has a single instance: what if there is more than one way to act? The established approach is to wrap such a type in a newtype, ensuring it has the same memory representation. newtypes require require laborious manual wrapping and unwrapping which have no effect at runtime. Haskell’s deriving construct allows easily generating instances that follow a common pattern by simply listing the classes you want derived. At present, GHC only supports deriving a few classes. The only alternative is to write it by hand. This thesis offers an alternative: the language extension -XDerivingVia (appeared in GHC 8.6 ) and the GHCi command :instances (appeared in GHC 8.10 ) which lists instances of types. The Deriving Via introduces a new deriving strategy via which allows deriving classes from one or more ‘via types’. These types must be identical (at runtime) to the type we are deriving for. We instantiate behaviour at a via type and then coerce it to our type. The :instances command lists candidates that can be derived via a given type. That enables programmers to compose instances from named programming patterns, thereby turning deriving into a high-level domain-specific language for defining instances. Deriving Via leverages newtypes—an already familiar tool of the Haskell trade—to declare recurring patterns in a way that both feels natural and allows a high degree of abstraction."],"dc:identifier.coursecode":["MPALG"],"dc:identifier.uri":["https://hdl.handle.net/20.500.12380/302035"],"dc:language.iso":["eng"],"dc:publisher.program":["Computer science – algorithms, languages and logic (MPALG), MSc"],"dc:subject":["Thesis","deriving","Haskell","program synthesis","type classes","safe coercions"],"dc:subject.uppsok":["Technology"],"dc:title":["Deriving Via Type-directed instances"],"dc:type.degree":["Examensarbete för masterexamen"],"others:access_status":["open.access"],"thesis:degree_level":["H"]},"updated_at":"2026-11-19T03:01:43Z"}