Hi, I have an error message, and I’m looking for code that produces it (how is that for a change...)
While fixing https://ghc.haskell.org/trac/ghc/ticket/8576 I’d like to clean up some error reporting in FunDeps.lhs, in particular code that is involved in producing errors like Couldn't match type 'False with 'True When using functional dependencies to combine And 'False 'False 'False, arising from the dependency `a b -> c' in the instance declaration in `UnitTyped.Units' And 'False 'False 'True, arising from a use of `+' at <interactive>:14:7 In the expression: meter + second In an equation for `it': it = meter + second but unfortunately, the test suite does _not_ contain any code that creates this error message. Also, the results obtained from googling for that error message yield either no code, or only unhelpful code fragments, or code that produces a different error message with current HEAD. Unfortunately, I cannot produce code that triggers it. Does anyone have code lying around that triggers that error message? Also: I found code that had this kind of error message in 7.6, e.g. the attached code’s error changed from FunDepError.hs:86:27: Couldn't match type `F a1' with `U' When using functional dependencies to combine UpdateR (xs :> s) (S n) t (xs' :> s), arising from the dependency xs n t -> xs' in the instance declaration at FunDepError.hs:54:10 UpdateR ((xs' :> F a0) :> F a1) (S O) U ((jj0 :> U) :> U), arising from a use of `var' at FunDepError.hs:86:27-29 In the expression: var a In the first argument of `lam', namely `(\ b -> var a)' (sorry for not finding something simpler) to FunDepError.hs:86:5: No instance for (Consume xs' jj) arising from a use of ‛lam’ Possible fix: add (Consume xs' jj) to the context of the inferred type of x :: LLC t xs' jj (a :-> (a1 :-> a)) In the expression: lam (\ a -> lam (\ b -> var a)) In an equation for ‛x’: x = lam (\ a -> lam (\ b -> var a)) FunDepError.hs:86:27: No instance for (UpdateR ((xs' :> F a) :> F a1) (S O) U ((jj :> U) :> U)) arising from a use of ‛var’ In the expression: var a In the first argument of ‛lam’, namely ‛(\ b -> var a)’ In the expression: lam (\ b -> var a) Is that desired or a regression? Greetings, Joachim -- Joachim “nomeata” Breitner [email protected] • http://www.joachim-breitner.de/ Jabber: [email protected] • GPG-Key: 0x4743206C Debian Developer: [email protected]
{-# LANGUAGE
MultiParamTypeClasses,FunctionalDependencies,FlexibleInstances,FlexibleContexts,
UndecidableInstances,OverlappingInstances,NoMonomorphismRestriction,Rank2Types,
TypeOperators,EmptyDataDecls,KindSignatures,TypeFamilies
#-}
module FunDepError (x) where
data O = O deriving Show
data S n = S n deriving Show
class Sub a b c | a b -> c where
sub :: a -> b -> c
instance Sub n n O where sub _ _ = O
instance Sub (S n) n (S O) where sub _ _ = S O
instance Sub (S (S n)) n (S (S O)) where sub _ _ = S (S O)
instance Sub (S (S (S n))) n (S (S (S O))) where sub _ _ = S (S (S O))
data xs :> x = xs :> x
data Nil = Nil
class HList xs n | xs -> n where
len :: xs -> n
instance HList xs n => HList (xs :> x) (S n) where
len ~(xs :> x) = S (len xs)
instance HList Nil O where
len _ = O
class Pickup xs n s | xs n -> s where
pickup :: xs -> n -> s
instance (HList xs l, Sub l (S n) m, PickupR xs m s)
=> Pickup xs n s where
pickup xs n = pickupR xs (sub (len xs) (S n))
class PickupR xs n s | xs n -> s where
pickupR :: xs -> n -> s
instance xs ~ (xs':>t) => PickupR xs O t where
pickupR (_ :> t) _ = t
instance (PickupR xs' n t, xs ~ (xs':>s')) => PickupR xs (S n) t where
pickupR (xs' :> _) (S n) = pickupR xs' n
class Update xs n t xs' | xs n t -> xs' where
update :: xs -> n -> t -> xs'
instance (HList xs l, Sub l (S n) m, UpdateR xs m t xs')
=> Update xs n t xs' where
update xs n t = updateR xs (sub (len xs) (S n)) t
class UpdateR xs n t xs' | xs n t -> xs' where
updateR :: xs -> n -> t -> xs'
instance UpdateR (xs:>s) O t (xs:>t) where
updateR (xs:>_) _ t = xs :> t
instance UpdateR xs n t xs' => UpdateR (xs:>s) (S n) t (xs':>s) where
updateR (xs:>s) (S n) t = updateR xs n t :> s
newtype F a = F a
data U = U
newtype a :-> b = Arr { ext :: a -> IO b }
newtype LLC t ii jj a = LLC { run' :: ii -> IO (jj,a) }
run :: forall a n jj. (forall t. LLC t Nil Nil a) -> IO a
run s = case s of LLC m -> m Nil >>= \(_,a) -> return a
newtype Var n = Var n
infixr 6 :->
class Consume ii jj where
consume :: ii -> jj
instance Consume Nil Nil where
consume _ = Nil
instance Consume ii jj => Consume (ii:>F a) (jj:>F a) where
consume (ii:>i) = consume ii :> i
instance Consume ii jj => Consume (ii:>F a) (jj:>U) where
consume (ii:>_) = consume ii :> U
lam :: (HList ii n, Consume ii jj) => (Var n -> LLC t (ii:>F a) (jj:>U) b) -> LLC t ii jj (a :-> b)
lam f = LLC (\ii -> return (consume ii, Arr $ \a -> run' (f (Var $ len ii)) (ii:>F a) >>= \(_,b) -> return b))
var :: (Pickup ii n (F a), Update ii n U jj) => Var n -> LLC t ii jj a
var (Var n) = LLC (\ii -> return (update ii n U, case pickup ii n of F x -> x))
x = lam (\a -> lam (\b -> var a))
signature.asc
Description: This is a digitally signed message part
_______________________________________________ ghc-devs mailing list [email protected] http://www.haskell.org/mailman/listinfo/ghc-devs
