Shell: add assoc combinator to Data_encoding.
This commit is contained in:
parent
f42e9d12ac
commit
e80ce1e8d5
@ -147,6 +147,8 @@ val merge_tups : 'a1 encoding -> 'a2 encoding -> ('a1 * 'a2) encoding
|
||||
val array : 'a encoding -> 'a array encoding
|
||||
val list : 'a encoding -> 'a list encoding
|
||||
|
||||
val assoc : 'a encoding -> (string * 'a) list encoding
|
||||
|
||||
type 't case
|
||||
val case :
|
||||
?tag:int -> 'a encoding -> ('t -> 'a option) -> ('a -> 't) -> 't case
|
||||
|
@ -719,6 +719,10 @@ module Encoding = struct
|
||||
`Variable in
|
||||
make @@ Mu (kind, name, self)
|
||||
|
||||
let assoc enc =
|
||||
let json = Json_encoding.assoc (Json.get_json enc) in
|
||||
let binary = list (tup2 string enc) in
|
||||
raw_splitted ~json ~binary
|
||||
end
|
||||
|
||||
include Encoding
|
||||
|
@ -155,6 +155,8 @@ val merge_tups : 'a1 encoding -> 'a2 encoding -> ('a1 * 'a2) encoding
|
||||
val array : 'a encoding -> 'a array encoding
|
||||
val list : 'a encoding -> 'a list encoding
|
||||
|
||||
val assoc : 'a encoding -> (string * 'a) list encoding
|
||||
|
||||
type 't case
|
||||
val case :
|
||||
?tag:int -> 'a encoding -> ('t -> 'a option) -> ('a -> 't) -> 't case
|
||||
|
Loading…
Reference in New Issue
Block a user