"No operation" haskell

If I remember correctly from school, there is a function or keyword that is used for "not yet implemented," but a compilation of code. I tried to find it, but I can not find it. Does anyone know what I'm looking for?

- it's something like

isDivisor :: Integer -> Integer -> Bool isDivisor xy = None --isDivisor xy = (rem xy) == 0 
+7
source share
1 answer

What you think is called bottom

bottom is not just an indication that something is not implemented, it is intended to represent the calculation that makes our program fail.

For example, we can actually define undefined ourselves as an infinite loop.

 undefined = let x = x in x undefined = undefined 

So what we really do is simply enter an undefined :: a value that will cause or program a failure or loop forever, but never evaluates it.

Therefore, if you have a large and complex function that you do not know how to implement, you can just do it

 foo :: Bar -> Baz -> Quux foo bar baz = foo bar baz 

Since this is typechecks, it will compile and we can test other parts of our program.

However, since you accidentally run this part of the program, it is pretty useless to have an infinite loop, GHC and others implement undefined otherwise. They force them to crash the program and give an error message, for example:

 -- In GHC error msg = throw (ErrorCall s) undefined = error "Prelude.undefined" 

So, to leave the function undefined with better debugging capabilities

 foo bar baz = undefined foo bar baz = error ("Tried to evaluate foo with" ++ show bar ++ show baz) 

If you find the concept of confusion, hammar posted a great answer

+8
source

All Articles