~jack/misc

be2bbe6b37a2a92e5d8a1a9de8a0e7cd80d6fc0e — Jack Kelly 2 years ago fd7ab4b
Add a reflex host (badly)
M consengine/consengine.cabal => consengine/consengine.cabal +2 -0
@@ 26,8 26,10 @@ library
                     , GLFW-b ^>= 3.2.1
                     , bytestring ^>= 0.10.8.2
                     , gl ^>= 0.8
                     , glow ^>= 0
                     , linear ^>= 1.20.9
                     , reflex ^>= 0.6
                     , reflex-basic-host ^>= 0.1
                     , reflex-sdl2 ^>= 0.3
                     , text ^>= 1.2.3.1
                     , vector ^>= 0.12.0.3

M consengine/consengine.nix => consengine/consengine.nix +4 -3
@@ 1,5 1,5 @@
{ mkDerivation, base, bytestring, gl, GLFW-b, linear, reflex
, reflex-sdl2, stdenv, text, vector
{ mkDerivation, base, bytestring, gl, GLFW-b, glow, linear, reflex
, reflex-basic-host, reflex-sdl2, stdenv, text, vector
}:
mkDerivation {
  pname = "consengine";


@@ 8,7 8,8 @@ mkDerivation {
  isLibrary = true;
  isExecutable = true;
  libraryHaskellDepends = [
    base bytestring gl GLFW-b linear reflex reflex-sdl2 text vector
    base bytestring gl GLFW-b glow linear reflex reflex-basic-host
    reflex-sdl2 text vector
  ];
  executableHaskellDepends = [ base ];
  license = stdenv.lib.licenses.gpl3;

M consengine/default.nix => consengine/default.nix +7 -0
@@ 6,6 6,8 @@
let
  inherit (nixpkgs) pkgs;

  codex = import ./nix/codex.nix;

  baseHaskellPackages = if compiler == "default"
                       then pkgs.haskellPackages
                       else pkgs.haskell.packages.${compiler};


@@ 23,6 25,11 @@ let
        jailbreak = true;
      });

      glow = super.callCabal2nix "glow" "${codex}/glow" {};
      ptrdiff = super.callCabal2nix "ptrdiff" "${codex}/ptrdiff" {};
      reflex-basic-host = super.callCabal2nix "reflex-basic-host"
        (import ./nix/reflex-basic-host.nix) {};

#      sdl2 = doJailbreak super.sdl2;
    };
  };

A consengine/nix/codex.json => consengine/nix/codex.json +7 -0
@@ 0,0 1,7 @@
{
  "url": "https://github.com/ekmett/codex",
  "rev": "9e6f74454fa727e16cf1fb3fd812fa675face601",
  "date": "2019-06-19T17:32:13+02:00",
  "sha256": "1pg827wnmd6kmq0ywa0mqvvm374nkzqy4n90cg30xsqak8m3dpzr",
  "fetchSubmodules": false
}

A consengine/nix/codex.nix => consengine/nix/codex.nix +9 -0
@@ 0,0 1,9 @@
let
  codexPin = builtins.fromJSON (builtins.readFile ./codex.json);

  codex = builtins.fetchGit {
    inherit (codexPin) url rev;
    ref = "master";
  };
in
  codex

A consengine/nix/reflex-basic-host.json => consengine/nix/reflex-basic-host.json +7 -0
@@ 0,0 1,7 @@
{
  "url": "https://github.com/qfpl/reflex-basic-host",
  "rev": "009354c2751fcbe3d798d756f548f2bcf767aaaa",
  "date": "2019-05-17T13:22:29+10:00",
  "sha256": "1ng3mfx0qa4wdw7vc9aihbkzf6cs7n7if53rg5jnxfj57h2xd3gl",
  "fetchSubmodules": false
}

A consengine/nix/reflex-basic-host.nix => consengine/nix/reflex-basic-host.nix +10 -0
@@ 0,0 1,10 @@
let
  reflex-basic-hostPin = builtins.fromJSON
    (builtins.readFile ./reflex-basic-host.json);

  reflex-basic-host = builtins.fetchGit {
    inherit (reflex-basic-hostPin) url rev;
    ref = "master";
  };
in
  reflex-basic-host

M consengine/src/App.hs => consengine/src/App.hs +15 -1
@@ 1,9 1,12 @@
{-# LANGUAGE FlexibleContexts  #-}
{-# LANGUAGE OverloadedLists   #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies      #-}

module App where

import           Control.Monad
import           Control.Monad.IO.Class (liftIO)
import           Data.Bits
import qualified Data.ByteString.Char8 as B
import           Data.Foldable


@@ 21,10 24,21 @@ import           Graphics.GL.Core45
import           Graphics.GL.Types
import qualified Graphics.UI.GLFW as GLFW
import           Linear.V3
import           Reflex
import           Reflex.Host.Basic (BasicGuest, BasicGuestConstraints, basicHostWithQuit)
import           System.Exit

main :: IO ()
main = do
main = basicHostWithQuit guest

guest :: BasicGuestConstraints t m => BasicGuest t m ((), Event t ())
guest =  do
  postBuildE <- getPostBuild
  performEvent_ $ postBuildE $> liftIO crap
  pure ((), never)

crap :: IO ()
crap = do
  ok <- GLFW.init
  unless ok $ exitFailure
  putStrLn "glfw init ok"