From e0718f203f2448ba2029e70d14aed075860b7fac Mon Sep 17 00:00:00 2001 From: nand Date: Tue, 4 Feb 2014 22:13:27 +0100 Subject: Add support for type/data families This adds support for type/data families with their respective instances, as well as closed type families and associated type/data families. Signed-off-by: Mateusz Kowalczyk --- html-test/ref/TypeFamilies.html | 674 ++++++++++++++++++++++++++++++++++----- html-test/ref/TypeFamilies2.html | 113 +++++++ html-test/ref/ocean.css | 19 ++ html-test/src/TypeFamilies.hs | 76 +++-- html-test/src/TypeFamilies2.hs | 12 + 5 files changed, 797 insertions(+), 97 deletions(-) create mode 100644 html-test/ref/TypeFamilies2.html create mode 100644 html-test/src/TypeFamilies2.hs (limited to 'html-test') diff --git a/html-test/ref/TypeFamilies.html b/html-test/ref/TypeFamilies.html index 27a4564c..bfafc3d0 100644 --- a/html-test/ref/TypeFamilies.html +++ b/html-test/ref/TypeFamilies.html @@ -17,11 +17,11 @@ window.onload = function () {pageLoad();setSynopsis("mini_TypeFamilies.html");}; >

TypeFamilies

Description

Doc for: module TypeFamilies

Synopsis

Documentation

data X

Doc for: data X

Constructors

X

Doc for: X

XX

Doc for: XX

XXX

Doc for: XXX

Instances

Assoc X

Doc for: instance Assoc X

Test X

Doc for: instance Test X

data AssocD X = AssocX 
type AssocT X = Foo X 
data Bat X

Doc for: data instance Bat X

type Foo X = Y

Doc for: type instance Foo X = Y

data Y

Doc for: data Y

Instances

Assoc Y

Doc for: instance Assoc Y

Test Y

Doc for: instance Test Y

data AssocD Y = AssocY 
type AssocT Y = Bat Y 
data Bat Y

Doc for: data instance Bat Y

type Foo Y = X

Doc for: type instance Foo Y = X

class Test a

Doc for: class Test a

Instances

Test Y

Doc for: instance Test Y

Test X

Doc for: instance Test X

type family G Foo a

Doc for: type family Foo a

Instances

type Foo Y = X

Doc for: type instance Foo Y = X

type Foo X = Y

Doc for: type instance Foo X = Y

data family Bat a :: *

Type family G

Doc for: data family Bat a

Instances

data Bat Y

Doc for: data instance Bat Y

data Bat X

Doc for: data instance Bat X

class A a where

Assoc a

A class with an associated type

Doc for: class Assoc a

data B a :: * -> *

AssocD a :: *

An associated type

Doc for: data AssocD a

Methods

f :: B a Int

type AssocT a :: *

A method

Doc for: type AssocT a

Instances

A IntAssoc Y

Doc for: instance Assoc Y

Assoc X

Doc for: instance Assoc X

 

type family F a

Bar b

Doc for family

Doc for: type family Bar b

Equations

Bar X = X 
Bar y = Y 
+TypeFamilies2
Safe HaskellSafe-Inferred

TypeFamilies2

Documentation

data X

Instances

type Foo X = Y 

type family Foo a

Instances

type Foo X = Y 
diff --git a/html-test/ref/ocean.css b/html-test/ref/ocean.css index 42238709..05597d79 100644 --- a/html-test/ref/ocean.css +++ b/html-test/ref/ocean.css @@ -420,6 +420,19 @@ div#style-menu-holder { margin: 0; } +.subs ul { + height: 100%; + padding: 0.5em; + margin: 0; +} + +.subs ul, +.subs ul li.src { + list-style: none; + margin-left: 1em; +} + + .top p.src { border-top: 1px solid #ccc; } @@ -457,6 +470,12 @@ div#style-menu-holder { /* @group Auxillary Pages */ + +.extension-list { + list-style-type: none; + margin-left: 0; +} + #mini { margin: 0 auto; padding: 0 1em 1em; diff --git a/html-test/src/TypeFamilies.hs b/html-test/src/TypeFamilies.hs index 561f95fd..725e76a7 100644 --- a/html-test/src/TypeFamilies.hs +++ b/html-test/src/TypeFamilies.hs @@ -1,28 +1,68 @@ -{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeFamilies, UndecidableInstances #-} +-- | Doc for: module TypeFamilies module TypeFamilies where --- | Type family G -type family G a :: * +-- | Doc for: data X +data X + = X -- ^ Doc for: X + | XX -- ^ Doc for: XX + | XXX -- ^ Doc for: XXX --- | A class with an associated type -class A a where - -- | An associated type - data B a :: * -> * - -- | A method - f :: B a Int +-- | Doc for: data Y +data Y --- | Doc for family -type family F a +-- | Doc for: class Test a +class Test a +-- | Doc for: instance Test X +instance Test X +-- | Doc for: instance Test Y +instance Test Y --- | Doc for G Int -type instance G Int = Bool -type instance G Float = Int +-- | Doc for: type family Foo a +type family Foo a +-- | Doc for: type instance Foo X = Y +type instance Foo X = Y +-- | Doc for: type instance Foo Y = X +type instance Foo Y = X -instance A Int where - data B Int x = Con x - f = Con 3 +-- | Doc for: data family Bat a +data family Bat a :: * -g = Con 5 +-- | Doc for: data instance Bat X +data instance Bat X + = BatX X -- ^ Doc for: BatX X + | BatXX { aaa :: X , bbb :: Y } -- ^ Doc for: BatXX { ... } + +-- | Doc for: data instance Bat Y +data instance Bat Y + = BatY Y -- ^ Doc for: BatY Y + | X :+ X -- X :+ X + +-- | Doc for: class Assoc a +class Assoc a where + -- | Doc for: data AssocD a + data AssocD a :: * + -- | Doc for: type AssocT a + type AssocT a :: * + +-- | Doc for: instance Assoc X +instance Assoc X where + -- | Doc for: data AssocD X = AssocX + data AssocD X = AssocX -- ^ Doc for: AssocX + -- | Doc for: type AssocT X = Foo X + type AssocT X = Foo X + +-- | Doc for: instance Assoc Y +instance Assoc Y where + -- | Doc for: data AssocD Y = AssocY + data AssocD Y = AssocY -- ^ Doc for: AssocY + -- | Doc for: type AssocT Y = Bat Y + type AssocT Y = Bat Y + +-- | Doc for: type family Bar b +type family Bar b where + Bar X = X + Bar y = Y diff --git a/html-test/src/TypeFamilies2.hs b/html-test/src/TypeFamilies2.hs new file mode 100644 index 00000000..718e11dc --- /dev/null +++ b/html-test/src/TypeFamilies2.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE TypeFamilies #-} +-- This tests what happens if we have unexported types +-- in type instances. The expected behaviour is +-- that we get the instance, Y is not linked and +-- Haddock shows a linking warning. +module TypeFamilies2 (X, Foo) where + +data X +data Y + +type family Foo a +type instance Foo X = Y -- cgit v1.2.3