Abstract
Monads provide a greatly useful capability to pure languages in simulating side-effects, but implementations such as the Monad Transformer Library [1] in Haskell prohibit reuse of those side-effects such as threading through two different states without some explicit work-around. Monad Factory provides a straightforward solution for opening the non-proper morphisms by indexing monads at both the type-level and term-level, allowing ‘copies’ of the monads to be created and simultaneously used within even the same monadic transformer stack. This expands monads’ applicability and mitigates the amount of boilerplate code we need for monads to work together, and yet we use them nearly identically to non-indexed monads.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Gill, A.: mtl: The Monad Transformer Library (September 2010), http://hackage.haskell.org/package/mtl-1.1.1.0
GHC: The Glasgow Haskell Compiler, http://haskell.org/ghc/
Snyder, M.: mtlx: Monad transformer library with type indexes, providing ’free’ copies (October 2010), http://hackage.haskell.org/package/mtlx-0.1.5
Harrison, W.L., Hook, J.: Achieving information flow security through precise control of effects. In: CSFW 2005: Proceedings of the 18th IEEE Workshop on Computer Security Foundations, pp. 16–30. IEEE Computer Society, Washington, DC (2005)
McBride, C.: Faking It - Simulating Dependent Types in Haskell. J. Funct. Program 12(5), 375–392 (2002)
Cheney, J., Hinze, R.: First-class phantom types. Technical report, Cornell University (2003)
Claessen, K., Hughes, J.: QuickCheck: a lightweight tool for random testing of Haskell programs. In: ICFP 2000: Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming, pp. 268–279. ACM, New York (2000)
Moggi, E.: An Abstract View of Programming Languages. Technical Report ECS-LFCS-90-113, Dept. of Comp. Sci., Edinburgh Univ. (1990)
Wadler, P.L.: Comprehending Monads. In: Proceedings of the 1990 ACM Conference on LISP and Functional Programming, pp. 61–78. ACM, New York (1990)
Wadler, P.: The Essence of Functional Programming. In: Conference Record of the Nineteenth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Albequerque, New Mexico, pp. 1–14 (1992)
Jones, M.P.: Functional Programming with Overloading and Higher-Order Polymorphism. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925, pp. 97–136. Springer, Heidelberg (1995)
Kariotis, P.S., Procter, A.M., Harrison, W.L.: Making Monads First-Class with Template Haskell. In: Haskell 2008: Proceedings of the First ACM SIGPLAN Symposium on Haskell, pp. 99–110. ACM, New York (2008)
Sheard, T., Jones, S.P.: Template Meta-Programming for Haskell. SIGPLAN Not 37(12), 60–75 (2002)
Atkey, R.: Parameterized Notions of Computation. In: Proceedings of Workshop on Mathematically Structured Functional Programming (July 2006)
Jaskelioff, M.: Monatron: An Extensible Monad Transformer Library. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 64–79. Springer, Heidelberg (2009)
Kiselyov, O., Lämmel, R., Schupke, K.: Strongly Typed Heterogeneous Collections. In: Haskell 2004: Proceedings of the ACM SIGPLAN Workshop on Haskell, pp. 96–107. ACM Press, New York (2004)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2011 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Snyder, M., Alexander, P. (2011). Monad Factory: Type-Indexed Monads. In: Page, R., Horváth, Z., Zsók, V. (eds) Trends in Functional Programming. TFP 2010. Lecture Notes in Computer Science, vol 6546. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-22941-1_13
Download citation
DOI: https://doi.org/10.1007/978-3-642-22941-1_13
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-22940-4
Online ISBN: 978-3-642-22941-1
eBook Packages: Computer ScienceComputer Science (R0)