[Haskell-cafe] Functional dependence nightmare

Stephen Tetley stephen.tetley at gmail.com
Sat Mar 26 23:13:05 CET 2011


Hi Edgar

I think you have some errors of construction rather than just a
problem with the type families / fun deps.

Note, I've knocked off the class constraints on the data declarations
on the copy I'm working with (e.g ActiveSubUnit) , this may or may not
change things.

This change to splitAF will type check, whether or not it does what you want:

> splitAF::(SubUnit a, Ord a)=> BoxPair -> a -> StateMBC a ()
> splitAF pairBox e = case subUnitPos pairBox e of


Your code was:

> splitAF::(SubUnit a)=>BoxPair -> a -> StateMBC a ()
> splitAF pairBox e = case subUnitPos pairBox (activeUnit e) of


getUnitsOnPlane will compile if you comment out the type sig, but GHC
generates this type sig:


getUnitsOnPlane ::
  (Unit su1 ~ Unit su,
   SubUnit (ActiveSubUnit su),
   SubUnit su1,
   SubUnit su,
   Ord su) =>
  [Point]
  -> BoxPair
  -> t
  -> StateT
       (SubUnitsSets (ActiveSubUnit su))
       Data.Functor.Identity.Identity
       [Unit su]
        -- Defined at DeUni.hs:324:1-15

Note the class constraints are introducing a type variable *su1* that
isn't mentioned in the function arguments, this strongly makes me
think the function body isn't doing what it should. Also GHC infers a
type var *t* rather than Plane for the second arg, again this makes me
think the function body is not right.

I'm a bit at a loss with the mbc function, if I comment out the
function type sig and local type sigs GHC generates some errors
mentioning Edge - as Edge is one of the instances of SubUnit, I think
the function body is less polymorphic than you expect.

Best wishes

Stephen



More information about the Haskell-Cafe mailing list