purescript-typelevel-prelude
purescript-typelevel-prelude copied to clipboard
Feature Request: Symbol Reverse
class Reverse (s :: Symbol) (r :: Symbol) | s -> r, r -> s
instance reverseNil :: Reverse "" ""
else instance reverseCons :: (Symbol.Cons h t s, Reverse t u, Symbol.Append u h r) => Reverse s r
This implementation doesn't appear to be bidirectional:
Forwards:
eg1 :: Unit
eg1 = unit :: forall t . Reverse "Apple" t => Warn (Text t) => Unit
-- A custom warning occurred while solving type class constraints:
-- elppA
Backwards:
eg2 :: Unit
eg2 = unit :: forall t . Reverse t "Banana" => Warn (Text t) => Unit
-- No type class instance was found for
-- Prim.Symbol.Cons t0 t1 t2
The issue is that Append requires at least two arguments to work out the third.
Yeah suppose so. I'll share the more elaborate implementation when I am able.
See #51