この記事はメモ書きです。 どうも、自分のブログの脱WordPress化を画策しているmod_poppoです。 今日は、WordPressのREST APIを叩いてデータを取ってみたいと思います。APIのマニュアルはこの辺にあり、例えば とすると直近10件くらいの投稿が取得できます。 JSON WordPressのREST APIのレスポンスはJSONで帰ってきます。これをいい感じにHaskellのデータ型にマップしたいです。 最初は自分でデータ型を定義して Generic で FromJSON / ToJSON のインスタンスを定義しようとしたのですが、フィールド名のアレが面倒なのでやめました。代わりに extensible を使います。 extensible を使うと、投稿を表すデータ型が次のように定義できます。各フィールドにアクセスするには Lens と OverloadedLabel