How is low level stuff like sockets, pipes and file IO implemented in Haskell? I guess these IO methods are not native in Haskell but Haskell quickly wraps some low level C library, is it right?
Sockets, pipes and files are implemented in the kernel; to use them from a user-space program, you need to call into the kernel. If you regard the kernel as a library, then yes, I/O is necessarily implemented by a low-level C/assembler library.
In practice, Haskell implementations such as GHC will use the C library's wrappers around system calls. See e.g. the GHC RTS commentary, which describes the bits of C that make up the core of any Haskell program compiled with GHC. When in doubt, consult the source code.
"quickly wraps" isn't always the best description here.
You could argue that because GHC's runtime system is written in C and your OS was probably written in C, Haskell is a wrapper around C, but that's like saying a Spyker C8 car wraps an Audi V8 engine. Spyker might be upset if you called their lovely C8 a box with an Audi in it. When you're driving your car you're using an engine, but not directly. Some people like to tweak their car, just like some people like to overclock their CPU, but you don't have to unless you want to. Some people say you should know how the engine works if you want to understand your car.
If you can forgive the Formula 1 references, mainly Haskell "wraps" C like a Torro Rosso wraps a Ferrari, but occasionally it's like a Maclaren wraps a Mercedes. (Before you call a Torro Rosso slow, compare it to a Ford.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With