Skip to content

Commit

Permalink
experiments | ghc: well-typed/generics-sop#89
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire committed Oct 31, 2018
1 parent dba49b0 commit 9136ed3
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
41 changes: 41 additions & 0 deletions experiments/ghc/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# LANGUAGE UnicodeSyntax #-}
{-# OPTIONS_GHC -Wextra -Wno-unused-imports -Wno-unticked-promoted-constructors -Wno-type-defaults -Wno-missing-signatures #-}

module Main where

import Control.Monad.IO.Class
import qualified GHC.Generics as GHC
import Generics.SOP
import qualified Generics.SOP as SOP


class ( GHC.Generic a, SOP.Generic a, HasDatatypeInfo a
, forall xs. Code a ~ '[xs]) => Foo m a where

instance ( GHC.Generic a, SOP.Generic a, HasDatatypeInfo a
, forall xs. Code a ~ '[xs]
, Monad m) => Foo m a where

-- error:
-- • Could not deduce: Code a ~ '[xs]
-- arising from the superclasses of an instance declaration
-- from the context: (GHC.Generic a, HasDatatypeInfo a,
-- forall (xs :: [*]). Code a ~ '[xs], Monad m)
-- bound by the instance declaration
-- at /run/user/1000/danteazsW1Q.hs:(22,10)-(24,47)
-- • In the instance declaration for ‘Foo m a’


main IO ()
main = do

putStrLn "You are standing at the end of a road before a small brick building."
putStrLn "Around you is a forest. A small stream flows out of the building and"
putStrLn "down a gully."
17 changes: 17 additions & 0 deletions experiments/ghc/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ mkDerivation, stdenv, base, cabal-install, generics-sop
}:
mkDerivation {
pname = "holotype";
version = "0.0.1";
src = ./.;
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
base
cabal-install
generics-sop
];
description = "Graph-backed visual mind assistant";
license = stdenv.lib.licenses.agpl3;
doHaddock = false;
}
19 changes: 19 additions & 0 deletions experiments/ghc/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc861", doBenchmark ? false }:

let

inherit (nixpkgs) pkgs;

f = import ./default.nix;

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

variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;

drv = variant (haskellPackages.callPackage f {});

in

if pkgs.lib.inNixShell then drv.env else drv
6 changes: 6 additions & 0 deletions holotype.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,9 @@ executable lifted-record-holotree
main-is: Main.hs
default-language: Haskell2010
build-depends: base, base-unicode-symbols, containers, lens, TypeCompose

executable ghc
hs-source-dirs: experiments/ghc
main-is: Main.hs
default-language: Haskell2010
build-depends: base, base-unicode-symbols, containers, generics-sop, lens, TypeCompose

0 comments on commit 9136ed3

Please sign in to comment.