Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. type t('a) =
  2.  | E: t([ | `Empty])
  3.  | F(string): t([ | `Ready]);
  4.  
  5. type action =
  6.  | No;
  7.  
  8. let component = ReasonReact.reducerComponent("Page");
  9.  
  10. let make = _children => {
  11.  ...component,
  12.  initialState: () => E,
  13.  reducer: (action, state: t('a)) =>
  14.     switch (action) {
  15.     | No => ReasonReact.Update(F("action"))
  16.     },
  17.   render: self => {
  18.     let message: type a. t(a) => string =
  19.       state =>
  20.         switch (state) {
  21.         | E => "empty"
  22.         | F(msg) => msg
  23.         };
  24.     <div> (ReasonReact.stringToElement(message(self.state))) </div>;
  25.   },
  26. };
  27.  
  28.  
  29.  
  30.  
  31.  
  32. This has type:
  33.     ReasonReact.componentSpec
  34.     (ReactTemplate.Page.t([ `Ready ]),  ReactTemplate.Page.t([ `Empty ]),
  35.       ReasonReact.noRetainedProps,  ReasonReact.noRetainedProps,
  36.       ReactTemplate.Page.action)
  37.   But somewhere wanted:
  38.     ReasonReact.component (ReactTemplate.Page.t([ `Ready ]),  'a,  'b)
  39.       (defined as
  40.       ReasonReact.componentSpec
  41.       (ReactTemplate.Page.t([ `Ready ]),  ReactTemplate.Page.t([ `Ready ]),
  42.         'a,  'a,  'b))
  43.  
  44.  The incompatible parts:
  45.    ReactTemplate.Page.t([ `Empty ]) (defined as
  46.      ReactTemplate.Page.t([ `Empty ]))
  47.    vs
  48.    ReactTemplate.Page.t([ `Ready ]) (defined as
  49.      ReactTemplate.Page.t([ `Ready ]))
  50.  These two variant types have no intersection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement