Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: node_js
dist: trusty
sudo: required
node_js: 6
env:
- PATH=$HOME/purescript:$PATH
install:
- TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p')
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
- chmod a+x $HOME/purescript
- npm install -g bower
- npm install
script:
- bower install --production
- npm run -s build
- bower install
- npm -s test
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
"purescript-eff": "^2.0.0",
"purescript-exceptions": "^2.0.0",
"purescript-foreign": "^3.0.0",
"purescript-generics": "^3.0.0",
"purescript-generics-rep": "^4.0.0",
"purescript-globals": "^2.0.0",
"purescript-maps": "^2.0.0",
"purescript-nullable": "^2.0.0",
"purescript-symbols": "^1.0.1"
"purescript-symbols": "^2.0.0"
},
"devDependencies": {
"purescript-assert": "^2.0.0"
Expand Down
21 changes: 4 additions & 17 deletions docs/Data/Foreign/Generic.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
## Module Data.Foreign.Generic

#### `Options`

``` purescript
type Options = { sumEncoding :: SumEncoding, unwrapNewtypes :: Boolean, unwrapSingleArgumentConstructors :: Boolean, maybeAsNull :: Boolean, tupleAsArray :: Boolean }
```

#### `SumEncoding`

``` purescript
data SumEncoding
= TaggedObject { tagFieldName :: String, contentsFieldName :: String }
```

#### `defaultOptions`

``` purescript
Expand All @@ -22,31 +9,31 @@ defaultOptions :: Options
#### `readGeneric`

``` purescript
readGeneric :: forall a. Generic a => Options -> Foreign -> F a
readGeneric :: forall a rep. (Generic a rep, GenericDecode rep) => Options -> Foreign -> F a
```

Read a value which has a `Generic` type.

#### `toForeignGeneric`

``` purescript
toForeignGeneric :: forall a. Generic a => Options -> a -> Foreign
toForeignGeneric :: forall a rep. (Generic a rep, GenericEncode rep) => Options -> a -> Foreign
```

Generate a `Foreign` value compatible with the `readGeneric` function.

#### `readJSONGeneric`

``` purescript
readJSONGeneric :: forall a. Generic a => Options -> String -> F a
readJSONGeneric :: forall a rep. (Generic a rep, GenericDecode rep) => Options -> String -> F a
```

Read a value which has a `Generic` type from a JSON String

#### `toJSONGeneric`

``` purescript
toJSONGeneric :: forall a. Generic a => Options -> a -> String
toJSONGeneric :: forall a rep. (Generic a rep, GenericEncode rep) => Options -> a -> String
```

Write a value which has a `Generic` type as a JSON String
Expand Down
102 changes: 102 additions & 0 deletions docs/Data/Foreign/Generic/Classes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
## Module Data.Foreign.Generic.Classes

#### `GenericDecode`

``` purescript
class GenericDecode a where
decodeOpts :: Options -> Foreign -> F a
```

##### Instances
``` purescript
GenericDecode NoConstructors
(IsSymbol name, GenericDecodeArgs rep, GenericCountArgs rep) => GenericDecode (Constructor name rep)
(GenericDecode a, GenericDecode b) => GenericDecode (Sum a b)
```

#### `GenericEncode`

``` purescript
class GenericEncode a where
encodeOpts :: Options -> a -> Foreign
```

##### Instances
``` purescript
GenericEncode NoConstructors
(IsSymbol name, GenericEncodeArgs rep) => GenericEncode (Constructor name rep)
(GenericEncode a, GenericEncode b) => GenericEncode (Sum a b)
```

#### `GenericDecodeArgs`

``` purescript
class GenericDecodeArgs a where
decodeArgs :: Int -> List Foreign -> F { result :: a, rest :: List Foreign, next :: Int }
```

##### Instances
``` purescript
GenericDecodeArgs NoArguments
(IsForeign a) => GenericDecodeArgs (Argument a)
(GenericDecodeArgs a, GenericDecodeArgs b) => GenericDecodeArgs (Product a b)
(GenericDecodeFields fields) => GenericDecodeArgs (Rec fields)
```

#### `GenericEncodeArgs`

``` purescript
class GenericEncodeArgs a where
encodeArgs :: a -> List Foreign
```

##### Instances
``` purescript
GenericEncodeArgs NoArguments
(AsForeign a) => GenericEncodeArgs (Argument a)
(GenericEncodeArgs a, GenericEncodeArgs b) => GenericEncodeArgs (Product a b)
(GenericEncodeFields fields) => GenericEncodeArgs (Rec fields)
```

#### `GenericDecodeFields`

``` purescript
class GenericDecodeFields a where
decodeFields :: Foreign -> F a
```

##### Instances
``` purescript
(IsSymbol name, IsForeign a) => GenericDecodeFields (Field name a)
(GenericDecodeFields a, GenericDecodeFields b) => GenericDecodeFields (Product a b)
```

#### `GenericEncodeFields`

``` purescript
class GenericEncodeFields a where
encodeFields :: a -> StrMap Foreign
```

##### Instances
``` purescript
(IsSymbol name, AsForeign a) => GenericEncodeFields (Field name a)
(GenericEncodeFields a, GenericEncodeFields b) => GenericEncodeFields (Product a b)
```

#### `GenericCountArgs`

``` purescript
class GenericCountArgs a where
countArgs :: Proxy a -> Either a Int
```

##### Instances
``` purescript
GenericCountArgs NoArguments
GenericCountArgs (Argument a)
(GenericCountArgs a, GenericCountArgs b) => GenericCountArgs (Product a b)
GenericCountArgs (Rec fields)
```


16 changes: 16 additions & 0 deletions docs/Data/Foreign/Generic/Types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Module Data.Foreign.Generic.Types

#### `Options`

``` purescript
type Options = { sumEncoding :: SumEncoding, unwrapSingleConstructors :: Boolean, unwrapSingleArguments :: Boolean }
```

#### `SumEncoding`

``` purescript
data SumEncoding
= TaggedObject { tagFieldName :: String, contentsFieldName :: String }
```


12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"private": true,
"scripts": {
"clean": "rimraf output",
"build": "psa \"src/**/*.purs\" \"bower_components/purescript-*/src/**/*.purs\" --censor-lib --strict",
"test": "psc \"src/**/*.purs\" \"bower_components/purescript-*/src/**/*.purs\" \"test/**/*.purs\" && psc-bundle \"output/**/*.js\" --module Test.Main --main Test.Main | node"
},
"devDependencies": {
"purescript-psa": "^0.3.8",
"rimraf": "^2.5.0"
}
}
42 changes: 0 additions & 42 deletions psc-package.json

This file was deleted.

Loading