Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add identifier #77

Open
wants to merge 1 commit into
base: golang
Choose a base branch
from
Open

Add identifier #77

wants to merge 1 commit into from

Conversation

pmd3d
Copy link

@pmd3d pmd3d commented Apr 17, 2022

spago init -> set psgo backend -> spago build failed with error message about $ char code. added it in. maybe some sort of locale issue? i'm in LA area using Ubuntu 20.04 in wsl of windows.

spago init -> set psgo backend -> spago build failed with error message about $ char code. added it in. maybe some sort of locale issue? i'm in LA area using Ubuntu 20.04 in wsl of windows.
@jjthiessen
Copy link

Are you building psgo yourself? If so, how (stack, cabal; what commit are you working off of)? If not, which binary are you using/where are you getting it from?

I had a similar issue when I was first working on #76, but I was also trying to sort out version issues (golang's (the branch, that is) package.yaml and psgo.cabal doesn't include version constraints for PureScript — there are a few required changes to the codebase to get it working with 0.14.x (something I want to get into a PR after testing my other PR more and hopefully getting it merged)).

I'm not sure the specific cause, but I've run into the same issue, and I can also say that doing nix builds (and, IIRC, regular stack builds too?) from https://github.com/jjthiessen/purescript-native/tree/add-flakes seems to work/avoid the issue.

@jjthiessen
Copy link

That being said, I did have to do something akin to this PR in my earlier experimentation to get psgo compiling and seemingly working with 0.14.x (along with other changes), so something like this might be necessary in any case.

@pmd3d
Copy link
Author

pmd3d commented Apr 20, 2022

Hi. I am a beginner at nix so I used stack to build psgo from source

@jjthiessen
Copy link

jjthiessen commented Apr 20, 2022 via email

@pmd3d
Copy link
Author

pmd3d commented Apr 20, 2022

Oh. I was gonna try it from scratch on a digital ocean instance this weekend. Not sure if something was off with using wsl Ubuntu instead of regular Ubuntu

@pmd3d
Copy link
Author

pmd3d commented Apr 20, 2022

I'll try to provide more detail when I do that. Like go version. Purescript version. Ubuntu version.

@pmd3d
Copy link
Author

pmd3d commented Apr 20, 2022

I'll work on it now but I don't have much time.

@pmd3d
Copy link
Author

pmd3d commented Apr 21, 2022

hi, i duplicated the issue with some manual fresh installs:
spago init -> spago backend="psgo" -> spago run ->
error message:
[info] Build succeeded.
psgo: 36
CallStack (from HasCallStack):
error, called at src/CodeGen/IL/Common.hs:63:21 in psgo-0.1.0.0-IgBukhCIbVQBRCfK92QQye:CodeGen.IL.Common
[error] Backend "psgo" exited with error:1
Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-107-generic x86_64)
installed libtinfo-dev
git clone https://github.com/andyarvanitis/purescript-native.git
stack - Version 2.7.5, Git revision ba147e6f59b2da75b1beb98b1888cce97f7032b1 x86_64 hpack-0.34.4
node - v18.0.0
purs - 0.14.9
spago - 0.20.7
go version - go1.18.1 linux/amd64

hopefully i will try the nix this weekend sometime but i'm a beginner at nix. maybe there's something different in the versions.

@jjthiessen
Copy link

I wasn't able to reproduce the issue earlier with either Stack or Nix builds because I was using PureScript 0.13.8 for both building and using psgo.

That is, all of the following should work:

  • On add-flakes:
    • Using the nix flake directly
    • stack --nix build
    • nix-shell stack.nix
      stack --no-nix --system-ghc build
      
  • On golang:
    • stack --nix build
    • nix-shell stack.nix
      stack --no-nix --system-ghc build
      

When I encountered this originally, I was experimenting with 0.14.x compatibility (for building and running).

The error is because you're using purs 0.14.x.
psgo doesn't support PureScript 0.14.x yet (at build time or runtime).

