ekmett / adjunctions

Simple adjunctions
http://hackage.haskell.org/package/adjunctions
Other
44 stars 27 forks source link

instance Representable f => Representable (Reverse f)? #25

Closed Icelandjack closed 8 years ago

Icelandjack commented 8 years ago

Is there a valid Representable instance for Reverse?

instance Representable f => Representable (Reverse f) where
  type Rep (Reverse f) = Rep f
  tabulate = Reverse . tabulate
  index (Reverse f) i = index f i

gives the same result for these two expressions

>>> (!) = index; infixl 6 ! 
>>> V3 'x' 'y' 'z' ! E _x
'x'
>>> Reverse (V3 'x' 'y' 'z') ! E _x
'x'
Icelandjack commented 8 years ago

I was toying around with defining a queue as Product V3 (Reverse V3).

RyanGlScott commented 8 years ago

Sounds reasonable to me.