Skip to content

Commit 1bc6fb7

Browse files
alexeygolevchenglou
authored andcommitted
Add a sub-section on extending module signatures (#191)
* Add a sub-section on extending module signatures Following the example for extending modules. * Update module.md
1 parent 2520844 commit 1bc6fb7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/pages/guide/language/module.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,23 @@ It's also useful to hide the underlying type as an implementation detail others
199199
can't rely on. If you ask what the type of `Company.profession` is, instead of
200200
exposing the variant, it'll only tell you "it's `Company.profession`".
201201

202+
#### Extending module signatures
203+
204+
Like modules themselves, module signatures can also be extended through `include module type of Foo`:
205+
206+
```reason
207+
module type BaseComponent = {
208+
let defaultGreeting: string;
209+
let getAudience: excited::bool => string;
210+
};
211+
212+
module type ActualComponent = {
213+
/* the signature is copied over */
214+
include module type of BaseComponent;
215+
let render: unit => string;
216+
};
217+
```
218+
202219
#### Every `.rei` file is a signature
203220

204221
Similar to how a `react.re` file implicitly defines a module `React`, a file

0 commit comments

Comments
 (0)