Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

show returns undefined inside FFI/JS #4564

Copy link
Copy link

Description

@Hi-Angel
Issue body actions

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

  1. 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));
        };
    };
  2. Execute spago run

Expected behavior

It should output Foo, not undefined

PureScript version

0.15.15

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.