Skip to content

Move fantasy-land methods to the prototypes and implement Node.js inspect()#750

Merged
gigobyte merged 2 commits intogigobyte:masterfrom
cAttte:master
Apr 10, 2025
Merged

Move fantasy-land methods to the prototypes and implement Node.js inspect()#750
gigobyte merged 2 commits intogigobyte:masterfrom
cAttte:master

Conversation

@cAttte
Copy link
Contributor

@cAttte cAttte commented Apr 9, 2025

hi! this PR closes #745 and closes #744.

here's an example of how the changes affect debugging output. given this script:

console.log('nothing:', Nothing)
console.log('something:', Just({ a: 3 }))

before this PR, the output was:

(expand)
nothing: {
  'fantasy-land/equals': [Function: equals],
  'fantasy-land/map': [Function: map],
  'fantasy-land/ap': [Function: ap],
  'fantasy-land/alt': [Function: alt],
  'fantasy-land/chain': [Function: chain],
  'fantasy-land/reduce': [Function: reduce],
  'fantasy-land/extend': [Function: extend],
  'fantasy-land/filter': [Function: filter]
}
something: {
  __value: { a: 3 },
  'fantasy-land/equals': [Function: equals],
  'fantasy-land/map': [Function: map],
  'fantasy-land/ap': [Function: ap],
  'fantasy-land/alt': [Function: alt],
  'fantasy-land/chain': [Function: chain],
  'fantasy-land/reduce': [Function: reduce],
  'fantasy-land/extend': [Function: extend],
  'fantasy-land/filter': [Function: filter]
}

after a37c7c9 (fantasy-land), and in the browser, the output is:

nothing: {}
something: { __value: { a: 3 } }

after a7e20f0 (inspect), only on node.js, the output is:

nothing: Nothing
something: Just({ a: 3 })

compare with the current inspect():

nothing: Nothing
something: Just([object Object])

@gigobyte
Copy link
Owner

Thanks a lot, great quality of life improvement!

@gigobyte gigobyte merged commit aa2d60b into gigobyte:master Apr 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move fantasy-land methods to the prototypes [PR-ready] Better Node.js inspect() support [PR-ready]

2 participants