purescript-contrib / purescript-profunctor-lenses

Pure profunctor lenses
MIT License
144 stars 52 forks source link

Update Array inside Array #22

Closed user471 closed 8 years ago

user471 commented 8 years ago
x :: Array (Array Int)
x = [[1,2,3]] # ix 0 <<< ix 2 .~ 11
  No type class instance was found for

    Data.Lens.Index.Index (Array (Array Int))
                          Int
                          _0

  The instance head contains unknown type variables. Consider adding a type annotation.

I created this function aix

aix :: forall a. Int -> TraversalP (Array a) a
aix n = ix n
x = [[1,2,3]] # aix 0 <<< aix 2 .~ 11

Is there any better workaround?

garyb commented 8 years ago

I don't think so, until we have functional dependencies. The Index class needs a a -> b fundep so that the index can be determined by the type.

LiamGoodacre commented 8 years ago

Can be closed now that Index has the appropriate fundep?

garyb commented 8 years ago

Indeed! Thanks for the reminder.