Polymorphic seq definitely magical. You can implement seq for any particular type, but only the compiler can implement one function for all possible types [and avoid optimizing it, even if it looks non-op].
Obviously, the whole IO monad is deeply magical, like everything with concurrency and parallelism ( par , forkIO , MVar ), volatile storage, throwing and catching for exception, garbage collector and runtime statistics, etc.
IO monad can be considered as a special case of ST monad, which is also magic. (It allows truly mutable storage that requires low-level material.)
State monad, on the other hand, is completely custom user level code that anyone can write. So the monad is Cont . Various monads of exceptions / errors are also possible.
Everything related to the syntax (do-blocks, list comprehensions) is rigidly tied to the definition of the language. (Note that some of them respond to the LANGUAGE RebindableSyntax , which allows you to change which functions it binds.) Also deriving stuff; the compiler “knows about” several special classes and methods for automatically generating instances for them. However, for newtype works for any class. (It simply copies an instance from one type to another identical instance of that type.)
Arrays are hard-wired. Like any other programming language.
The entire external interface of the function is clearly hard-wired.
STM can be implemented in user code (I did this), but it is currently tightly coupled. (I believe this provides a significant performance advantage. I have not actually tried to measure it.) But, conceptually, this is just an optimization; you can implement it using existing lower level concurrency primitives.
MathematicalOrchid
source share