Derive
This library provides a framework for deriving instances, using GHC and Template Haskell. It can be seen as an alternative to DrIFT.
Acknowledgements
Thanks to Stefan O'Rear for being co-author of the tool. Thanks Twan van Laarhoven for contributing Functor deriving.
Downloads
- Released version
- Deriving a Relationship from a Single Example - from Approaches and Applications of Inductive Programming 2009 (abstract)(hide abstract)
Given an appropriate domain specific language (DSL), it is possible
to describe the relationship between Haskell data types and many
generic functions, typically type-class instances. While describing
the relationship is possible, it is not always an easy task. There is an
alternative - simply give one example output for a carefully chosen
input, and have the relationship derived.
When deriving a relationship from only one example, it is important
that the derived relationship is the intended one.We identify
general restrictions on the DSL, and on the provided example, to
ensure a level of predictability. We then apply these restrictions in
practice, to derive the relationship between Haskell data types and
generic functions. We have used our scheme in the Derive tool,
where over 60% of type classes are derived from a single example.
(bibtex)(hide bibtex)@inproceedings{mitchell:derive_2009_9_4
,title = {Deriving a Relationship from a Single Example}
,author = {Neil Mitchell}
,year = {2009}
,month = {September}
,day = {4}
,location = {Edinburgh, Scotland, UK}
,series = {Lecture Notes in Computer Science, Vol. 5812}
,editors = {Ute Schmid, Emanuel Kitzelmann, Rinus Plasmeijer}
,isbn = {978-3-642-11930-9}
,pages = {1--24}
,url = {\verb'http://community.haskell.org/~ndm/downloads/paper-deriving_a_relationship_from_a_single_example-04_sep_2009.pdf'}
}
- Instances for Free - from PLASMA (bibtex)(hide bibtex)
@misc{mitchell:derive_2008_5_22
,title = {Instances for Free}
,author = {Neil Mitchell}
,year = {2008}
,month = {May}
,day = {22}
,note = {Presentation from PLASMA}
,url = {\verb'http://community.haskell.org/~ndm/downloads/slides-instances_for_free-22_may_2008.pdf'}
}
- Deriving Generic Functions by Example - from York Doctoral Symposium 2007 (abstract)(hide abstract)
A function is said to be generic if it operates over values of
any data type. For example, a generic equality function can test pairs of
booleans, integers, lists, trees etc. In most languages programmers must
define generic functions multiple times, specialised for each data type.
Alternatively, a tool could be used to specify the relationship between the
data type and the implementation, but this relationship may be complex.
This paper describes a solution: given a single example of the generic
function on one data type, we can infer the relationship between a data
type and the implementation. We have used our method in the Derive
tool, allowing the implementation of 60% of the generic functions to be
inferred.
(bibtex)(hide bibtex)@inproceedings{mitchell:derive_2007_10_26
,title = {Deriving Generic Functions by Example}
,author = {Neil Mitchell}
,year = {2007}
,month = {October}
,day = {26}
,pages = {55--62}
,publisher = {Tech. Report YCS-2007-421, Dept. of Computer Science, University of York, UK}
,editor = {Jan Tobias M\"{u}hlberg and Juan Ignacio Perna}
,booktitle = {Proceedings of the First York Doctoral Syposium 2007}
,url = {\verb'http://community.haskell.org/~ndm/downloads/paper-deriving_generic_functions_by_example-26_oct_2007.pdf'}
}
Tags: haskell library popular program