Hacker News new | ask | show | jobs
by qb45 4807 days ago
Another story is that you may end up with something like:

  Just x -> something x
  Nothing -> halt_and_catch_fire  # impossible
In Haskell there is even a standard library function fromJust which does exactly that.

One introduces this hack knowing that this particular variable will always be Just and having absolutely no way to deal with Nothing and later somebody else sees the type Maybe Foo and figures that it must be OK to put a Nothing in there.

1 comments

Well, assuming "halt_and_catch_fire" is something like error foo or undefined, you're essentially going out of your way to circumvent the type system. It's possible to do it, but it's frowned upon.