Efficient string processing String :: [Char] is not efficient, every element is allocated individually and has bookkeeping overhead. Even programs write in interpreted languages can outperform H...
Real World Haskell 07: IO
Classical IO <- binds the result from executing an IO action to a name -- can run the program with runghc (run the script without compiling) main = do putStrLn "Hello, what's yo...
Real World Haskell 06: Typeclasses
Definition allow to define generic interfaces that provide a common feature set over a wide variety of types define a set of functions that can have different implementations depending on the ...
Real World Haskell 05: Work with JSON data
General :reload remembers the last loaded file ghc -c SimpleJSON.hs compiles the source file and only generates the object code (-c), the source file must have main function (the start of the ...
Real world haskell 04: Functional programming
General compile one haskell file with ghc -make <file-name.hs>, the file must contain a main function, then use ./<file-name> <args> to run it functions that have only return...
Real World Haskell 03: Pattern matching
Define new data types data BookInfo = Book Int String [String] deriving (Show) -- tack Show on a type declaration so that ghci know how to a value of this type myIn...
Real World Haskell 02: Types and functions
Major features why need type systems: introduce abstraction, ignore implementation details strong an ill typed expression will raise a type error at compile time no implicit c...
Real World Haskell 01: Getting started
Major features pure functions: take immutable values as input and produce new values as output laziness: defer every computation until its result is actually required, e.g., -- fi...
Scaling issue with Nvidia Ubuntu
Problem My laptop has a 4k screen and it has a Nvidia GPU and an integrated GPU, I want to conect to an external 1080p monitor via HDMI. The external monitor is recognized via xrandr and arandr, b...
Stochastic superoptimization
This post is a note of this paper. Introduction This paper formulates the loop-free assembly code optimization task as a stochastic search problem. It encodes the correctness and performance con...