gigobyte / purify

Functional programming library for TypeScript - https://gigobyte.github.io/purify/
ISC License
1.5k stars 58 forks source link

Make Pattern Follow TypeScript Naming Scheme #626

Closed czhang03 closed 1 year ago

czhang03 commented 1 year ago

Hi I noticed most of the pattern here (EitherPattern, MaybePattern, etc) follows haskell style naming scheme. However by default TypeScript recommend to use camelCase for fields in an object.

I was wondering it is possble to create a overloaded version of caseOf that use naming scheme that is recommended by TypeScript, like:

someMaybe.caseOf({
  nothing: () => ...
  just: (val) => ...
})
gigobyte commented 1 year ago

I don't like overloads, in this case it's purely cosmetical and the caseOf method has been stable since the creation of the library, I don't think this change is worth it.

czhang03 commented 1 year ago

Sorry, I should have mentioned the use case the this. I use eslint with my project, hence I need to silence all the lines with caseOf if I want to enforce the naming scheme.

There is no good way around it, as I cannot simply disable or change the recommended rule, since I do want my other classes to have consistent naming.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Stanislav Iliev @.> Sent: Tuesday, March 7, 2023 4:15:33 AM To: gigobyte/purify @.> Cc: Cheng Zhang @.>; Author @.> Subject: Re: [gigobyte/purify] Make Pattern Follow TypeScript Naming Scheme (Issue #626)

I don't like overloads, in this case it's purely cosmetical and the caseOf method has been stable since the creation of the library, I don't think this change is worth it.

— Reply to this email directly, view it on GitHubhttps://github.com/gigobyte/purify/issues/626#issuecomment-1457818497, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACNCCAZLUPKOHOWOSJNP3R3W234DLANCNFSM6AAAAAAVRV5QFM. You are receiving this because you authored the thread.Message ID: @.***>

czhang03 commented 1 year ago

But I guess I can always just modify the prototype in my own project if you are not happy with this change.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Cheng Zhang @.> Sent: Tuesday, March 7, 2023 7:16:18 AM To: gigobyte/purify @.>; gigobyte/purify @.> Cc: Author @.> Subject: Re: [gigobyte/purify] Make Pattern Follow TypeScript Naming Scheme (Issue #626)

Sorry, I should have mentioned the use case the this. I use eslint with my project, hence I need to silence all the lines with caseOf if I want to enforce the naming scheme.

There is no good way around it, as I cannot simply disable or change the recommended rule, since I do want my other classes to have consistent naming.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Stanislav Iliev @.> Sent: Tuesday, March 7, 2023 4:15:33 AM To: gigobyte/purify @.> Cc: Cheng Zhang @.>; Author @.> Subject: Re: [gigobyte/purify] Make Pattern Follow TypeScript Naming Scheme (Issue #626)

I don't like overloads, in this case it's purely cosmetical and the caseOf method has been stable since the creation of the library, I don't think this change is worth it.

— Reply to this email directly, view it on GitHubhttps://github.com/gigobyte/purify/issues/626#issuecomment-1457818497, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACNCCAZLUPKOHOWOSJNP3R3W234DLANCNFSM6AAAAAAVRV5QFM. You are receiving this because you authored the thread.Message ID: @.***>

gigobyte commented 1 year ago

Yes, of course, you can use the information in this thread on how to extend/modify the modules: https://github.com/gigobyte/purify/issues/623