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

Research and explain Boolean type #139

Closed
razcore-rad opened this issue Nov 15, 2018 · 22 comments · Fixed by #169
Closed

Research and explain Boolean type #139

razcore-rad opened this issue Nov 15, 2018 · 22 comments · Fixed by #169
Labels
enhancement New feature or request Syntax Something related to the syntax part of this repo

Comments

@razcore-rad
Copy link
Contributor

Context

  1. Indicate the affected section (i.e. top-level folder)
    I'm not sure where it would go

  2. Indicate what kind of issue this is
    Enhancement = a new idea that can be documented/filed

  3. If it applies, indicate the file to which you are referring using non-numerical-ordering names

Body

As it stands, purescript has a Boolean type with true & false values. Beginners such as myself, especially ones coming from haskell where there's the data Bool = True | False definition, might wonder where's True & False in purescript. Or why they're not present. I don't know the full history behind it but I assume it has to do with purescript being so tightly linked with javascript. It can definitely be a point of confusion as one would expect all constructors to start with a capital letters and this being such a simple data type one wouldn't expect literal values for it, or at least it's a bit of a discord compared to basic types.

@JordanMartinez
Copy link
Owner

psc-package is originally phil and others' project

Yeah... that's a good question 😅 Haha!

I'm coming from a Java background and the true/false values are lower-cased. So, this issue could be solved in one of two ways:

  • Add a "Differences from Haskell" file
  • Explain how the Javascript backend influenced the syntax of the language (Technically, PureScript could compile to C and Swift depending on which backend one uses.)

I think I like the 'Haskell Differences' idea better because it's the only language I know of that uppercases the true/false values.

Thoughts?

@thomashoneyman
Copy link

@JordanMartinez
Copy link
Owner

@thomashoneyman True. I can't recall whether I'd already linked to that specific page or not (I'm guessing not). However, this particular issue can either be solved by updating that repo's page to include that True/False difference or we restate it here. Either way splits the content into two places.

@JordanMartinez JordanMartinez added enhancement New feature or request Syntax Something related to the syntax part of this repo labels Nov 16, 2018
@razcore-rad
Copy link
Contributor Author

razcore-rad commented Nov 16, 2018

I don't think you linked to the differences, at least I can't remember either. I think we should update that repo's page + offer a short javascript influence explanation in this repo which would talk about why such a simple data type would need literal values instead of the regular constructors.

@JordanMartinez
Copy link
Owner

Either way, we should link to that page. My question is, where should that link ideally appear? In the Getting Started folder, I presume?

offer a short javascript influence explanation in this repo which would talk about why such a simple data type would need literal values instead of the regular constructors.

Seems like there should be a Backends section/folder, perhaps in the Getting Started folder.

@razcore-rad
Copy link
Contributor Author

I think the Backends idea is fine, placed in Getting Started. If you think you want to roll your own 2cents about the literal values true/fasle I think those might be better off in Syntax.

@JordanMartinez
Copy link
Owner

@razcore-art Would you be willing to submit a PR that includes a small snippet for Haskellers in the Syntax part that explains Boolean's quirk? I'll submit a separate PR that includes the link to the Differences from Haskell page, though if you want to include that in a PR, go for it. I was going to put it in its own section in the Getting Started/Other Imporant Info.md.

@razcore-rad
Copy link
Contributor Author

razcore-rad commented Nov 17, 2018 via email

@JordanMartinez
Copy link
Owner

you know you're giving this task to a total beginner

And...? Haha! This whole repo is my understanding of PureScript, any and all of which could be wrong, haha! If you happen to contribute something that is wrong, you're in good company. We can learn together.

Still, I don't think this particular issue is that difficult. You're basically saying, "In Haskell, you write True and in PureScript, you write true. Why? Because of the influence of Javascript. Why not change it? Because backwards compatibility and ecosystem stability, etc."

I can link with Purescript differences from Haskell as well.

Ok, thanks!

@razcore-rad
Copy link
Contributor Author

some notes on research:

a bit of confusion, seems like I'm not the only one: purescript/purescript#842, especially this comment purescript/purescript#842 (comment)
in essence: built-in types aren't ADTs and so it follows they don't have constructors in the regular FP style
explanation in purescript by example: https://leanpub.com/purescript/read#leanpub-auto-simple-types
prim module: https://pursuit.purescript.org/builtins/docs/Prim#t:Boolean - not much explanation, just that we use true/false literal values

@JordanMartinez
Copy link
Owner

some notes on research:

Mm... that makes a lot more sense.

Rather than using Boolean as the example type that help teach type-level programming's syntax, what if we used a type that works just like Boolean but gets around this suprising-capitalization-syntax issue: YesNo?

@razcore-rad
Copy link
Contributor Author

YesNo is good

@JordanMartinez
Copy link
Owner

Mind submitting a PR that changes that?

@razcore-rad
Copy link
Contributor Author

I can take care of that sure.

@JordanMartinez
Copy link
Owner

@razcore-art Thanks! And just to make sure this gets done instead of turning into
a "yeah I'll submit a PR. *1 year passes w/o a PR*," I'll wait for a week. If it's not done by then, I'll do it.

@razcore-rad
Copy link
Contributor Author

Yes, that's acceptable :)

@JordanMartinez
Copy link
Owner

I've linked to the documentation repo and also a PDF that I also found quite helpful and descriptive (see #156). What are the next actions for this issue?

@razcore-rad
Copy link
Contributor Author

Your low maintenance work on this repo is far more active than I initially thought :). Yes, I just need to explain in writing why purescript Boolean uses literal true/false values rather than True/False constructors and we'll be good to close this issue. I'll get to it today

@JordanMartinez
Copy link
Owner

Perhaps I should define "low maintenance": if it requires me to do additional work for a new release each time (e.g. something more than submit development PR on latestRelease branch, summarize new changes, define new tag and release on GH), then it's no longer low maintenance.

If it's fixing bugs or adding new content, I just consider that learning.

I'll get to it today

Excellent!

@razcore-rad
Copy link
Contributor Author

Well I didn't get to it that day :) but I'm getting to it right now

@AntC2
Copy link

AntC2 commented Dec 3, 2021

You may simply want to link to this: https://github.com/purescript/documentation/blob/master/language/Differences-from-Haskell.md

Looks like nobody did mention true/false vs True/False on that page. That would have saved me some consternation, coming from Haskell.

The world doesn't seem to have blown up if I declare

data Bool = False | True
derive instance eqBool :: Eq Bool 
derive instance ordBool :: Ord Bool 

And a Show instance; and some conversion functions.

@JordanMartinez
Copy link
Owner

Can you open an issue on the documentaiton repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Syntax Something related to the syntax part of this repo
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants