question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

isJust & fromJust

See original GitHub issue

I do not see in the docs a isJust or fromJust (potential to throw but unless isJust was checked) nor isNothing. Even the pure Haskell has theme functions.

The primary importance (for me) is that values passed around are explicit but how I implement a function is not where errors arise. The fact that a value is a Maybe is obvious (or will raise obvious errors). My function should be able to deal with that logically without needing to get into callback functions (JavaScript does not even have do notation to make things at least look better). I give up compile time type safety/checking by using isJust and fromJust, but wait, JS is not statically typed anyway.

It is true I likely may never use isJust or fromJust and have the simple alternative with the other functions. But I am unwilling to start using a library without complete definitions (if I want to get a value from a Just (regardless of whether I theoretically should (even Haskell has performUnsafeIO!)) how can I do it?).

Thanks, Jonathan

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
JonathanILevicommented, Nov 10, 2019

I guess that is reasonable. They are not that hard to implement oneself.

For anyone who sees this looking for an implementation here is one:

const isJust =
    either(constant(false), constant(true))
const fromJust =
    either(Identity, ()=>{throw Error();})
1reaction
evilsoftcommented, Nov 8, 2019

@JonathanILevi Personally, I see those “theme” functions as bloat and while we use Haskell for some reference and provide some functions with the same name (fanout, fst, etc), we try not to let their choices influence what we provide in the library.

As far as your need for these functions, could you provide an example of where you would find them useful?

While it is a bummer that you feel this library is not complete without those two functions or theme functions, there are other libs out there like Sanctuary that do provide those functions and may feel more complete to you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data.Maybe - Hackage - Haskell.org
The isJust function returns True iff its argument is of the form Just _ . ... The fromJust function extracts the element out...
Read more >
fromJust - Haskell
Function: fromJust. Type: Maybe a -> a. Description: If the argument is Just, it returns the Just value, otherwise an error is produced....
Read more >
is it good choice to use the function fromJust when I know ...
isJust doesn't prove there is a value, it checks if there's a value. "Prove" in Haskell terms can be as straightforward as meaning...
Read more >
option type - "fromJust" vs. "Just =" in Haskell
What does the `forall` keyword in Haskell/GHC do? 878 · A monad is just a monoid in the category of endofunctors, what's the...
Read more >
The Haskell 1.3 Library Report: Maybe Utilities
module Maybe( isJust, fromJust, fromMaybe, listToMaybe, maybeToList, catMaybes, mapMaybe, unfoldr ) where isJust :: Maybe a -> Bool fromJust :: Maybe a ->...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found