I'm running in errors that, I think, is related with functional dependence. But I don't know how to interpret or solve them.
I have basically 3 types: Edge, Face and Simplex (Tetrahedron) and I want to combined them in a class type such that:
under the same MCB (Marriage Before Conquer) algorithm.
I first tried to use Multiparameter type class with functional dependence relation:
class SubUnit subUnit unit | subUnit -> unit, unit -> subUnit where
buildUnit :: ActiveSubUnit subUnit -> [Point] -> Maybe unit
build1stUnit :: Plane -> [Point] -> [Point] -> [Point] -> Maybe unit
getAllSubUnits :: unit -> [ActiveSubUnit subUnit]
subUnitPos :: BoxPair -> subUnit -> Position
src/DeUni.hs:265:39:
Couldn't match type `Unit subUnit3' with `Unit subUnit2'
NB: `Unit' is a type function, and may not be injective
Expected type: Unit a
Actual type: Unit subUnit2
In the expression: un
In the expression: [un]
In the first argument of `return', namely
`(([un], fromList $ getAllSubUnits un) ::
SubUnit a => ([Unit a], SetActiveSubUnits a))'
src/DeUni.hs:265:39:
Couldn't match type `Unit (ActiveSubUnit subUnit3)'
with `Unit subUnit2'
NB: `Unit' is a type function, and may not be injective
Expected type: Unit a
Actual type: Unit subUnit2
In the expression: un
In the expression: [un]
In the first argument of `return', namely
`(([un], fromList $ getAllSubUnits un) ::
SubUnit a => ([Unit a], SetActiveSubUnits a))'
src/DeUni.hs:265:44:
Could not deduce (a1 ~ ActiveSubUnit subUnit3)
from the context (SubUnit a)
bound by the type signature for
mbc :: SubUnit a =>
[Point] -> SetActiveSubUnits a -> Box -> StateMBC a [Unit a]
at src/DeUni.hs:(260,1)-(317,53)
or from (SubUnit a1)
bound by an expression type signature:
SubUnit a1 => ([Unit a1], SetActiveSubUnits a1)
at src/DeUni.hs:265:37-117
`a1' is a rigid type variable bound by
an expression type signature:
SubUnit a1 => ([Unit a1], SetActiveSubUnits a1)
at src/DeUni.hs:265:37
Expected type: SetActiveSubUnits a
Actual type: Set (ActiveSubUnit subUnit3)
In the expression: fromList $ getAllSubUnits un
In the first argument of `return', namely
`(([un], fromList $ getAllSubUnits un) ::
SubUnit a => ([Unit a], SetActiveSubUnits a))'
.....
.....