Since psgo is compiled against 0.13.8, it will build fine (if you tried to bump the PureScript version to 0.14.x in the stack.yaml it would fail).
However, psgo is executed against the CoreFn output from whatever version of purs you have available.

Below is a comparison of the contents of output/Effect.Class/corefn.json for a build using 0.13.8 vs 0.14.5 (notice the $ in identifiers in the 0.14.5 CoreFn output).

{
  "moduleName": [
    "Effect",
    "Class"
  ],
  "imports": [
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            1,
            1
          ],
          "end": [
            19,
            24
          ]
        }
      },
      "moduleName": [
        "Control",
        "Category"
      ]
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            4,
            1
          ],
          "end": [
            4,
            35
          ]
        }
      },
      "moduleName": [
        "Control",
        "Monad"
      ]
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            1,
            1
          ],
          "end": [
            19,
            24
          ]
        }
      },
      "moduleName": [
        "Effect"
      ]
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            1,
            1
          ],
          "end": [
            19,
            24
          ]
        }
      },
      "moduleName": [
        "Effect",
        "Class"
      ]
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            1,
            1
          ],
          "end": [
            19,
            24
          ]
        }
      },
      "moduleName": [
        "Prim"
      ]
    }
  ],
  "builtWith": "0.13.8",
  "modulePath": ".spago/effect/v2.0.1/src/Effect/Class.purs",
  "exports": [
    "liftEffect",
    "MonadEffect",
    "monadEffectEffect"
  ],
  "decls": [
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            15,
            1
          ],
          "end": [
            16,
            42
          ]
        }
      },
      "identifier": "MonadEffect",
      "expression": {
        "annotation": {
          "meta": {
            "metaType": "IsTypeClassConstructor"
          },
          "sourceSpan": {
            "start": [
              15,
              1
            ],
            "end": [
              16,
              42
            ]
          }
        },
        "body": {
          "annotation": {
            "meta": null,
            "sourceSpan": {
              "start": [
                15,
                1
              ],
              "end": [
                16,
                42
              ]
            }
          },
          "body": {
            "annotation": {
              "meta": null,
              "sourceSpan": {
                "start": [
                  15,
                  1
                ],
                "end": [
                  16,
                  42
                ]
              }
            },
            "value": {
              "literalType": "ObjectLiteral",
              "value": [
                [
                  "Monad0",
                  {
                    "annotation": {
                      "meta": null,
                      "sourceSpan": {
                        "start": [
                          15,
                          1
                        ],
                        "end": [
                          16,
                          42
                        ]
                      }
                    },
                    "value": {
                      "moduleName": null,
                      "identifier": "Monad0"
                    },
                    "type": "Var"
                  }
                ],
                [
                  "liftEffect",
                  {
                    "annotation": {
                      "meta": null,
                      "sourceSpan": {
                        "start": [
                          15,
                          1
                        ],
                        "end": [
                          16,
                          42
                        ]
                      }
                    },
                    "value": {
                      "moduleName": null,
                      "identifier": "liftEffect"
                    },
                    "type": "Var"
                  }
                ]
              ]
            },
            "type": "Literal"
          },
          "argument": "liftEffect",
          "type": "Abs"
        },
        "argument": "Monad0",
        "type": "Abs"
      },
      "bindType": "NonRec"
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            18,
            1
          ],
          "end": [
            19,
            24
          ]
        }
      },
      "identifier": "monadEffectEffect",
      "expression": {
        "annotation": {
          "meta": null,
          "sourceSpan": {
            "start": [
              18,
              1
            ],
            "end": [
              19,
              24
            ]
          }
        },
        "argument": {
          "annotation": {
            "meta": null,
            "sourceSpan": {
              "start": [
                19,
                16
              ],
              "end": [
                19,
                24
              ]
            }
          },
          "argument": {
            "annotation": {
              "meta": null,
              "sourceSpan": {
                "start": [
                  0,
                  0
                ],
                "end": [
                  0,
                  0
                ]
              }
            },
            "value": {
              "moduleName": [
                "Control",
                "Category"
              ],
              "identifier": "categoryFn"
            },
            "type": "Var"
          },
          "type": "App",
          "abstraction": {
            "annotation": {
              "meta": {
                "metaType": "IsForeign"
              },
              "sourceSpan": {
                "start": [
                  19,
                  16
                ],
                "end": [
                  19,
                  24
                ]
              }
            },
            "value": {
              "moduleName": [
                "Control",
                "Category"
              ],
              "identifier": "identity"
            },
            "type": "Var"
          }
        },
        "type": "App",
        "abstraction": {
          "annotation": {
            "meta": null,
            "sourceSpan": {
              "start": [
                18,
                1
              ],
              "end": [
                19,
                24
              ]
            }
          },
          "argument": {
            "annotation": {
              "meta": null,
              "sourceSpan": {
                "start": [
                  18,
                  1
                ],
                "end": [
                  19,
                  24
                ]
              }
            },
            "body": {
              "annotation": {
                "meta": null,
                "sourceSpan": {
                  "start": [
                    0,
                    0
                  ],
                  "end": [
                    0,
                    0
                  ]
                }
              },
              "value": {
                "moduleName": [
                  "Effect"
                ],
                "identifier": "monadEffect"
              },
              "type": "Var"
            },
            "argument": "$__unused",
            "type": "Abs"
          },
          "type": "App",
          "abstraction": {
            "annotation": {
              "meta": {
                "metaType": "IsTypeClassConstructor"
              },
              "sourceSpan": {
                "start": [
                  18,
                  1
                ],
                "end": [
                  19,
                  24
                ]
              }
            },
            "value": {
              "moduleName": [
                "Effect",
                "Class"
              ],
              "identifier": "MonadEffect"
            },
            "type": "Var"
          }
        }
      },
      "bindType": "NonRec"
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            16,
            3
          ],
          "end": [
            16,
            42
          ]
        }
      },
      "identifier": "liftEffect",
      "expression": {
        "annotation": {
          "meta": null,
          "sourceSpan": {
            "start": [
              16,
              3
            ],
            "end": [
              16,
              42
            ]
          }
        },
        "body": {
          "annotation": {
            "meta": null,
            "sourceSpan": {
              "start": [
                16,
                3
              ],
              "end": [
                16,
                42
              ]
            }
          },
          "expression": {
            "annotation": {
              "meta": null,
              "sourceSpan": {
                "start": [
                  16,
                  3
                ],
                "end": [
                  16,
                  42
                ]
              }
            },
            "value": {
              "moduleName": null,
              "identifier": "dict"
            },
            "type": "Var"
          },
          "fieldName": "liftEffect",
          "type": "Accessor"
        },
        "argument": "dict",
        "type": "Abs"
      },
      "bindType": "NonRec"
    }
  ],
  "comments": [],
  "foreign": [],
  "sourceSpan": {
    "start": [
      1,
      1
    ],
    "end": [
      19,
      24
    ]
  }
}

{
  "moduleName": [
    "Effect",
    "Class"
  ],
  "reExports": {},
  "imports": [
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            1,
            1
          ],
          "end": [
            19,
            24
          ]
        }
      },
      "moduleName": [
        "Control",
        "Category"
      ]
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            4,
            1
          ],
          "end": [
            4,
            35
          ]
        }
      },
      "moduleName": [
        "Control",
        "Monad"
      ]
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            1,
            1
          ],
          "end": [
            19,
            24
          ]
        }
      },
      "moduleName": [
        "Effect"
      ]
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            1,
            1
          ],
          "end": [
            19,
            24
          ]
        }
      },
      "moduleName": [
        "Effect",
        "Class"
      ]
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            1,
            1
          ],
          "end": [
            19,
            24
          ]
        }
      },
      "moduleName": [
        "Prim"
      ]
    }
  ],
  "builtWith": "0.14.5",
  "modulePath": ".spago/effect/v3.0.0/src/Effect/Class.purs",
  "exports": [
    "liftEffect",
    "monadEffectEffect"
  ],
  "decls": [
    {
      "annotation": {
        "meta": {
          "metaType": "IsTypeClassConstructor"
        },
        "sourceSpan": {
          "start": [
            15,
            1
          ],
          "end": [
            16,
            42
          ]
        }
      },
      "identifier": "MonadEffect$Dict",
      "expression": {
        "annotation": {
          "meta": {
            "metaType": "IsNewtype"
          },
          "sourceSpan": {
            "start": [
              15,
              1
            ],
            "end": [
              16,
              42
            ]
          }
        },
        "body": {
          "annotation": {
            "meta": null,
            "sourceSpan": {
              "start": [
                15,
                1
              ],
              "end": [
                16,
                42
              ]
            }
          },
          "value": {
            "moduleName": null,
            "identifier": "x"
          },
          "type": "Var"
        },
        "argument": "x",
        "type": "Abs"
      },
      "bindType": "NonRec"
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            18,
            1
          ],
          "end": [
            19,
            24
          ]
        }
      },
      "identifier": "monadEffectEffect",
      "expression": {
        "annotation": {
          "meta": null,
          "sourceSpan": {
            "start": [
              18,
              1
            ],
            "end": [
              19,
              24
            ]
          }
        },
        "argument": {
          "annotation": {
            "meta": null,
            "sourceSpan": {
              "start": [
                18,
                1
              ],
              "end": [
                19,
                24
              ]
            }
          },
          "value": {
            "literalType": "ObjectLiteral",
            "value": [
              [
                "liftEffect",
                {
                  "annotation": {
                    "meta": null,
                    "sourceSpan": {
                      "start": [
                        19,
                        16
                      ],
                      "end": [
                        19,
                        24
                      ]
                    }
                  },
                  "argument": {
                    "annotation": {
                      "meta": null,
                      "sourceSpan": {
                        "start": [
                          0,
                          0
                        ],
                        "end": [
                          0,
                          0
                        ]
                      }
                    },
                    "value": {
                      "moduleName": [
                        "Control",
                        "Category"
                      ],
                      "identifier": "categoryFn"
                    },
                    "type": "Var"
                  },
                  "type": "App",
                  "abstraction": {
                    "annotation": {
                      "meta": {
                        "metaType": "IsForeign"
                      },
                      "sourceSpan": {
                        "start": [
                          19,
                          16
                        ],
                        "end": [
                          19,
                          24
                        ]
                      }
                    },
                    "value": {
                      "moduleName": [
                        "Control",
                        "Category"
                      ],
                      "identifier": "identity"
                    },
                    "type": "Var"
                  }
                }
              ],
              [
                "Monad0",
                {
                  "annotation": {
                    "meta": null,
                    "sourceSpan": {
                      "start": [
                        18,
                        1
                      ],
                      "end": [
                        19,
                        24
                      ]
                    }
                  },
                  "body": {
                    "annotation": {
                      "meta": null,
                      "sourceSpan": {
                        "start": [
                          0,
                          0
                        ],
                        "end": [
                          0,
                          0
                        ]
                      }
                    },
                    "value": {
                      "moduleName": [
                        "Effect"
                      ],
                      "identifier": "monadEffect"
                    },
                    "type": "Var"
                  },
                  "argument": "$__unused",
                  "type": "Abs"
                }
              ]
            ]
          },
          "type": "Literal"
        },
        "type": "App",
        "abstraction": {
          "annotation": {
            "meta": {
              "metaType": "IsNewtype"
            },
            "sourceSpan": {
              "start": [
                18,
                1
              ],
              "end": [
                19,
                24
              ]
            }
          },
          "value": {
            "moduleName": [
              "Effect",
              "Class"
            ],
            "identifier": "MonadEffect$Dict"
          },
          "type": "Var"
        }
      },
      "bindType": "NonRec"
    },
    {
      "annotation": {
        "meta": null,
        "sourceSpan": {
          "start": [
            16,
            3
          ],
          "end": [
            16,
            42
          ]
        }
      },
      "identifier": "liftEffect",
      "expression": {
        "annotation": {
          "meta": null,
          "sourceSpan": {
            "start": [
              16,
              3
            ],
            "end": [
              16,
              42
            ]
          }
        },
        "body": {
          "annotation": {
            "meta": null,
            "sourceSpan": {
              "start": [
                16,
                3
              ],
              "end": [
                16,
                42
              ]
            }
          },
          "caseExpressions": [
            {
              "annotation": {
                "meta": null,
                "sourceSpan": {
                  "start": [
                    16,
                    3
                  ],
                  "end": [
                    16,
                    42
                  ]
                }
              },
              "value": {
                "moduleName": null,
                "identifier": "dict"
              },
              "type": "Var"
            }
          ],
          "caseAlternatives": [
            {
              "binders": [
                {
                  "constructorName": {
                    "moduleName": [
                      "Effect",
                      "Class"
                    ],
                    "identifier": "MonadEffect$Dict"
                  },
                  "annotation": {
                    "meta": {
                      "metaType": "IsNewtype"
                    },
                    "sourceSpan": {
                      "start": [
                        16,
                        3
                      ],
                      "end": [
                        16,
                        42
                      ]
                    }
                  },
                  "typeName": {
                    "moduleName": [
                      "Effect",
                      "Class"
                    ],
                    "identifier": "MonadEffect$Dict"
                  },
                  "binders": [
                    {
                      "annotation": {
                        "meta": null,
                        "sourceSpan": {
                          "start": [
                            16,
                            3
                          ],
                          "end": [
                            16,
                            42
                          ]
                        }
                      },
                      "identifier": "v",
                      "binderType": "VarBinder"
                    }
                  ],
                  "binderType": "ConstructorBinder"
                }
              ],
              "expression": {
                "annotation": {
                  "meta": null,
                  "sourceSpan": {
                    "start": [
                      16,
                      3
                    ],
                    "end": [
                      16,
                      42
                    ]
                  }
                },
                "expression": {
                  "annotation": {
                    "meta": null,
                    "sourceSpan": {
                      "start": [
                        16,
                        3
                      ],
                      "end": [
                        16,
                        42
                      ]
                    }
                  },
                  "value": {
                    "moduleName": null,
                    "identifier": "v"
                  },
                  "type": "Var"
                },
                "fieldName": "liftEffect",
                "type": "Accessor"
              },
              "isGuarded": false
            }
          ],
          "type": "Case"
        },
        "argument": "dict",
        "type": "Abs"
      },
      "bindType": "NonRec"
    }
  ],
  "comments": [],
  "foreign": [],
  "sourceSpan": {
    "start": [
      1,
      1
    ],
    "end": [
      19,
      24
    ]
  }
}

I'm pretty sure there are other changes to CoreFn between 0.13.x and 0.14.x, and I'm not certain that psgo built against 0.13.x should function correctly over all possible outputs from purs 0.14.x (even with these changes).
However, something like this will be required for 0.14.x compatibility (I just don't think it's the whole story).

@jjthiessen
Copy link

jjthiessen commented Apr 21, 2022

TL;DR: Try using purs 0.13.x — it should resolve your issue.

@jjthiessen
Copy link

Also, my earlier

nix-shell stack.nix
stack --no-nix --system-ghc build

is because I'm running NixOS (and that's the closest I can get to a vanilla stack build).
A simple stack build should work in other environments.

@pmd3d
Copy link
Author

pmd3d commented Apr 22, 2022

yes, confirmed, purs 0.13.8 resolved issue.

@pmd3d
Copy link
Author

pmd3d commented Apr 23, 2022

Thank you for the info. Yes a stack build in Ubuntu worked after installing a library mentioned in this issue with some other project. haskell/haskeline#116

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.

2 participants