Created
September 20, 2012 17:46
-
-
Save nwf/3757318 to your computer and use it in GitHub Desktop.
Haskell closed classes using DataKinds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
-- Needed only for example below | |
-- {-# LANGUAGE UndecidableInstances #-} | |
data T1 = T1A | T1B | |
class Test (a :: T1) b | a -> b, b -> a where tcc :: b -> String | |
instance Test T1A Int where tcc = show | |
instance Test T1B [Char] where tcc = id | |
-- New instances fail with fundep conflicts. Try, for example, | |
-- instance Test T1A Float where tcc = show | |
-- instance Test a Float where tcc = show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment