What IO activity does the GHC IO manager support?

Any file descriptor that can be managed by epoll/kqueue is eligible. Libraries that want asynchronous treatment of I/O need to cooperate with the I/O manager by making file descriptors non-blocking, and calling the threadWaitRead and threadWaitWrite functions in GHC.Conc before retrying a system call that previously returned EWOULDBLOCK. This has already been done for the … Read more

Installing ghc binaries on Linux (can’t find libgmp.so)

You either add /usr/local/lib and/or /usr/local/lib64 to $LD_LIBRARY_PATH, or add them to /etc/ld.so.conf, or (since you already have /usr/lib64/libgmp.so.3) add a missing symbolic link: cd /usr/lib64 sudo ln -s libgmp.so.3 libgmp.so (and perhaps the same for /usr/lib). Note that /usr/lib64/libgmp.so.3 might be a different version from /usr/local/lib64/libgmp.so, make sure ghc can actually be used with … Read more

Can a `ST`-like monad be executed purely (without the `ST` library)?

tl;dr: It’s not possible without adjustments to the definition of PT. Here’s the core problem: you’ll be running your stateful computation in the context of some sort of storage medium, but said storage medium has to know how to store arbitrary types. This isn’t possible without packaging up some sort of evidence into the MkRef … Read more

Get evaluation timings in GHCi

If you enter :set +s in GHCi, then timing and memory info will be printed after the evaluation of every expression. Example: Prelude> :set +s Prelude> sum [1..2^20] 549756338176 it :: (Num a, Enum a) => a (0.34 secs, 169,197,008 bytes) Note that this will be the timing of the expression as evaluated in the … Read more

How can I disable Haskell warning in small block?

No, you can’t currently in GHC 9.2.1. The {-# OPTIONS_GHC #-} pragma is file-header only and applies to the whole module. And there are no such pragmas (or other ways) to suppress warnings in specific locations. You can check the full list of pragmas in the Haskell user guide: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas The list of warnings might … Read more

Distributing a Haskell program as C source

I’m interested in being able to write portions of programs in C and Haskell, and then distributing it as a tarball, but without requiring the target to have GHC and Cabal installed. You’re asking for an awful lot of infrastructure that you’re unlikely to find. Remember that any Haskell program, even if it is going … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)