-
Notifications
You must be signed in to change notification settings - Fork 87
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
add undefined
to Prelude
#44
Comments
+1, I've been noticing myself doing different hacks like short-circuiting a function to get things compile, because of the lack of |
👎 for it being in the prelude, it's about the most unsafe function you can have so it definitely shouldn't be commonly imported - we try to avoid providing partial functions anywhere aside from The only way I would be in favour of having this is if we included some kind of compiler hack so that there was an error thrown at the end of compilation if it was used, or for the generated runtime code to throw an error immediately (during initialisation) if the value is used. |
I mostly feel the same way. But Maybe the best solution would just be to make my own Prelude. |
Yeah, it's definitely super useful. I've written Supporting it natively in the compiler is my preference really, not sure what @paf31 thinks about that though? Alas we probably can't use |
Actually I guess |
Something that did this would be really nice. Something along the same lines is that |
👎 I'd much rather this were supported in a custom prelude, or in the compiler as a variation on typed holes. In either case, strictness is going to be an issue. |
How so? I think compilation should fail when a hole is present, just after all the other work is done so you know it would compile if the hole had an implementation. |
Ah, I was thinking it would be a warning like type wildcards (and ideally implemented using type wildcards). |
Yeah, that's what I had in mind too - it desugars into something like Even without the error it would be better than what we have now, but people don't necessarily always pay too much attention to warnings... especially when we have tons to fix in the core libraries. I get something like 400 warnings when building |
So can we close this, if we've decided we'd rather do it inside the compiler? That is, purescript/purescript#1283 |
Either way, I don't think it belongs in Prelude. A single-definition |
* first commit * Fix instances for record fields * Break modules up * Deriving Show (#5) * Initial work on deriving Show * Add test for Show * Remove import * Travis etc. * Data.Generic.Rep.Bounded (#6) * Data.Generic.Rep.Bounded Generic implementations of Prelude.Bounded class's top and bottom. * GenericBounded - don't support product types * GenericBounded - only support NoArguments * Update for PureScript 0.11 * Add Generic instance for Maybe (#9) * Add missing Bounded instances for Argument * Add GenericEnum and GenericBoundedEnum * Add enum tests, convert existing "tests" into assertions * Product instances in Bounded and Enum * Added GenericShowFields instances for NoConstructors and NoArguments (#20) * Added Eq and Show instances to NoArguments and NoConstructors * Added GenericShowFields * Removed Show, Eq * Cleanup * Removed NoConstructors Show instance * Remove Rec and Field & update package & bower symbols * Bump deps for compiler/0.12 * Remove symbols and fix operator fixity issue * Update dependencies, license * Added HeytingAlgebra, Semiring, Ring * Fix type annotation precedence in tests * Replace monomorphic proxies by Type.Proxy.Proxy (#44) * Remove Generic Maybe instance * Remove Generic Enum from src and test * Move all files to their correct folders and rename files to Generic.purs * Update module names to match their file names * Move test file for Data.Generic.Rep into proper folder and rename * Update generic-rep test file module to match file path * Rename generic-rep test name to testGenericRep * Replace generic Show's Foldable.intercalate usage with FFI * Replace Tuple with Pair in Data.Generic.Rep tests * Remove Maybe import from Data.Generic.Rep test file * Remove Maybe import from Data.Generic.Rep * Extract AlmostEff and assert to Test.Utils.purs file * Update Data.Generic.Rep tests to use AlmostEff; include it in main tests * Import implies in Data.Generic.Rep tests Co-authored-by: Phil Freeman <paf31@cantab.net> Co-authored-by: Matthew Leon <ml@matthewleon.com> Co-authored-by: Gary Burgess <gary.burgess@gmail.com> Co-authored-by: Liam Goodacre <goodacre.liam@gmail.com> Co-authored-by: Jorge Acereda <jacereda@gmail.com> Co-authored-by: Kristoffer Josefsson <kejace@gmail.com> Co-authored-by: Denis Stoyanov <stoyanov.gr@gmail.com> Co-authored-by: Harry Garrood <harry@garrood.me> Co-authored-by: Cyril <sobierajewicz.cyril@gmail.com>
* first commit * Fix instances for record fields * Break modules up * Deriving Show (#5) * Initial work on deriving Show * Add test for Show * Remove import * Travis etc. * Data.Generic.Rep.Bounded (#6) * Data.Generic.Rep.Bounded Generic implementations of Prelude.Bounded class's top and bottom. * GenericBounded - don't support product types * GenericBounded - only support NoArguments * Update for PureScript 0.11 * Add Generic instance for Maybe (purescript#9) * Add missing Bounded instances for Argument * Add GenericEnum and GenericBoundedEnum * Add enum tests, convert existing "tests" into assertions * Product instances in Bounded and Enum * Added GenericShowFields instances for NoConstructors and NoArguments (purescript#20) * Added Eq and Show instances to NoArguments and NoConstructors * Added GenericShowFields * Removed Show, Eq * Cleanup * Removed NoConstructors Show instance * Remove Rec and Field & update package & bower symbols * Bump deps for compiler/0.12 * Remove symbols and fix operator fixity issue * Update dependencies, license * Added HeytingAlgebra, Semiring, Ring * Fix type annotation precedence in tests * Replace monomorphic proxies by Type.Proxy.Proxy (purescript#44) * Remove Generic Maybe instance * Remove Generic Enum from src and test * Move all files to their correct folders and rename files to Generic.purs * Update module names to match their file names * Move test file for Data.Generic.Rep into proper folder and rename * Update generic-rep test file module to match file path * Rename generic-rep test name to testGenericRep * Replace generic Show's Foldable.intercalate usage with FFI * Replace Tuple with Pair in Data.Generic.Rep tests * Remove Maybe import from Data.Generic.Rep test file * Remove Maybe import from Data.Generic.Rep * Extract AlmostEff and assert to Test.Utils.purs file * Update Data.Generic.Rep tests to use AlmostEff; include it in main tests * Import implies in Data.Generic.Rep tests Co-authored-by: Phil Freeman <paf31@cantab.net> Co-authored-by: Matthew Leon <ml@matthewleon.com> Co-authored-by: Gary Burgess <gary.burgess@gmail.com> Co-authored-by: Liam Goodacre <goodacre.liam@gmail.com> Co-authored-by: Jorge Acereda <jacereda@gmail.com> Co-authored-by: Kristoffer Josefsson <kejace@gmail.com> Co-authored-by: Denis Stoyanov <stoyanov.gr@gmail.com> Co-authored-by: Harry Garrood <harry@garrood.me> Co-authored-by: Cyril <sobierajewicz.cyril@gmail.com>
When I'm programming in Haskell, I often use
undefined
to get code compiling when I am just fleshing out an api/type signatues.For instance, when doing something like authentication, I might write the following code:
At first, I don't want to worry about how to write the
auth
andcheckEmailAndPassword
functions, so I leave them asundefined
. After making sure the types line up and code compiles, I take out theundefined
, and fill in the appropriate code.I end up wanting
undefined
so often that I think it should go into the Prelude.However, there are some downsides to putting it into the prelude:
unsafeCompare
and division by 0.The text was updated successfully, but these errors were encountered: