Description
Following official documentation, to call show upon a data value inside JS I just need to do that, it should Just Work™.
But for some reason show returns undefined. More over, if I do spago bundle-app and look at the resulting index.js, I don't even see the string for the Show instance to produce, so if there's some odd trick required, it's impossible to derive from the output.
This came up as part of forum discussion.
To Reproduce
-
Create src/Main.purs as:
module Main where
import Prelude
import Effect (Effect)
data Foo = Foo
instance fooShow :: Show Foo where
show Foo = "Foo"
-- | re-export of `show`
show_ :: ∀ a. Show a => a -> String
show_ = show
foreign import printFoo :: Foo -> Effect Unit
main :: Effect Unit
main = printFoo Foo -- same as `log $ show Foo`
and src/Main.js as:
import { show_ } from '../Main/index.js';
export const printFoo = function(foo) {
return function () {
console.log(show_(foo));
};
};
-
Execute spago run
Expected behavior
It should output Foo, not undefined
PureScript version
0.15.15
Description
Following official documentation, to call
showupon adatavalue inside JS I just need to do that, it should Just Work™.But for some reason
showreturnsundefined. More over, if I dospago bundle-appand look at the resultingindex.js, I don't even see the string for the Show instance to produce, so if there's some odd trick required, it's impossible to derive from the output.This came up as part of forum discussion.
To Reproduce
Create
src/Main.pursas:and
src/Main.jsas:Execute
spago runExpected behavior
It should output
Foo, notundefinedPureScript version
0.15.15