Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Add FFI option for PureScript 0.7 #28

Merged
merged 1 commit into from
May 8, 2015
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
33 changes: 32 additions & 1 deletion MODULE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Module Documentation

## Module GulpPurescript.Buffer

#### `Buffer`

``` purescript
data Buffer
```


#### `mkBufferFromString`

``` purescript
mkBufferFromString :: String -> Buffer
```



## Module GulpPurescript.ChildProcess

#### `ChildProcess`
Expand Down Expand Up @@ -60,7 +77,7 @@ mkPluginError :: String -> String -> Error
#### `mkFile`

``` purescript
mkFile :: String -> String -> File
mkFile :: String -> Buffer -> File
```


Expand Down Expand Up @@ -166,6 +183,13 @@ platform :: forall eff. Eff (os :: OS | eff) (Maybe Platform)

## Module GulpPurescript.Options

#### `isForeignEither`

``` purescript
instance isForeignEither :: (IsForeign a, IsForeign b) => IsForeign (Either a b)
```


#### `isForeignPsc`

``` purescript
Expand Down Expand Up @@ -201,6 +225,13 @@ pscOptions :: Foreign -> [String]
```


#### `pscOptionsNoOutput`

``` purescript
pscOptionsNoOutput :: Foreign -> Tuple (Maybe String) [String]
```


#### `pscMakeOptions`

``` purescript
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Sets one or more `--module=<string>` that enables dead code elimination, removin

###### `codegen` (String Array)

Sets one or more `--codegen=<string>` that generates code and extenrs for the specified modules.
Sets one or more `--codegen=<string>` that generates code and externs for the specified modules.

###### `output` (String)

Expand All @@ -88,6 +88,10 @@ Sets the path value of the [File](https://github.com/wearefractal/vinyl) passed

Toggles `--no-prefix` that does not include the comment header.

###### `ffi` (String Array)

Sets one or more `--ffi=<string>` that specifies the location of files for code that is included with a `foreign import` in the PureScript source.

### `purescript.pscMake(options)`

Invokes the `psc-make` command. The following options are supported.
Expand Down Expand Up @@ -124,6 +128,10 @@ Sets `--output=<string>` the specifies the output directory, `output` by default

Toggles `--no-prefix` that does not include the comment header.

###### `ffi` (String Array)

Sets one or more `--ffi=<string>` that specifies the location of files for code that is included with a `foreign import` in the PureScript source.

### `purescript.pscDocs(options)`

Invokes the `pscDocs` command. The following options are supported.
Expand Down
20 changes: 16 additions & 4 deletions src/Options.purs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ formatOpt = "format"

formatKey = formatOpt

ffiOpt = "ffi"

ffiKey = ffiOpt

newtype Psc
= Psc { noPrelude :: NullOrUndefined Boolean
, noTco :: NullOrUndefined Boolean
Expand All @@ -86,6 +90,7 @@ newtype Psc
, output :: NullOrUndefined String
, externs :: NullOrUndefined String
, noPrefix :: NullOrUndefined Boolean
, ffi :: NullOrUndefined [String]
}

newtype PscMake
Expand All @@ -97,6 +102,7 @@ newtype PscMake
, comments :: NullOrUndefined Boolean
, noPrefix :: NullOrUndefined Boolean
, output :: NullOrUndefined String
, ffi :: NullOrUndefined [String]
}

newtype PscDocs
Expand All @@ -110,7 +116,7 @@ instance isForeignEither :: (IsForeign a, IsForeign b) => IsForeign (Either a b)

instance isForeignPsc :: IsForeign Psc where
read obj =
(\a b c d e f g h i j k l m ->
(\a b c d e f g h i j k l m o ->
Psc { noPrelude: a
, noTco: b
, noMagicDo: c
Expand All @@ -124,6 +130,7 @@ instance isForeignPsc :: IsForeign Psc where
, output: k
, externs: l
, noPrefix: m
, ffi: o
}) <$> readProp noPreludeKey obj
<*> readProp noTcoKey obj
<*> readProp noMagicDoKey obj
Expand All @@ -137,10 +144,11 @@ instance isForeignPsc :: IsForeign Psc where
<*> readProp outputKey obj
<*> readProp externsKey obj
<*> readProp noPrefixKey obj
<*> readProp ffiKey obj

instance isForeignPscMake :: IsForeign PscMake where
read obj =
(\a b c d e f g h ->
(\a b c d e f g h i ->
PscMake { output: a
, noPrelude: b
, noTco: c
Expand All @@ -149,6 +157,7 @@ instance isForeignPscMake :: IsForeign PscMake where
, verboseErrors: f
, comments: g
, noPrefix: h
, ffi: i
}) <$> readProp outputKey obj
<*> readProp noPreludeKey obj
<*> readProp noTcoKey obj
Expand All @@ -157,6 +166,7 @@ instance isForeignPscMake :: IsForeign PscMake where
<*> readProp verboseErrorsKey obj
<*> readProp commentsKey obj
<*> readProp noPrefixKey obj
<*> readProp ffiKey obj

instance isForeignPscDocs :: IsForeign PscDocs where
read obj = (\a -> PscDocs { format: a }) <$> readProp formatKey obj
Expand Down Expand Up @@ -204,7 +214,8 @@ foldPscOptions (Psc a) = mkBoolean noPreludeOpt a.noPrelude <>
mkStringArray codegenOpt a.codegen <>
mkString outputOpt a.output <>
mkString externsOpt a.externs <>
mkBoolean noPrefixOpt a.noPrefix
mkBoolean noPrefixOpt a.noPrefix <>
mkStringArray ffiOpt a.ffi

pscOptions :: Foreign -> [String]
pscOptions opts = either (const []) foldPscOptions parsed
Expand All @@ -226,7 +237,8 @@ pscMakeOptions opts = either (const []) fold parsed
mkBoolean noOptsOpt a.noOpts <>
mkBoolean verboseErrorsOpt a.verboseErrors <>
mkBoolean commentsOpt a.comments <>
mkBoolean noPrefixOpt a.noPrefix
mkBoolean noPrefixOpt a.noPrefix <>
mkStringArray ffiOpt a.ffi

pscDocsOptions :: Foreign -> [String]
pscDocsOptions opts = either (const []) fold parsed
Expand Down