sanctuary-js / sanctuary

:see_no_evil: Refuge from unsafe JavaScript
https://sanctuary.js.org
MIT License
3.04k stars 94 forks source link

Code sample in README.md#API#create throws error #526

Closed derrickbeining closed 6 years ago

derrickbeining commented 6 years ago

I'm a newb to the ADT scene and was trying to get familiar with Sanctuary. I started with running the code from README.md#API#create here on REPL.it https://repl.it/@dbeining/sanctuary-js-create-env, and it threw a sanctuary type error. I'm assuming that's not the expected behavior, so wanted to see what's up.

davidchambers commented 6 years ago

Could you share the error message, @derrickbeining? I see => Identity { value: 42 } as the output.

derrickbeining commented 6 years ago

Quick response! Sorry, without thinking I edited that repl.it code and seem to have figured out the issue. I changed it back if you care to look again to see the error I was getting.

derrickbeining commented 6 years ago

From skimming through the sanctuary-def README, it looks like

//    IdentityType :: Type -> Type
const IdentityType = $.UnaryType(
  Identity['@@type'],
  'http://example.com/my-package#Identity',
  x => type(x) === Identity['@@type'],
  identity => [identity.value]
);

should be

const IdentityType = $.UnaryType
  (Identity['@@type'])
  ('http://example.com/my-package#Identity')
  (x => type(x) === Identity['@@type'])
  (identity => [identity.value])
davidchambers commented 6 years ago

There were several breaking changes in sanctuary-def@0.15.0. The most recent Sanctuary release depends on an older version of sanctuary-def:

$ npm view sanctuary version
0.14.1

$ npm view sanctuary dependencies.sanctuary-def
0.14.0

The readme is compatible with sanctuary-def@0.14.0 but not with more recent versions. I'll make sure that the readme is updated when I release sanctuary@0.15.0 (this weekend, hopefully).