TY - GEN
T1 - Functional pearl
T2 - Proceedings of the ACM SIGPLAN 2004 Haskell Workshop, Haskell'04
AU - Kiselyov, Oleg
AU - Shan, Chung Chieh
PY - 2004
Y1 - 2004
N2 - The configurations problem is to propagate run-time preferences throughout a program, allowing multiple concurrent configuration sets to coexist safely under statically guaranteed separation. This problem is common in all software systems, but particularly acute in Haskell, where currently the most popular solution relies on unsafe operations and compiler pragmas. We solve the configurations problem in Haskell using only stable and widely implemented language features like the type-class system. In our approach, a term expression can refer to run-time configuration parameters as if they were compile-time constants in global scope. Besides supporting such intuitive term notation and statically guaranteeing separation, our solution also helps improve the program's performance by transparently dispatching to specialized code at run-time. We can propagate any type of configuration data-numbers, strings, 10 actions, polymorphic functions, closures, and abstract data types. No previous approach to propagating configurations implicitly in any language provides the same static separation guarantees. The enabling technique behind our solution is to propagate values via types, with the help of polymorphic recursion and higher-rank polymorphism. The technique essentially emulates local type-class instance declarations while preserving coherence. Configuration parameters are propagated throughout the code implicitly as part of type inference rather than explicitly by the programmer. Our technique can be regarded as a portable, coherent, and intuitive alternative to implicit parameters. It motivates adding local instances to Haskell, with a restriction that salvages principal types.
AB - The configurations problem is to propagate run-time preferences throughout a program, allowing multiple concurrent configuration sets to coexist safely under statically guaranteed separation. This problem is common in all software systems, but particularly acute in Haskell, where currently the most popular solution relies on unsafe operations and compiler pragmas. We solve the configurations problem in Haskell using only stable and widely implemented language features like the type-class system. In our approach, a term expression can refer to run-time configuration parameters as if they were compile-time constants in global scope. Besides supporting such intuitive term notation and statically guaranteeing separation, our solution also helps improve the program's performance by transparently dispatching to specialized code at run-time. We can propagate any type of configuration data-numbers, strings, 10 actions, polymorphic functions, closures, and abstract data types. No previous approach to propagating configurations implicitly in any language provides the same static separation guarantees. The enabling technique behind our solution is to propagate values via types, with the help of polymorphic recursion and higher-rank polymorphism. The technique essentially emulates local type-class instance declarations while preserving coherence. Configuration parameters are propagated throughout the code implicitly as part of type inference rather than explicitly by the programmer. Our technique can be regarded as a portable, coherent, and intuitive alternative to implicit parameters. It motivates adding local instances to Haskell, with a restriction that salvages principal types.
KW - Existential types
KW - Higher-rank polymorphism
KW - Implicit parameters
KW - Polymorphic recursion
KW - Type classes
UR - http://www.scopus.com/inward/record.url?scp=11244309683&partnerID=8YFLogxK
UR - http://www.scopus.com/inward/citedby.url?scp=11244309683&partnerID=8YFLogxK
M3 - Conference contribution
AN - SCOPUS:11244309683
SN - 1581138504
SN - 9781581138504
T3 - Proceedings of the ACM SIGPLAN 2004 Haskell Workshop, Haskell'04
SP - 33
EP - 44
BT - Proceedings of the ACM SIGPLAN 2004 Haskell Workshop, Haskell'04
Y2 - 22 September 2004 through 22 September 2004
ER -