From 90f2b604933f7ae96ec280a94ced1e54bb6f69ab Mon Sep 17 00:00:00 2001 From: simonpj Date: Mon, 5 Feb 2001 08:43:47 +0000 Subject: [PATCH] [project @ 2001-02-05 08:43:47 by simonpj] Add restriction comment to generics --- ghc/docs/users_guide/glasgow_exts.sgml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ghc/docs/users_guide/glasgow_exts.sgml b/ghc/docs/users_guide/glasgow_exts.sgml index 3e42fab..909def9 100644 --- a/ghc/docs/users_guide/glasgow_exts.sgml +++ b/ghc/docs/users_guide/glasgow_exts.sgml @@ -4463,6 +4463,32 @@ A generic method declaration must give a case for each of the three type constru +The type for a generic method can be built only from: + + Function arrows + Type variables + Tuples + Arbitrary types not involving type variables + +Here are some example type signatures for generic methods: + + op1 :: a -> Bool + op2 :: Bool -> (a,Bool) + op3 :: [Int] -> a -> a + op4 :: [a] -> Bool + +Here, op1, op2, op3 are OK, but op4 is rejected, because it has a type variable +inside a list. + + +This restriction is an implementation restriction: we just havn't got around to +implementing the necessary bidirectional maps over arbitrary type constructors. +It would be relatively easy to add specific type constructors, such as Maybe and list, +to the ones that are allowed. + + + + In an instance declaration for a generic class, the idea is that the compiler will fill in the methods for you, based on the generic templates. However it can only do so if -- 1.7.10.4