Hi Günther

The finally tagless style is an implementation of the TypeCase pattern
(Bruno C. d. S. Oliveira and Jeremy Gibbons):

http://www.comlab.ox.ac.uk/jeremy.gibbons/publications/typecase.pdf

TypeCase can be implemented via GADTs or type classes - typed printf
in section 4.2 of the paper is shown in both versions.

The authors of the "Finally Tagless" note in the long version of their
paper that the GADT TypeCase had some problems with non-exhaustive
pattern matching (last paragraph, page 14) - if I'm understanding it
correctly, in order to be total, the interpretation function stills
needs to introduce pattern matching clauses in some circumstances for
values that the GADT actually prevents occurring.

Plain old data types can easily be interpreted by multiple evaluators
- the benefit of TypeCase is probably when you want some degree of
extensibility, see this message for instance:

http://www.haskell.org/pipermail/haskell-cafe/2008-July/045028.html

Best wishes

Stephen
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to