tweag / monad-bayes

A library for probabilistic programming in Haskell.
MIT License
407 stars 62 forks source link

Port to brick versions >= 1.0 #229

Closed vkleen closed 1 year ago

vkleen commented 1 year ago

This PR contains the necessary changes for supporting brick versions between 1.0 and 2.0, fixing #221.

Alternatively, the brick version would need to be constrained to be 0.73 or less. If this would be preferably, please just close this PR.

netlify[bot] commented 1 year ago

Deploy Preview for monad-bayes canceled.

Name Link
Latest commit 2746dbec42f4b9f008763ef41b9a899a5fb18a93
Latest deploy log https://app.netlify.com/sites/monad-bayes/deploys/636639b76b7b9300090cced0
netlify[bot] commented 1 year ago

Deploy Preview for monad-bayes-site canceled.

Name Link
Latest commit 2746dbec42f4b9f008763ef41b9a899a5fb18a93
Latest deploy log https://app.netlify.com/sites/monad-bayes-site/deploys/636639b7f363770008fec59f
reubenharry commented 1 year ago

Amazing, thank you! Looks like nix is taking a while on CI, but upgrading to the newer brick sounds ideal.

vkleen commented 1 year ago

I think a vty test is hanging indefinitely on x86_64-darwin, but I have no idea why. In principle, I could try disabling tests for vty on darwin but I'm not sure whether that's a real issue or just a false negative; I don't have a Mac to check, unfortunately.

idontgetoutmuch commented 1 year ago

The tests pass for me on macOS albeit I didn't use the flake; I just used my shell.nix

let

myHaskellPackageOverlay = self: super: {
  myHaskellPackages = super.haskellPackages.override {
    overrides = hself: hsuper: rec {

    };
  };
};

in

{ nixpkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixpkgs-22.05-darwin.tar.gz")
  {
    overlays = [ myHaskellPackageOverlay ];
  }
}:

let
  R-with-my-packages = nixpkgs.rWrapper.override{
    packages = with nixpkgs.rPackages; [
      ggplot2
      reshape2
      tidyverse
      jqr
      RPostgres
      readxl
      openxlsx
    ]; };

  pkgs = nixpkgs;

  monad-bayes = pkgs.haskell.packages.ghc902.developPackage {
    name = "monad-bayes";
    root = "/Users/dom/Dropbox/Tidy/monad-bayes-maria";

    # Remove this override when bumping nixpkgs
    source-overrides = {
      vty = pkgs.fetchzip {
        url = "mirror://hackage/vty-5.37/vty-5.37.tar.gz";
        sha256 = "sha256-OOrJBi/mSIyaibgObrp6NmUTWxRu9pxmjAL0EuPV9wY=";
      };

      text-zipper = pkgs.fetchzip {
        url = "mirror://hackage/text-zipper-0.12/text-zipper-0.12.tar.gz";
        sha256 = "sha256-P2/UHuG3UuSN7G31DyYvyUWSyIj2YXAOmjGkHtTaP8o=";
      };

      bimap = pkgs.fetchzip {
        url = "mirror://hackage/bimap-0.5.0/bimap-0.5.0.tar.gz";
        sha256 = "sha256-pbw+xg9Qz/c7YoXAJg8SR11RJGmgMw5hhnzKv+bGK9w=";
      };

      brick = pkgs.fetchzip {
        url = "mirror://hackage/brick-1.4/brick-1.4.tar.gz";
        sha256 = "sha256-KDa7RVQQPpinkJ0aKsYP0E50pn2auEIP38l6Uk7GmmE=";
      };
    };

    cabal2nixOptions = "--benchmark";
  };

  haskellDeps = ps: with ps; [
    ad
    base
    cassava
    hasql
    http-client
    http-client-tls
    http-conduit
    microlens
    monad-bayes
    monad-extras
    path
    path-io
    pipes
    postgresql-binary
    process
    unix-compat
    vinyl
    xlsx
    zip
    base brick containers foldl free histogram-fill ieee754 integration
    lens linear log-domain math-functions matrix monad-coroutine
    monad-extras mtl mwc-random pipes pretty-simple primitive random
    safe scientific statistics text transformers vector vty

    random-fu
    hspec

    Chart
    Chart-diagrams
    diagrams-svg
    diagrams-rasterific
  ];

in

pkgs.stdenv.mkDerivation {
  name = "rOnly";

  buildInputs = [
    pkgs.libintlOrEmpty
    R-with-my-packages
    pkgs.postgresql_13
    pkgs.lhs2tex
    (pkgs.myHaskellPackages.ghcWithPackages haskellDeps)
    pkgs.darwin.apple_sdk.frameworks.Cocoa
  ];
}