将我的评论与@ForestPhoenix 的回答结合起来:
Opaleye 允许您在运行查询时转换Column PGInt8
为。Int64
这意味着它还允许您转换Column (Nullable PGInt8)
为Maybe Int64
.
您正在包装Column (Nullable PGInt8)
新Key'
类型(为了类型安全),它为您提供Key' (Column (Nullable PGInt8))
. 这意味着当您运行查询时,您需要将其读取为Key' (Maybe Int64)
.
或许这张小表让对应关系更清晰:
Opaleye side | Haskell side
----------------------------- | -------------
Column PGInt8 | Int64
Column (Nullable PGInt) | Maybe Int64
Key' (Column (Nullable PGInt) | Key' (Maybe Int64)
一般来说:
Opaleye side | Haskell side
------------------------------- | -------------
Column o | h
Column (Nullable o) | Maybe h
MyNewype' (Column (Nullable o)) | MyNewType' (Maybe h)