[Haskell-cafe] api-tools questions

Karsten Gebbert k at ioctl.it
Tue Sep 9 15:20:22 UTC 2014


Excellent, thanks a lot Adam. I'll open a PR when I'm through with this
project :)

Adam Gundry <adam at well-typed.com> writes:

> Hi Karsten,
>
> This isn't very well documented, but there is a (hidden) feature of
> api-tools that should do what you want. If you say something like
>
>     mt :: MyTime = basic string with inj_MyTime, prj_MyTime
>
> then you can define your own type MyTime and give conversion functions
> inj_MyTime and prj_MyTime to convert back and forth from a
> newtype-wrapped Text. (In fact, you could probably use UTCTime as
> MyTime...). More precisely, api-tools will generate something like
>
>     newtype REP__MyTime = REP__MyTime Text
>
> and you will need to implement
>
>     inj_MyTime :: REP__MyTime -> ParserWithErrs MyTime
>     prj_MyTime :: MyTime -> REP__MyTime
>
> I hope this helps, and further questions or documentation contributions
> are very welcome!
>
> Cheers,
>
> Adam
>
>
> On 09/09/14 14:02, Karsten Gebbert wrote:
>> Hi All,
>> 
>> I have a question concerning the api-tools package.
>> 
>> Its not clear from the tests, sources or the tutorial how I can use
>> other date/time formats that the default `utc` type can handle. I'm
>> trying to wrap a JSON API that is not under my control, so I have to
>> adhere to whatever I get back from it. Could anybody with experience
>> with the package point me to some example, relevant bits in the sources
>> or a tip how to do it?
>> 
>> I'm planning to create some more documentation around the package to
>> contribute back once I figured out a few more details, because I think
>> its quite a useful abstraction when dealing with (foreign) APIs IMO.
>> 
>> Thanks already for any hints,
>> 
>> karsten
>
>
> -- 
> Adam Gundry, Haskell Consultant
> Well-Typed LLP, http://www.well-typed.com/


More information about the Haskell-Cafe mailing list