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

Map Parser's UserState type #63

Open
3Rafal opened this issue Dec 14, 2020 · 0 comments
Open

Map Parser's UserState type #63

3Rafal opened this issue Dec 14, 2020 · 0 comments

Comments

@3Rafal
Copy link

3Rafal commented Dec 14, 2020

Hello,
I've found a curious case, which I don't know how to solve. I wonder if I'm missing some obvious solution.

Let's say that I have a type

type UserState =
  { Sub1: Substate1
    Sub2: Substate2 }

And I have a parser of type

let parseWithSub1 : Parser<'a,Substate1> =
  // Implementation...

Is there a posibility to map this state, so that I can use it like

let parseWithUserState : Parser<'a,UserState> =
  mapUserState (fun x -> x.Sub1) parseWithSub

where mapUserState would be a hypothetical function of signature ('u1 -> 'u2) -> Parser<'a,'u1> -> Parser<'a,'u2>?

@3Rafal 3Rafal changed the title Map parser userstate type Map Parser's UserState type Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant