I am new to Haskell and to its semantics. I learned that not every function can be mapped to an object. For instance:
square :: Int -> Int
square x = x*x
The value of square is mapped to the math object. However, for any non-terminating function, we map it to a special math value ⊥. I want to know what will happen if I have to do calculation with this undefined value. For instance, I have a set of numbers Z⊥ ={⊥, 1,0,-1}. What will be the output if I multiply ⊥ with 1? Since, the type of ⊥ will be undefined, am I able to do multiplication with a well defined type? Since, ⊥ is in the domain of Z⊥, I guess I can do the multiplication. But, then it will have to return ⊥! I would like to have some guidance regarding it!
The multiplication will also return
⊥. It behaves exactly like you described; any computation that depends on the⊥value will also yield⊥.The bottom value is an inhabitant of every type, and is thus an implicit member of every value set and cannot be excluded by types (Except by using GHC internal primitives). The reason for the existence of this special value is to make it possible to argue about the Halting Problem in Haskell; without this value, the compiler would have to be able to prove that a certain computation terminates in order for it to type-check, and this is generally not possible.