diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2016-10-13 21:34:17 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2016-10-20 12:45:34 -0700 |
commit | 7e77c4b2ee08d7f88df8ba47537640ec1bd70bfe (patch) | |
tree | 523c9967e676508468a8fe9254a6b35afa2ff65f /testsuite/tests/backpack/should_compile/bkp40.bkp | |
parent | 518f28959ec56cf27d6a8096a14a6ce9bc8b9816 (diff) | |
download | haskell-7e77c4b2ee08d7f88df8ba47537640ec1bd70bfe.tar.gz |
Support constraint synonym implementations of abstract classes.
Summary:
Test Plan: validate
Reviewers: goldfire, simonpj, austin, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2595
GHC Trac Issues: #12679
Diffstat (limited to 'testsuite/tests/backpack/should_compile/bkp40.bkp')
-rw-r--r-- | testsuite/tests/backpack/should_compile/bkp40.bkp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/testsuite/tests/backpack/should_compile/bkp40.bkp b/testsuite/tests/backpack/should_compile/bkp40.bkp new file mode 100644 index 0000000000..3f97456686 --- /dev/null +++ b/testsuite/tests/backpack/should_compile/bkp40.bkp @@ -0,0 +1,41 @@ +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE TypeSynonymInstances #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE RoleAnnotations #-} +unit user where + signature Map where + type role Map nominal representational + data Map k a + class Key k + instance Key String + empty :: Map k a + lookup :: Key k => k -> Map k a -> Maybe a + insert :: Key k => k -> a -> Map k a -> Map k a + module User where + import Prelude hiding (lookup) + import Map + x = lookup "foo" (insert "foo" True empty) +unit ordmap where + module Map(module Data.Map, Key) where + import Data.Map + type Key = Ord +unit eqmap where + module Map where + import Prelude hiding (lookup) + import qualified Prelude + type role Map nominal representational + newtype Map k a = Assoc [(k, a)] + type Key = Eq + -- Ugh, need the type signatures, otherwise the quantifiers + -- are put in the wrong order. See #12441 + empty :: Map k a + empty = Assoc [] + lookup :: Eq k => k -> Map k a -> Maybe a + lookup k (Assoc xs) = Prelude.lookup k xs + -- Need to insert redundant constraint to make it work... + insert :: Eq k => k -> a -> Map k a -> Map k a + insert k v (Assoc xs) = Assoc ((k,v):xs) +unit main where + dependency user[Map=ordmap:Map] (User as User.Ord) + dependency user[Map=eqmap:Map] (User as User.Eq) + |