[Hs-Generics] A Lightweight Implementation of Generics and
Dynamics (LIGD)
Stefan Holdermans
stefan at cs.uu.nl
Fri Oct 20 02:09:49 EDT 2006
Stephanie,
> What do you mean by "local redefinitions"?
I suppose it could be described as "scoped specializability"; see
Chapter 8 of Andres' thesis [1].
Examples of local redefinitions in GH:
-- case-insenstive equality
let equals {| a |} c1 c2 = equals {| Char |} (toUpper c1) (toUpper
c2)
in equals {| [a] |} "Hello" "hEllo"
-- length of the list
let size {| a |} x = 1
in size {| [a] |} [2, 3, 5, 7]
-- map toUpper
let map {| a |} = toUpper
in map {| [a] |} "Hello, world!"
-- flattens the list of lists
let collect {| a |} x = [x]
in collect {| [[a]] |} xss
-- unlines
let collect {| a |} s = s ++ "\n"
in collect {| [a] |} ["Hello", "World"]
Cheers,
Stefan
----
[1] Andres Loeh. Exploring Generic Haskell. Ph.D. thesis, Utrecht
University, 2004.
More information about the Generics
mailing list