Advanced types and FFI

The type system of Haskell goes further than a signature of one arrow, and these twelve lessons use it: GADTs, type families, rank-N types, the existential, kinds and DataKinds, the deriving strategies and DerivingVia. The last lessons cross the boundary to C: foreign import ccall, foreign export, the shared library a C driver calls, and the same library read from Python. A parser closes the part.

082 GADTs data ... where, a constructor with a refined result type, a typed expression Open 083 Type families a type family, an associated type, an instance per type, TypeFamilies Open 084 Rank-N types forall inside a type, RankNTypes, a function that takes a polymorphic argument Open 085 Existential types forall a. in a constructor, a heterogeneous list, the operation it keeps Open 086 Kinds and DataKinds :kind, a kind signature, promoted constructors, a phantom that carries units Open 087 Deriving strategies deriving stock, newtype and anyclass, GeneralizedNewtypeDeriving, what each one means Open 088 DerivingVia deriving via, a newtype wrapper with a shared instance, DerivingVia Open 089 Phantom types a type parameter that carries no value, a checked transition, DataKinds with it Open 090 Calling C from Haskell foreign import ccall, a C function, Ptr, CString, the link line Open 091 Being called from C foreign export ccall, a shared library, a C driver, the stable pointer question Open 092 Calling Haskell from Python the same shared library through ctypes, a measured call, the string lifetime Open 093 Parsing with parsec Parser, parse, char, string, many, a small grammar, the error position Open

Lessons