在尝试解码更大的 json 值时,我在Json-Decode-Extra
库中遇到了以下代码。(位于此处)
import Date (Date)
type alias User =
{ id : Int
, createdAt : Date
, updatedAt : Date
, deletedAt : Maybe Date
, username : Maybe String
, email : Maybe String
, fullname : Maybe String
, avatar : Maybe String
, isModerator : Bool
, isOrganization : Bool
, isAdmin : Bool
}
metaDecoder : (Int -> Date -> Date -> Maybe Date -> b) -> Decoder b
metaDecoder f = f
`map` ("id" := int)
`apply` ("createdAt" := date)
`apply` ("updatedAt" := date)
`apply` ("deletedAt" := maybe date)
userDecoder : Decoder User
userDecoder = metaDecoder User
`apply` ("username" := maybe string)
`apply` ("email" := maybe string)
`apply` ("fullname" := maybe string)
`apply` ("avatar" := maybe string)
`apply` ("isModerator" := bool)
`apply` ("isOrganization" := bool)
`apply` ("isAdmin" := bool)
但是,我经常遇到:=
操作员的编译器错误。这是在哪里定义的?JSON 解码教程不会在任何地方显式导入此运算符。