11566
Progress Journals & Experimental Routines / Re: ADARQ's journal
« on: May 26, 2016, 05:03:13 pm »
that code-generation library I wrote is really saving my life.. to date, it's generated nearly 25k lines of code:
That's just going to keep growing as I create more types and API endpoints.
just added another "feature" to it, to create converters between request/responses (two different types):
here's an example conversion between an auto-generated ThreadRequest and ThreadResponse:
That last function is the one I need most.. Response To Request. The first one, Request To Response I probably won't use much at all. Response To Request allows me to take a simple response from the server and form it into a request, ie for editing threads etc.
I thought this was going to take me a few hours to write, but it actually took just under an hour.
woord!
pc
Code: [Select]
$ wc -l /tmp/LN*|tail -n 1
24367 total
That's just going to keep growing as I create more types and API endpoints.
just added another "feature" to it, to create converters between request/responses (two different types):
here's an example conversion between an auto-generated ThreadRequest and ThreadResponse:
Code: [Select]
threadRequestToThreadResponse :: Int -> Int -> Int -> (Maybe Date) -> (Maybe Int) -> (Maybe Date) -> (Maybe Date) -> ThreadRequest ->
ThreadResponse
threadRequestToThreadResponse id userId boardId createdAt modifiedBy modifiedAt activityAt (ThreadRequest o) =
ThreadResponse {
id: id,
userId: userId,
boardId: boardId,
name: o.name,
description: o.description,
sticky: o.sticky,
locked: o.locked,
poll: o.poll,
createdAt: createdAt,
modifiedBy: modifiedBy,
modifiedAt: modifiedAt,
activityAt: activityAt
}
threadResponseToThreadRequest :: ThreadResponse -> ThreadRequest
threadResponseToThreadRequest (ThreadResponse o) =
ThreadRequest {
name: o.name,
description: o.description,
sticky: o.sticky,
locked: o.locked,
poll: o.poll
}
That last function is the one I need most.. Response To Request. The first one, Request To Response I probably won't use much at all. Response To Request allows me to take a simple response from the server and form it into a request, ie for editing threads etc.
I thought this was going to take me a few hours to write, but it actually took just under an hour.

woord!
pc





