Commit Graph

27 Commits

Author SHA1 Message Date
Philip Patsch
e4865644c1 doc(servant-foreign): Document module
I spend some considerable time reverse engineering the module, so I
thought I’d write the documentation I would have liked to see.

The strategy here is that a user not necessarily has insight into how
servant works internally, or even how to write complex servant routes,
they just want to generate a list of endpoints and convert the `Req`
type into e.g. generated code in $language. Thus, they need to know
the semantics of all fields of Req, how they interact and how they
relate to a plain http route.

I made sure every `f` is replaced with `ftype`, so we have one
conventional way of referring to the foreign type argument everywhere.

Some enums are not set at all, they are marked as such.

`_reqBodyContentType` introduces a major restriction of the module, so
that is mentioned in the documentation for now, until the time it will
be fixed.

A few TODO’s describe places where types don’t make sense but would
introduce API-breaking changes, so these should probably be
simplified,
but bundled in one go.
2021-03-25 11:26:53 +01:00
Philip Patsch
a0265097e8 doc(servant-foreign): reorder imports
The imports were ordered in the worst possible way, with all
undocumented small type definitions coming first and the actual meat
of the module coming at the very end, mixed in with irrelevant
functions.

This inverses that toxic ordering, showing the main function
first (`listFromAPI`) and then the main data type (`Req`) and the main
class (`HasForeignType`).
2021-03-25 11:26:53 +01:00
Philip Patsch
c3a517cb4f doc(servant-foreign): Inflection docs & module docs 2021-03-25 11:26:53 +01:00
Andrew Cady
c07f86bda7 introduce type ReqBodyContentType replacing use of Bool 2018-09-17 17:22:32 -04:00
Andrew Cady
62def38a9b Add record to Req type
This is needed for servant-js to know whether to call JSON.stringify()
on the request body or just send it raw.
2018-09-16 21:08:07 -04:00
Oleg Grenrus
f9bcc15d0b Apply stylish-haskell on all modules 2018-06-29 23:36:39 +03:00
Steve Purcell
5188e842a9 [servant-foreign] Parameterise type classes with a foreign representation type
We allow a user-specified type to represent the foreign type of haskell
types encountered in the API. This lets users map Integer, Date etc. to
representations other than Text, and have those representations
available in the returned list of Req.

For example, we might want to map a type which has an instance of
Generic to both a foreign type name and a class declaration for that
foreign type such that it can encode/decode itself to JSON. The previous
limitation to a single Text output prevented this case.
2016-03-14 10:34:53 +13:00
Steve Purcell
bfe812f5d9 [servant-foreign] Normalise names of arg field accessors 2016-03-13 17:27:31 +13:00
Denis Redozubov
e5635a044e use newtypes in servant-foreign 2016-03-12 12:51:22 +03:00
Denis Redozubov
e6e13fde84 Make servant-foreign code nicer
* non-messy imports
* got rid of most long lines (>80 chars)
* prisms for sum types and newtypes(we use lens anyway, so why not)
* consistent indentation
2016-02-11 15:26:01 +03:00
Maksymilian Owsianny
721151a32d Added default NoTypes parameter for dynamic languages. 2015-12-02 15:56:56 +00:00
Maksymilian Owsianny
2d8db45907 Moved GenerateList to servant-foreign. 2015-12-02 11:21:37 +00:00
Maksymilian Owsianny
8932cb242c Add access to types in servant-foreign. 2015-11-28 08:13:26 +00:00
Matthias Fischmann
9b08a05502 Adjust file contents a little. 2015-11-16 18:40:15 +01:00
Matthias Fischmann
a1dcc275eb Just rename the file. 2015-11-16 18:33:35 +01:00
Matt Bray
f6ee02eb91 servant-foreign: fix camelCase
Previous behaviour was a bit shouty (and dashes aren't allowed in JS
variable names):

camelCase ["one", "two", "thirty-three"] => "oneTWOTHIRTY-THREE"

New behaviour:

camelCase ["one", "two", "thirty-three"] => "oneTwoThirtythree"
2015-11-04 11:27:07 +00:00
Julian K. Arni
2a894d861c -Wall fixes 2015-10-13 21:38:13 +02:00
Julian K. Arni
ec55f4b981 Remove Matrix params.
For servant-docs, -foreign, -js, and -mock.
2015-10-13 21:37:07 +02:00
Arian van Putten
4b81f0c77a More test fixes 2015-10-02 15:03:26 +02:00
Arian van Putten
e17987e5ff Convert servant-foreign to use text 2015-10-02 10:23:57 +02:00
Julian K. Arni
4206285e2d CPP NullaryTypeClass 2015-09-23 20:39:46 +02:00
Julian K. Arni
487f323f2f More Werror fixes 2015-09-23 20:30:45 +02:00
Denis Redozubov
99b59eac39 NullaryTypeClasses needed for ghc 7.8 2015-09-22 14:47:38 +03:00
Denis Redozubov
5018a34abd fix Elem type family to enable sane error reporting 2015-09-22 14:02:52 +03:00
Denis Redozubov
b59a62e012 no opinion on valid function names in servant-foreign 2015-09-22 14:02:30 +03:00
Denis Redozubov
7ff9e52a50 CommonGeneratorOptions moved to servant-js 2015-09-22 12:21:04 +03:00
Denis Redozubov
ce3e4f7193 Extract common code-generation stuff to servant-foreign 2015-09-21 20:59:09 +03:00