Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file user.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133(*
* Copyright (c) 2013-2017 Thomas Gazagnaire <thomas@gazagnaire.org>
* and Romain Calascibetta <romain.calascibetta@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)typetz_offset={sign:[`Plus|`Minus];hours:int;minutes:int}typet={name:string;email:string;date:int64*tz_offsetoption}letpp_signppf=function|`Plus->Fmt.pfppf"`Plus"|`Minus->Fmt.pfppf"`Minus"letpp_tz_offsetppf{sign;hours;minutes}=Fmt.pfppf"{ @[<hov>sign = %a;@ hours = %02d;@ minutes = %02d;@] }"(Fmt.hvboxpp_sign)signhoursminutesletppppf{name;email;date=n,tz_offset}=Fmt.pfppf"{ @[<hov>name = %s;@ email = %s;@ date = %a;@] }"nameemail(Fmt.hvbox(Fmt.pairFmt.int64(Fmt.optionpp_tz_offset)))(n,tz_offset)moduleMake(Meta:Encore.Meta.S)=structtypee=topenHelper.BaseIsomoduleIso=structopenEncore.Bijectionlettz_offset=make_exn~fwd:(fun(sign,hours,minutes)->ifhours=0&&minutes=0thenNoneelseSome{sign;hours;minutes})~bwd:(function|Some{sign;hours;minutes}->sign,hours,minutes|None->`Plus,0,0)letuser=make_exn~fwd:(fun(name,email,time,date)->{name;email;date=time,date})~bwd:(fun{name;email;date=time,date}->name,email,time,date)endmoduleMeta=Encore.Meta.Make(Meta)openEncore.BijectionopenMetatype'at='aMeta.tletis_not_ltchr=chr<>'<'letis_not_gtchr=chr<>'>'letis_digit=function'0'..'9'->true|_->falseletdate=letsign=make_exn~fwd:(function|'+'->`Plus|'-'->`Minus|_->Exn.fail())~bwd:(function`Plus->'+'|`Minus->'-')<$>anyinletdigit2=make_exn~fwd:(function|('0'..'9'asa),('0'..'9'asb)->Char.(((codea-48)*10)+(codeb-48))|_,_->Exn.fail())~bwd:(funn->leta,b=n/10,nmod10inChar.chr(a+48),Char.chr(b+48))<$>(any<*>any)inExn.composeobj3Iso.tz_offset<$>(sign<*>digit2<*>digit2)letchop=make_exn~fwd:(funs->String.subs0(String.lengths-1))~bwd:(funs->s^" ")letp=Exn.composeobj4Iso.user<$>(chop<$>(while1is_not_lt<*(char_elt'<'<$>any))<*>(while1is_not_gt<*(string_elt"> "<$>const"> "))<*>(int64<$>while1is_digit<*(char_elt' '<$>any))<*>date)endmoduleA=Make(Encore.Proxy_decoder.Impl)moduleM=Make(Encore.Proxy_encoder.Impl)moduleD=Helper.MakeDecoder(A)moduleE=Helper.MakeEncoder(M)letlengtht=letstringx=Int64.of_int(String.lengthx)inlet(+)=Int64.addinlettz_offset_length=5Linstringt.name+1L+1L+stringt.email+1L+1L+string(Int64.to_string(fstt.date))+1L+tz_offset_lengthletequal=(=)letcompare=Stdlib.comparelethash=Hashtbl.hashmoduleSet=Set.Make(structtypenonrect=tletcompare=compareend)moduleMap=Map.Make(structtypenonrect=tletcompare=compareend)