compiling-to-categories / concat

Compiling to Categories
http://conal.net/papers/compiling-to-categories
BSD 3-Clause "New" or "Revised" License
431 stars 49 forks source link

Error in compiling graphic example. #43

Open wpoosanguansit opened 5 years ago

wpoosanguansit commented 5 years ago

Hi,

I am just checking out the code and following the instruction in README. But I am getting these errors for graphic examples:

➜  concat git:(master) stack build :graphics-examples
concat-graphics-0.1.0.0: build (lib + test)
Preprocessing library concat-graphics-0.1.0.0...
Preprocessing test suite 'graphics-examples' for concat-graphics-0.1.0.0...
[1 of 1] Compiling Main             ( test/Examples.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/graphics-examples/graphics-examples-tmp/Main.o )

/Volumes/First/Projects/concat/graphics/test/Examples.hs:176:35: error:
    • Could not deduce (A.MonoidalPCat k) arising from a use of ‘A.&&&’
      from the context: (A.ClosedCat k,
                         A.FloatingCat k R,
                         A.NumCat k R,
                         A.Ok k (R :* R),
                         A.Ok k (R -> R))
        bound by the type signature for:
                   exampleC3' :: (A.ClosedCat k, A.FloatingCat k R, A.NumCat k R,
                                  A.Ok k (R :* R), A.Ok k (R -> R)) =>
                                 k R (R -> R)
        at test/Examples.hs:(173,1)-(175,28)
      Possible fix:
        add (A.MonoidalPCat k) to the context of
          the type signature for:
            exampleC3' :: (A.ClosedCat k, A.FloatingCat k R, A.NumCat k R,
                           A.Ok k (R :* R), A.Ok k (R -> R)) =>
                          k R (R -> R)
    • In the second argument of ‘(A..)’, namely ‘(A.exr A.&&& A.exl)’
      In the first argument of ‘A.curry’, namely
        ‘(A.addC A.. (A.exr A.&&& A.exl))’
      In the first argument of ‘(A..)’, namely
        ‘A.curry (A.addC A.. (A.exr A.&&& A.exl))’
Progress 1/2

--  While building custom Setup.hs for package concat-graphics-0.1.0.0 using:
      /Users/anonym/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.2.0 build lib:concat-graphics test:graphics-examples --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
➜  concat git:(master) stack --version
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2

And for stack build :misc-examples --flag concat-examples:smt:

/Volumes/First/Projects/concat/examples/src/ConCat/SMT.hs:208:28: error:
    • Could not deduce (MonoidalPCat k) arising from a use of ‘&&&’
      from the context: (ConstCat k r, OrdCat k r, Ok k a)
        bound by the type signature for:
                   andAbove :: (ConstCat k r, OrdCat k r, Ok k a) =>
                               k (a :* r) Bool -> r -> k (a :* r) Bool
        at src/ConCat/SMT.hs:(206,1)-(207,59)
      or from: ConCat.Category.Con (Ok' k (Prod k Bool Bool))
        bound by a type expected by the context:
                   ConCat.Category.Con (Ok' k (Prod k Bool Bool)) => k (a :* r) Bool
        at src/ConCat/SMT.hs:(208,20)-(211,26)
      or from: ConCat.Category.Con (Ok' k (Prod k r r))
        bound by a type expected by the context:
                   ConCat.Category.Con (Ok' k (Prod k r r)) => k (a :* r) Bool
        at src/ConCat/SMT.hs:(208,20)-(210,23)
      or from: ConCat.Category.Con (Ok' k (Prod k a r))
        bound by a type expected by the context:
                   ConCat.Category.Con (Ok' k (Prod k a r)) => k (a :* r) Bool
        at src/ConCat/SMT.hs:(208,20)-(209,23)
      Possible fix:
        add (MonoidalPCat k) to the context of
          the type signature for:
            andAbove :: (ConstCat k r, OrdCat k r, Ok k a) =>
                        k (a :* r) Bool -> r -> k (a :* r) Bool
    • In the second argument of ‘(.)’, namely
        ‘(greaterThan . (exr &&& const lower) &&& f)’
      In the first argument of ‘(<+)’, namely
        ‘andC . (greaterThan . (exr &&& const lower) &&& f)’
      In the first argument of ‘(<+)’, namely
        ‘andC . (greaterThan . (exr &&& const lower) &&& f)
         <+ okProd @k @a @r’
Progress 2/3

--  While building custom Setup.hs for package concat-examples-0.3.0.0 using:
      /Users/watt/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.2.0 build lib:concat-examples test:misc-examples --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

I am on a MacOs High Sierra.

Thanks.

conal commented 5 years ago

Thanks! Both issues are fixed now.

wpoosanguansit commented 5 years ago

Thank you. I did pull and retry. I do get the graphic to show up for graphic example. But with these errors in the console:

/Volumes/First/Projects/concat/graphics/In file included from /var/folders/ms/s5m_0bpx2h76hgcshjzby8f80000gn/T/ghc70471_0/ghc_3.c:1:0: error:

/Volumes/First/Projects/concat/graphics/In file included from /Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/Rts.h:217:0: error:

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:505:5: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF || ZERO_SLOP_FOR_SANITY_CHECK
    ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:502:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_LDV_PROF'
#define ZERO_SLOP_FOR_LDV_PROF     (defined(PROFILING))
                                    ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:505:31: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF || ZERO_SLOP_FOR_SANITY_CHECK
                              ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                    ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:505:31: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:56: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                                       ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:523:5: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
    ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:502:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_LDV_PROF'
#define ZERO_SLOP_FOR_LDV_PROF     (defined(PROFILING))
                                    ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:523:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
                               ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                    ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:523:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:56: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                                       ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:552:5: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
    ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:502:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_LDV_PROF'
#define ZERO_SLOP_FOR_LDV_PROF     (defined(PROFILING))
                                    ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:552:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
                               ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                    ^

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:552:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]

/Users/anonym/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:56: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                                       ^
9 warnings generated.
clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]
concat-graphics-0.1.0.0: copy/register
Installing library in
/Volumes/First/Projects/concat/.stack-work/install/x86_64-osx/lts-9.20/8.0.2/lib/x86_64-osx-ghc-8.0.2/concat-graphics-0.1.0.0-FrPPXQe1zgW3mRLKXOASZD
Registering concat-graphics-0.1.0.0...
concat-graphics-0.1.0.0: test (suite: graphics-examples)

But I still get compile errors for stack build :misc-examples --flag concat-examples:smt

/Volumes/First/Projects/concat/examples/test/Examples.hs:154:1: error:
    Failed to load interface for ‘ConCat.StackMachine’
    Use -v to see a list of the files searched for.

/Volumes/First/Projects/concat/examples/test/Examples.hs:155:1: error:
    Failed to load interface for ‘ConCat.StackMachine’
    Use -v to see a list of the files searched for.
Progress 1/2

--  While building custom Setup.hs for package concat-examples-0.3.0.0 using:
      /Users/anonym/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.2.0 build lib:concat-examples test:misc-examples --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

Appreciate your help.

conal commented 5 years ago

I just pushed examples/test/Examples.hs. Hopefully fixes the compile errors.

I've not seen those warning messages. A quick web search turns up some hits. Are you using nix? I've not tried concat in that setting.