I'm playing with a wrapper for lists that can be indexed individually.
The basic class of such wrappers:
class list where the list: :: - ->
The cover of the index which can be indexed by integral
Data IdxByIntList ia = (Ix i, Integral i) = & gt; IdxByIntList {getList :: [a]}
If there is an example of IdxByIntList
of list
, then i
Integral
and Ix
:
Example (Integral I, Ix i) => The list (idxByIntList i) from where = list = getList
looks like the indexed
function in the constraint (Ix i, integral i)
dissatisfied It is possible to do this in the indexed
:
example indexed IDXBIInLIS list where indexed = zip [0 ..] . GetList
but it can not be compiled because the compiler type variable i
to enum
and Num
.
Edit:
In the indexed
for IdxByIntList
, [0 ..]
Code> (name, anonymous A) which goes to zip [0 ..]
and so on and it goes to indexed
. Therefore, should be bound to indexed
(Ix I, Enum i, Num i, List (li))
but it is not.
An example of i
is
integral
, so it is an example of Num
and Enum
.
I have common barriers to all IdxByIntList
on the constraint (Ix i, list (i), integral i)
on indexed
. How can I do this?
About changing the class a bit
{- # LANGUAGE typefile # -} Import data IECS indexed Li where indexed :: li ~ li = & gt; Li-A - & gt; [(I, A)] - I - Type of index - L - Type wrapper data IDXBIINLLITI AA = IDXIILLIL {getList :: [A]} Example (Integral I, IXI) = & gt; Indexed (IdxByIntList i) where indexed = zip [0 ..]. GetList
This class creates the parameter only l
instead of l
, which may be sufficient for your use.
If you really need the do to be parametized on l
, things will be more difficult; I think you need a related family type again * - & gt; Restrictions
, which requires the constraintkinds
extensions, and becomes odd to express family examples when more than one class obstacle is involved. (I do not know that this will work satisfactorily in practice.)