Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Symbol Reverse #40

Open
eric-corumdigital opened this issue Oct 25, 2018 · 3 comments
Open

Feature Request: Symbol Reverse #40

eric-corumdigital opened this issue Oct 25, 2018 · 3 comments
Labels
type: enhancement A new feature or addition.

Comments

@eric-corumdigital
Copy link

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
@LiamGoodacre
Copy link
Member

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.

@eric-corumdigital
Copy link
Author

Yeah suppose so. I'll share the more elaborate implementation when I am able.

@JordanMartinez
Copy link
Contributor

See #51

@JordanMartinez JordanMartinez added the type: enhancement A new feature or addition. label Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A new feature or addition.
Projects
None yet
Development

No branches or pull requests

3 participants