Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
simonpj
committed
Apr 28, 2008
1 parent
c179df0
commit fc2ea08
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE EmptyDataDecls #-} | ||
{-# LANGUAGE FunctionalDependencies #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
|
||
-- Trac #2238 | ||
-- Notice that class CTF has just one value field, but | ||
-- it also has an equality predicate. | ||
-- See Note [Class newtypes and equality predicates] in BuildTyCl | ||
|
||
module Foo where | ||
|
||
data A | ||
data B | ||
|
||
-- via functional dependencies | ||
|
||
class HowFD a how | a -> how | ||
|
||
class HowFD a how => CFD a how where | ||
cfd :: a -> String | ||
cfd _ = "cfd" | ||
instance HowFD a how => CFD a how | ||
|
||
instance HowFD Bool A | ||
|
||
-- via type families | ||
|
||
type family HowTF a | ||
|
||
class how ~ HowTF a => CTF a how where | ||
ctf :: a -> String | ||
ctf _ = "ctf" | ||
|
||
instance how ~ HowTF a => CTF a how | ||
|
||
type instance HowTF Bool = A |
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