Commit 043fddf1 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Test Trac #7328 and #7332

parent 126c7984
{-# LANGUAGE PolyKinds, GADTs #-}
module T7328 where
data Proxy a
class Foo a where
foo :: a ~ f i => Proxy (Foo f)
T7328.hs:8:34:
Kind occurs check
The first argument of `Foo' should have kind `k0',
but `f' has kind `k1 -> k0'
In the type `a ~ f i => Proxy (Foo f)'
In the class declaration for `Foo'
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances, FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE OverloadedStrings #-}
module T7332 where
import GHC.Exts( IsString(..) )
import Data.Monoid
newtype DC d = DC d
deriving (Show, Monoid)
instance IsString (DC String) where
fromString = DC
class Monoid acc => Build acc r where
type BuildR r :: * -- Result type
build :: (acc -> BuildR r) -> acc -> r
instance Monoid dc => Build dc (DC dx) where
type BuildR (DC dx) = DC dx
build tr acc = tr acc
instance (Build dc r, a ~ dc) => Build dc (a->r) where
type BuildR (a->r) = BuildR r
build tr acc s = build tr (acc `mappend` s)
-- The type is inferred
tspan :: (Monoid d, Build (DC d) r, BuildR r ~ DC d) => r
tspan = build (id :: DC d -> DC d) mempty
foo = tspan "aa"
foo1 = tspan (tspan "aa")
bar = tspan "aa" :: DC String
......@@ -73,3 +73,5 @@ test('T7230', normal, compile_fail,[''])
test('T7238', normal, compile,[''])
test('T7278', normal, compile_fail,[''])
test('Holdermans', normal, compile_fail,[''])
test('T7328', normal, compile_fail,[''])
test('T7332', normal, compile,[''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment