Code Monkey home page Code Monkey logo

uhc's Introduction

The Utrecht Haskell Compiler (UHC)
==================================

When installing from this (https://github.com/UU-ComputerScience/uhc)
repo also use the repo for uhc-util
(https://github.com/UU-ComputerScience/uhc-util) as these are kept in
sync. For further installation instructions see EHC/README in the
subdirectory EHC holding the actual compiler.

Alternatively, and with less features, a lightweight variant of UHC is
available on hackage: https://hackage.haskell.org/package/uhc-light. Its
version lags behind the master of this repo.

Supported platforms
===================

UHC currently compiles/runs on MacOSX (10.11) with GHC 7.10.
Compiling on other Unix platforms in general does not give problems,
but is somewhat unpredictable due the great variation in combinations.

uhc's People

Contributors

a-middelk avatar asr avatar atzedijkstra avatar doaitse avatar dreixel avatar jbransen avatar jeroenfokker avatar kosmikus avatar mistuke avatar mstewartgallus avatar norm2782 avatar passalaqua avatar phile314 avatar rubendg avatar spockz avatar tomlokhorst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uhc's Issues

uhc-light-1.1.8.6 has Haddock syntax errors

Citing from http://hydra.cryp.to/build/527376/log/raw:

Running Haddock for uhc-light-1.1.8.6...
Running hscolour for uhc-light-1.1.8.6...
Preprocessing library uhc-light-1.1.8.6...
Preprocessing executable 'uhcl' for uhc-light-1.1.8.6...
Preprocessing executable 'uhcr' for uhc-light-1.1.8.6...
Preprocessing library uhc-light-1.1.8.6...

src/ehc/CoreRun/Prim.chs:132:3:
    parse error on input ‘-- | RP_readFile                  -- :: FilePath -> IO String
  -- | RP_writeFile                 -- :: FilePath -> String -> IO ()
  -- | RP_appendFile                -- :: FilePath -> String -> IO ()’

make fails, not finding module "UHC.Compiler.Base.Parser2"

./configure does not indicate anything missing, but running make quickly ends up in an error:

[...]
Configuring UHC-Compiler-1.1...
Building UHC-Compiler-1.1...
Preprocessing library UHC-Compiler-1.1...
In-place registering UHC-Compiler-1.1...
Installing library in
/home/markus/dev/uhc/EHC/install-for-build//lib/x86_64-linux-ghc-7.6.3/UHC-Compiler-1.1
Registering UHC-Compiler-1.1...
mkdir -p build/101
/home/markus/.cabal/bin/shuffle --hs --preamble=no --lhs2tex=no --line=yes --compiler=7.6.3 --def=EH:UHC.Compiler. --def=VARIANT:101 --def="ASPECTS:base codegen core corein coreout grin hmtyinfer javascript machdep noHmTyRuler" --gen-reqm="(101 base codegen core corein coreout grin hmtyinfer javascript machdep noHmTyRuler)" --base=Main --variant-order="1 < 2 < 3 < 4 < 4_99 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < 14 < 15 < 17 < 19 < 20 < 30 < 31 < 50 < 90 < 91 < 92 < 93 < 96 < 97 < 98 < 99 < 100 < 101, 100 < 102, 100 < 103, 6 < 6_4, 15 < 41" src/ehc/EHC.chs > build/101/EHC.hs && \
        touch build/101/EHC.hs
mkdir -p install/101/bin/ && \
        /usr/bin/ghc --make  -package uulib -package uhc-util -rtsopts -rtsopts  -package UHC-Compiler \
               -ibuild/101/ build/101/EHC.hs -o install/101/bin/ehc

build/101/EHC.hs:27:8:
    Could not find module `UHC.Compiler.Base.Parser2'

this is my ./configure output:

Version : 1.1.7.2
GIT hash: master@4c675d65fb
Installation/build summary.
  host                          : x86_64-unknown-linux-gnu
  prefix                        : /usr/local
  build suffix                  : 
  hardbaked aspects             : 
Required:
  uuagc is available?           : yes
    version                     : Attribute Grammar compiler / HUT project. Version 0.9.51
    command for uuagc           : /home/markus/.cabal/bin/uuagc
  shuffle is available?         : yes
    version                     : 0.1.3.1
    command for shuffle         : /home/markus/.cabal/bin/shuffle
  ghc is available?             : yes
    version                     : 7.6.3
    command for ghc             : /usr/bin/ghc
    command for ghc raw         : /usr/bin/ghc
    libraries:
      required and present      : process-1.2.0.0 array-0.4.0.1 containers-0.5.0.0 directory-1.2.1.0 mtl-2.2.1 base-4.6.0.1 uhc-util-0.1.3.9 hashable-1.2.2.0 binary-0.7.2.2 network-2.6.0.2 uulib-0.9.16 syb-0.4.2 vector-0.10.12.1 fgl-5.5.0.1 
  gcc is available?             : yes
    version                     : 4.8
    command for gcc             : /usr/bin/gcc
    uhc options to gcc          :  
  cpp is available?             : yes
    version                     : cpp (Ubuntu 4.8.2-19ubuntu1) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    command for cpp             : /usr/bin/cpp
    uhc options to cpp          :   -D__STDC__
  MP library                    : ltm
Required but not (yet) or during build enforced:
  cabal base dependencies       :  fgl hashable>=1.1&&<1.3 uhc-util>=0.1.3.7 base>=4&&<5  vector syb uulib network binary mtl directory containers array process
  cabal extra dependencies      : 
  build tool dependencies       : shuffle>=0.1.3.1 uuagc>=0.9.50.2 
Optional:
  haddock is available?         : yes
    version                     : Haddock version 2.13.2.1, (c) Simon Marlow 2006
    command for haddock         : /home/markus/.cabal/bin/haddock
Absolute location of directories:
  ehc repository                : /home/markus/dev/uhc/EHC
  ehc repository raw            : /home/markus/dev/uhc/EHC
  unix root prefix raw          :

Compilation fails on 32bit / i686 systems

Compilation fails on 32bit / i686 systems:

touch build/101/rts/bc/bc/interpreter.c
building build/101/rts/bc/bc/interpreter.o
/nix/store/icgwaw22fjy9c50rwc334hsc68xrs2w2-clang-wrapper-3.5.0/bin/clang -I/tmp/nix-build-uhc-1.1.8.7.drv-0/uhc-0dec07e/EHC/install/101/shared/include/ -std=gnu99 -Wno-array-bounds  -fomit-frame-pointer -D__UHC_BUILDS_RTS__ -O3 -D__UHC_TARGET_BC__ -D__UHC_TARGET__=bc -o build/101/rts/bc/bc/interpreter.o -c build/101/rts/bc/bc/interpreter.c
build/101/rts/bc/bc/interpreter.c:317:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
fatal error: error in backend: Invalid register name global variable
clang-3.5: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 3.5.0 (tags/RELEASE_350/final)
Target: i386-pc-linux-gnu
Thread model: posix
clang-3.5: note: diagnostic msg: PLEASE submit a bug report to  and include the crash backtrace, preprocessed source, and associated run script.
clang-3.5: note: diagnostic msg: 

Full log:
http://hydra.nixos.org/build/20345965/log/raw

I don't care if this gets fixed or not, but I'm opening the issue anyway in case somebody else runs into the same problem. Feel free to close.

Compile fails silently when src dir is not writable

Compile fails silently when src dir is not writable

I have some code which can end up in a directory which is not writable ( Haskell sources in Agdas cabal data files installed system-wide ).

Minimal example:

layout:

src/        (not writable)
src/Test.hs   
out/        (writable)

If the source directory is not writable, no compilation takes place and no error message is printed either. Example commands:

$ chmod -R -w src
$ uhc --odir=out --compile-only src/Test.hs
$

After giving write permissions on src, it works:

$ chmod +w src/
$ uhc --odir=out --compile-only src/Test.hs
[1/1] Compiling Haskell                  Test                   (src/Test.hs)
$

Preferrably uhc should work even if it has not write permissions in the source folders when using --odir. Alternatively, it should print an error message or panic.

(I can work around the problem by copying the Haskell sources to a temporary directory with write permissions, if necessary.)

Add support for GHC 7.10

Add support for GHC 7.10 to UHC and all dependencies. The following uhc-specific tools/libs need to be checked:

-uulib (done)
-uhc-util (done fails, http://hydra.cryp.to/build/698022/log)
-uuagc (done)
-uuagc-cabal (done fails, http://hydra.cryp.to/build/689052/log)
-uuagc-bootstrap (fails, http://hydra.cryp.to/build/699943/log )
-shuffle (done fails, http://hydra.cryp.to/build/722468/log/tail-reload )
-uhc (done)

@Atze @jbransen There is no public repo for uuagc/uuagc-cabal/uuagc-bootstrap as far as I know. Is it maybe possible to move these projects to Github too?

I will take a look at uhc-util later this week. If uuagc/uuagc-cabal/uuagc-bootstrap are moved to Github, I could also look at those.

If anyone else wants to work on any of these, maybe post a short comment here.

Use cabal sandboxes for building UHC

UHC could be built inside a cabal sandbox instead of using the global package db. This would avoid
any collisions between wrong package versions already installed.

Just an idea, not a problem for me. Would make it easier for other people to install it I think.

ordering of flag --pkg-hide-all matters

Main.hs consists only of
main = print "Hallo world!"

uhc --pkg-expose=base --pkg-hide-all Main.hs
hides all packages and it errors as it cannot find module Prelude
File not found:
file name : Prelude
searched locations: " (directory)"
"_build (directory)"
" (package database)"

Reuse previous compile results for bcr files

Currently, bcr files are always compiled from scratch. It would be good if this were avoided when the
bcr files have not changed. UHC already does this for Haskell files (.hs).

This requires some larger changes in the UHC Compiler Driver, and first requires a refactoring of the UHC compiler driver.

It is unlikely that this change makes it into UHC in the near future.

Definition of infix function x ! y is misparsed as bang pattern

Hi,

The following code should define a binary function (!) and then use it to define a value x:

(!) :: a -> b -> c
x ! y = undefined
x = 0 ! 0

Unfortunately, I get an error that x is defined twice:

Name(s) for value(s) introduced more than once:
    Test.x: Test.hs:4:1 (function)
            Test.hs:5:1 (value)

The reason is that in the definition x ! y = undefined, the ! is parsed as a bang pattern so it becomes x (!y) = undefined. This causes the containers package to fail to compile on UHC.

I worked around this by defining (!) prefix but thought I should report it anyway.

Missing support for GHC 8

Using GHC 8.0.1 RC 2:

$ cabal unpack uhc-light
$ cd uhc-light-1.1.9.2
$ cabal sandbox init
$ cabal install
...
rejecting: hashable-1.2.4.0 (conflict: uhc-light => hashable>=1.1 && <1.2.4)
...
Dependency tree exhaustively searched.

hashable 1.2.4 is required with GHC 8 but it was removed in #69.

ANormal Trf is not always run, causes runtime errors

If I compile binary Core Code, the ANormal transformation is not always run. This leads to crashes at
runtime or wrong output.

It looks like ANormal is never applied to the Main-module, and only sometimes to non-Main modules.

A small example reproducing the error is https://github.com/phile314/uhc/blob/3fb2d82f26a2afe1f60b4b7e1855d7bb5d404053/EHC/demo/CoreApi.hs .
Commenting out line 33, and instead using line 35 reproduces the error (prints the empty string instead of "HelloWorld").

Looks to me like the problem is in Core/Trf.chs, it doesn't seem to apply all transformations. With dump-core-stages=1 I get the following files:
CoreApiProg.tcr-permodule-10-let-defbefuse
CoreApiProg.tcr-permodule-1-initial
CoreApiProg.tcr-permodule-2-fix-postparse
CoreApiProg.tcr-permodule-3-let-defbefuse
CoreApiProg.tcr-permodule-4-let-flatstr
CoreApiProg.tcr-permodule-5-inl-letali
CoreApiProg.tcr-permodule-6-elim-trivapp
CoreApiProg.tcr-permodule-7-const-prop
CoreApiProg.tcr-permodule-8-inl-letali
CoreApiProg.tcr-permodule-9-elim-trivapp

Build error : make uhc : build/101/ehclib/hsc2hs: line 39

I get the following error when performing make uhc:

build/101/ehclib/hsc2hs: line 39: /Users/Jarno/dev/checkouts/uhc/EHC/build/101/lib/ghc-7.10.2/bin/hsc2hs: No such file or directory
build/101/ehclib/hsc2hs: line 39: exec: /Users/Jarno/dev/checkouts/uhc/EHC/build/101/lib/ghc-7.10.2/bin/hsc2hs: cannot execute: No such file or directory
make[2]: *** [build/101/ehclib/base/System/CPUTime.hs] Error 126
make[1]: *** [install/101/lib/pkg/base-3.0.0.0/101/bc/plain/CompileAll] Error 2
make: *** [101/ehclibs] Error 2

The requested path seems incorrect:
/Users/Jarno/dev/checkouts/uhc/EHC/build/101/lib/ghc-7.10.2/bin/hsc2hs

I fixed the problem by removing the prefix $(EHCLIB_BLD_VARIANT_ASPECTS_PREFIX) from uhc/EHC/ehclib/files2.mk (line 365). Now it uses my global hsc2hs binary.
Not a real solution of course, but it works for me.

I'm not sure about the intended behaviour.

Build failure

[161 of 259] Compiling UHC.Compiler.EHC.Main.Utils ( UHC/Compiler/EHC/Main/Utils.hs, dist/build/UHC/Compiler/EHC/Main/Utils.o )
src/ehc/EHC/Main/Utils.chs:122:47:
    Not in scope: data constructor ‘ECUS_CoreRun’
    Perhaps you meant ‘ECUS_Core’ (imported from UHC.Compiler.EHC.Common)

src/ehc/EHC/Main/Utils.chs:122:60:
    Not in scope: data constructor ‘CRRStartBinary’
    Perhaps you meant ‘CRStartBinary’ (imported from UHC.Compiler.EHC.Common)

UHC version: current head (91da468)
uhc-util: 0.1.5.0
uulib: 0.9.16
ghc: 7.8.4
cabal: 1.22.1.1

Building when mtl-2.2.1 is present does not work

editing the cabal file such that the constraint mtl==2.1.2 is present does work
this has to be added somewhere in the configure/make files but i cant find the correct place

Configuring UHC-Compiler-1.1...
Warning: This package indirectly depends on multiple versions of the same
package. This is highly likely to cause a compile failure.
package uhc-util-0.1.3.9 requires mtl-2.1.2
package parsec-3.1.3 requires mtl-2.1.2
package fgl-5.4.2.4 requires mtl-2.1.2
package UHC-Compiler-1.1 requires mtl-2.2.1
package mtl-2.1.2 requires transformers-0.3.0.0
package mtl-2.2.1 requires transformers-0.4.1.0

cabal --uhc install transformers fails

Resolving dependencies...
Configuring transformers-0.3.0.0...
Building transformers-0.3.0.0...
Preprocessing library transformers-0.3.0.0...
:0: warning: "STDC" redefined [enabled by default]
:0: note: this is the location of the previous definition
Control/Monad/Trans/Error.hs:60: error: missing binary operator before token "("
Control/Monad/Trans/Error.hs:71: warning: missing terminating " character [enabled by default]
Control/Monad/Trans/Error.hs:97: error: missing binary operator before token "("
Control/Monad/Trans/Error.hs:146: warning: missing terminating ' character [enabled by default]
Control/Monad/Trans/Error.hs:148: warning: missing terminating ' character [enabled by default]
cabal: Error: some packages failed to install:
transformers-0.3.0.0 failed during the building phase. The exception was:
ExitFailure 1

Javascript Backend: Data.Char.toLower and toUpper are not Implemented

Code like map toLower "HELLO" results in an error message like Uncaught ReferenceError: primCharToLower is not defined (at runtime in the browser).

To fix this issue I defined primCharToLower like this:

primCharToLower = function(charCode) {
  return String.fromCharCode(charCode).toLowerCase().charCodeAt(0);
};

The same goes for primCharToUpper.

using --pkg-hide-all and --pkg-expose it cannot find transitive packages

Main.hs consists only of
main = print "Hallo world!"

uhc --pkg-hide-all --pkg-expose=base Main.hs
it cannot find the files in another pkg than base
File not found:
file name : UHC/Show
searched locations: "/usr/local/lib/uhc-1.1.7.0/lib/pkg/base-3.0.0.0/uhc-1.1.7.0/bc/plain (package: base-3.0.0.0(in: /usr/local/lib/uhc-1.1.7.0/lib/pkg/base-3.0.0.0/uhc-1.1.7.0/bc/plain))"
" (directory)"
"_build (directory)"
" (package database)"

UHC git head doesn't build without ruler

Continuing our earlier email discussion, I tried to build current UHC git head but this fails on my machine.
Configure works, but the makefile seems to cause problems:

./configure --prefix /tmp/test-uhc
... snip ...
Version : 1.1.9.1
GIT hash: master@fa16f901f7
Installation/build summary.
  host                          : x86_64-unknown-linux-gnu
  prefix                        : /tmp/test-uhc
  build suffix                  : 
  hardbaked aspects             : 
Required:
  uuagc is available?           : yes
    version                     : Attribute Grammar compiler / HUT project. Version 0.9.51
    command for uuagc           : /home/philipp/.nix-profile/bin/uuagc
  shuffle is available?         : yes
    version                     : 0.1.3.3
    command for shuffle         : /home/philipp/.nix-profile/bin/shuffle
  ghc is available?             : yes
    version                     : 7.8.4
    command for ghc             : /home/philipp/.nix-profile/bin/ghc
    command for ghc raw         : /home/philipp/.nix-profile/bin/ghc
    libraries:
      required and present      : filepath-1.3.0.2 process-1.2.0.0 array-0.5.0.0 containers-0.5.5.1 directory-1.2.1.0 transformers-0.3.0.0 mtl-2.1.3.1 base-4.7.0.2 uhc-util-0.1.5.6 hashable-1.2.3.0 binary-0.7.1.0 network-2.6.0.2 uulib-0.9.20 syb-0.4.2 vector-0.10.12.2 fgl-5.5.0.1 
  gcc is available?             : yes
    version                     : 4.9.2
    command for gcc             : /usr/bin/gcc
    uhc options to gcc          :  
  cpp is available?             : yes
    version                     : cpp (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6) Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    command for cpp             : /usr/bin/cpp
    uhc options to cpp          :   -D__STDC__
  MP library                    : ltm
Required (or optional) but not (yet) or during build enforced:
  cabal base dependencies       :  fgl uulib>=0.9.19 hashable>=1.1&&<1.3 uhc-util>=0.1.6.1&&<0.1.7 base>=4.7&&<5  vector syb network binary mtl transformers directory containers array process filepath
  cabal extra dependencies      : 
  build tool dependencies       : shuffle>=0.1.3.1 uuagc>=0.9.50.2 
  (optional) build tool dpdcies : 
Other:
  haddock is available?         : yes
    version                     : Haddock version 2.14.3, (c) Simon Marlow 2006
    command for haddock         : /home/philipp/.nix-profile/bin/haddock
  ruler is available?           : no
Absolute location of directories:
  ehc repository                : /home/philipp/Projects/uhc/uhc2/EHC
  ehc repository raw            : /home/philipp/Projects/uhc/uhc2/EHC
  unix root prefix raw          : 
$ make
src/ehc/files1.mk:468: *** multiple target patterns.  Stop.

The commit introducing this problem:

f0d85858ca1d309f57edda08d9f3a55c5b54a5ec is the first bad commit
commit f0d85858ca1d309f57edda08d9f3a55c5b54a5ec
Author: Atze Dijkstra 
Date:   Wed Sep 16 16:58:09 2015 +0200

    fixing debugging stuff for type checker, fix for type pretty print which did incorrectly print tyvars

I used a freshly cloned git repository, so there should be no old files lying around.

uhc pollutes source directories

I'd use the --odir option but unfortunately that implies the --compile-only option. Why shouldn't I use --odir for a file with a main method?

UHC dependencies are not strict enough

UHC has no upper bound on uulib/uhc-util. If a new version of these libraries with breaking API changes is released, old UHC versions dont build anymore. See for example http://hydra.nixos.org/build/20949218/log/tail-reload , which tries to build uhc 1.1.8.7 with the current version of uulib/uhc-util.

I propose to make UHC depend on a specific version of these two libraries, to avoid this kind of breakage in the future. So the uhc-util >= 0.1.5.3 dependency becomes uhc-util == 0.1.5.3.

If you agree, I can prepare a pull-request later on?

Cannot find required EH-Util package dependency

The make script fails looking for the EH-Util package, which does not seem to be available through the cabal tool.

make INCLUDE_DERIVED_MK=yes EHC_VARIANT=`echo install/101/bin/ehc | sed -n -e 's+install/\([0-9_]*\)/bin/ehc.*+\1+p'` ehc-variant
/usr/bin/ghc --make -fglasgow-exts  -package uulib -rtsopts -O2 -rtsopts  -ignore-package uulib-debug -package EH-Util -ibuild/shuffle/ build/shuffle/Shuffle.hs -o bin/shuffle

on the commandline:
    Warning: -fglasgow-exts is deprecated: Use individual extensions instead
<command line>: cannot satisfy -package EH-Util
    (use -v for more information)
make \
       \
      ehc-variant-dflt
/usr/bin/ghc --make -fglasgow-exts  -package uulib -rtsopts -O2 -rtsopts  -ignore-package uulib-debug -package EH-Util -ibuild/shuffle/ build/shuffle/Shuffle.hs -o bin/shuffle

on the commandline:
    Warning: -fglasgow-exts is deprecated: Use individual extensions instead
<command line>: cannot satisfy -package EH-Util
    (use -v for more information)
make[1]: *** [ehc-variant] Error 2
make: *** [install/101/bin/ehc] Error 2
bok048:EHC jpmayer$ cabal install EH-Util
cabal: There is no package named 'EH-Util'.
You may need to run 'cabal update' to get the latest list of available
packages.

UHC cannot parse empty record

data Inh_SStrings = Inh_SStrings {}
gives a lot of errors (see below)

This makes the UUAGC unusabel with UHC as
this is generated

*** ERROR ***
AG.hs(15,33):
Expecting : var
Repaired by: deleting: Symbol symbol } at line 15, column 33 of file "AG.hs"
*** ERROR ***
AG.hs(16,1):
Expecting : var
Repaired by: deleting: SemiColon
*** ERROR ***
AG.hs(16,1):
Expecting : var
Repaired by: deleting: Symbol symbol data at line 16, column 1 of file "AG.hs"
*** ERROR ***
AG.hs(16,6):
Expecting : var
Repaired by: deleting: Symbol upper case identifier Syn_SString at line 16, column 6 of file "AG.hs"
*** ERROR ***
AG.hs(16,18):
Expecting : var
Repaired by: deleting: Symbol symbol = at line 16, column 18 of file "AG.hs"
... and more errors

Translation to JS fails

Hi Atze,
after successfully installing UHC (thanks again for #62), I tried to translate a mid-complex program to JavaScript and ran into multiple error that fail the process.

A simple HelloWorld can be translated without problems and produces very little JavaScript code, which makes UHC very interesting for me. I translated HelloWorld with GHCJS and Fay, both give you an extreme overhead of code...

Error log:
uhc -tjs Ambiguity.hs ParseRE.hs [1/2] Compiling Haskell Ambiguity (Ambiguity.hs) Parse (Haskell syntax) of module 'Ambiguity' *** ERROR *** Ambiguity.hs(1,1): Expecting : CloseBrace or pImportDeclaration or pTopDeclaration or (Symbol symbol ; or Nothing expected ...)* Repaired by: deleting: Symbol symbol {-# at line 1, column 1 of file "Ambiguity.hs" *** ERROR *** Ambiguity.hs(1,20): Expecting : Symbol symbol :: or pPatternConSuffix or pRhs or qconop or varop_no_bang or (pPatternBaseCon ...)* Repaired by: deleting: Symbol symbol #-} at line 1, column 20 of file "Ambiguity.hs" *** ERROR *** Ambiguity.hs(3,1): Expecting : Symbol symbol :: or pRhs or varop_no_bang Repaired by: deleting: SemiColon *** ERROR *** Ambiguity.hs(3,1): Expecting : Symbol symbol :: or pRhs or varop_no_bang Repaired by: deleting: Symbol symbol import at line 3, column 1 of file "Ambiguity.hs" *** ERROR *** Ambiguity.hs(3,8): Expecting : Symbol symbol :: or pRhs or varop_no_bang Repaired by: deleting: Symbol upper case qualified identifier System.Environment at line 3, column 8 of file "Ambiguity.hs" ... and more errors

The first few lines of the file Ambiguity.hs look like this:
{-# LANGUAGE GADTs #-} import System.Environment import Data.List import Data.Maybe import ParseRE

I can send you the 2 files if you want to have a closer look.

System.Environment is used to call getArgs when running the program from the command line, could be changes if this import is a problem.
GADTs are frequently used, is that supported in UHC?!

Many thanks in advance, nice project and great support in here! 😃

Sincerely,
Tobias

Core case expression requires total pattern matches?

Hi Atze,

Running the first regression tests on the Agda UHC backend already did catch some first bugs.... which raised a question about UHC Core. When I compile Haskell programs, one Core case alternative is produced for each possible constructor. Eg the following HS produces following pseudo-core:

data A = B | C | D | E | F

f :: A -> Int
f C = 1
f _ = 2

produces

case temp of
    Tag 0 -> 2
    Tag 1 -> 2
    Tag 2 -> 1
    Tag 3 -> 2
    Tag 4 -> 2

Now it seems that stuff starts to break when I instead use the default-branch instead of replicating the default value for all not-covered constructors. Eg.

case temp of
    Tag 2 -> 1
    default -> 2

This will yield the wrong result.

What is the best way forward? Should I just generate "total" case alternatives as well? Speaking just for myself, I think using the default feels more elegant, but I don't care too much about it. Otherwise I would just document the current behaviour in the Core API and not expose the default-alternative anymore.

Philipp

--odir in combination with --target=js causes the paths that refer the standard libraries in the html file to be set incorrectly

when building an executable from the following line of code to javascript: (stored in Main.hs)
main = print "hello"

uhc -o Main.html --target=js Main.hs
works fine as it produces the correct script includes in the html file: e.g.

<script type="text/javascript" src="/usr/local/lib/uhc-1.1.7.0/lib/pkg/uhcbase-1.1.7.0/uhc-1.1.7.0/js/plain/UHC/UHC_Base.mjs"></script>

uhc --odir=. -o Main.html --target=js Main.hs
this does not work as it not refers to non-existing files e.g.

<script type="text/javascript" src="./UHC/UHC_Base.mjs"></script>

`exists` parsed as existential quantification in expression

Inside a do block exists is read as existential quantifier.

module Main where

main = do exists <- undefined
          return ()
[1/1] Compiling Haskell                  Main                   (ErrorTest.hs)
Parse (Haskell syntax) of module
*** ERROR ***
ErrorTest.hs(3,11):
    Expecting  : Symbol symbol let or pExpression or pPattern or (Symbol symbol ; or Nothing expected ...)* 
    Repaired by: deleting: Symbol symbol exists at line 3, column 11 of file "ErrorTest.hs"
*** ERROR ***
ErrorTest.hs(3,18):
    Expecting  : Symbol symbol let or pExpression or pPattern or (Symbol symbol ; or Nothing expected ...)* 
    Repaired by: deleting: Symbol symbol <- at line 3, column 18 of file "ErrorTest.hs"

It also happens inside a let-statement:

module Main where

main = let exists = undefined
        in return ()
[1/1] Compiling Haskell                  Main                   (ErrorTest.hs)
Parse (Haskell syntax) of module
*** ERROR ***
ErrorTest.hs(3,12):
    Expecting  : CloseBrace or pDeclaration or (Symbol symbol ; or Nothing expected ...)* 
    Repaired by: deleting: Symbol symbol exists at line 3, column 12 of file "ErrorTest.hs"
*** ERROR ***
ErrorTest.hs(3,19):
    Expecting  : CloseBrace or pDeclaration or (Symbol symbol ; or Nothing expected ...)* 
    Repaired by: deleting: Symbol symbol = at line 3, column 19 of file "ErrorTest.hs"
*** ERROR ***
ErrorTest.hs(4,9):
    Expecting  : Symbol symbol :: or Symbol symbol @ or pRhs or qconop or varop_no_bang or (pPatternBaseCon ...)+ or (Symbol symbol , ...
    Repaired by: deleting: CloseBrace
*** ERROR ***
ErrorTest.hs(4,9):
    Expecting  : Symbol symbol :: 
    Repaired by: deleting: Symbol symbol in at line 4, column 9 of file "ErrorTest.hs"
*** ERROR ***
ErrorTest.hs(4,12):
    Expecting  : Symbol symbol :: 
    Repaired by: inserting: Symbol symbol ::
... and more errors

--output in combination with --target=js causes the generated html file to include itself instead of the js of the main module

when building an executable from the following line of code to javascript: (stored in Main.hs)
main = print "hello"

using uhc --target=js Main.hs
the last js source include in Main.html is

<script type="text/javascript" src="Main.js"></script>

this is correct however when using the -o flag it is not:

using "uhc -o Main.html --target=js Main.hs" it is

<script type="text/javascript" src="Main.html"></script>

Whole Program Optimisation and FFI

Functions that are not used themselves in the Haskell world but are exported through the FFI do not end up in the generated JavaScript code. (I'm not sure whether this is a JS-backend-specific problem.) This would, as I believe was mentioned before, indicate that the functions that are being exported are not included in the root set for the reachability analysis.

Defaulting doesn't work in instance declaration

I have a program where UHC fails to default a numeric literal to Integer. The offending function definition is inside of an instance declaration and, weirdly, if I move the function definition to the top level it typechecks.

f :: Num a => a -> ()
f _ = ()

class C a where
  it :: a

-- Here I get a type error:
-- Test.hs:14-15:
--   Predicates remain unproven:
--     preds: UHC.Base.Num v_3_190_2
--              at   : 
--              trace: (UHC.Base.Num v_3_190_2,<4,0>,Test.hs:15:8): FAIL
--                     (UHC.Base.Num v_3_190_2,<4,0>,Test.hs:15:8): FAIL
instance C () where
  it = f 0

-- This one compiles fine.
it' :: ()
it' = f 0

--compile-only is not possible for a module with a main function

when compiling the following line of code: (stored in Main.hs)
main = print "hello"

the error uhc returns is a s follows:

uhc -c Main.hs
[1/1] Compiling Haskell Main (Main.hs)
compilation run
Number of definitions for 'main' exceeds limit:
limit : 0
module : Main

However "uhc -c Main.hs -o Main.o" does work

compiled code is segfaulting

Hello

I have built UHC from source code using GHC on a 64 bit computer

$ uhc --version
ehc-1.1.7.2, revision master@05180a3aff, timestamp 20141121 +0000 030619

but I tried to compile the demo with uhc hello.hs, this seems to work and creates output files but when I run it it crashes:

(gdb) r
Program received signal SIGSEGV, Segmentation fault.
0x000000000041c748 in gb_InitTables ()
(gdb) bt
#0  0x000000000041c748 in gb_InitTables ()
#1  0x00000000004065a0 in UHC_Base_initModule ()
#2  0x0000000000404935 in main ()

I looked around and found this is in the bytecode interpreter.c file but I don't know what might be going wrong.

Add Core Exports for Datatypes

Currently, only functions can be exported by Core modules and used by other Core modules. Datatypes cannot be exported. There is a workaround using -Operwholecore, but this makes compilation much slower.

Export-statements similar to the function-exports should be added to Core to improve this. I guess this
requires adding a new export_datatype keyword or similar, as I think function and datatype names could
possibly collide in Core. For my use-case, it doesn't matter if export-granularity is per datatype or per constructor.

Note: It is unlikely that this is implemented soon

UHC Windows support

The question whether UHC supports Windows came up because of agda/agda#1731.
I guess nobody tests UHC on Windows, but maybe you know something more?

If nobody tests it, I think the cygwin support should be marked as unmaintained/untested on UHC - WebHome.

Variant 8 not producing executables.

Trying to compile a simple file fails for variant 8, with a cpOutputByteCodeC panic:

[frans-willem@Hydra case]$ ../../uhc/EHC/install/8/bin/ehc case.hs
Compiling Haskell                        case                   (case.hs)
let data Bool  =   True 
                 | False 

    {- [Bool: *] -}
    {- [False: Bool
       ,True: Bool
       ,_'unFalse: Bool -> ()
       ,_'unTrue: Bool -> ()
       ] -}
in let myfunc = \x1 -> case x1 of
                         True -> 10
                         False -> 20
                       {- mbCaseIds 0_0_0, 0_1_0 -}
       {- [] -}
       {- [myfunc: Bool -> Int] -}
   in let main = myfunc True
          {- [] -}
          {- [main: Int] -}
      in main
ehc: panic: cpOutputByteCodeC bytecode

Input file was:

data Bool = True | False

myfunc True = 10
myfunc False = 20

main = myfunc True

Compiled on ArchLinux with up to date GHC, Cabal, etc.

Building haddock doc fails

The following fails:

$ ./configure
....
$ make 101/hdoc
....
Building UHC-Compiler-1.1...
Preprocessing library UHC-Compiler-1.1...

UHC/Compiler/AbstractCore.hs:89:8:
    Could not find module `UHC.Compiler.Ty'
    Use -v to see a list of the files searched for.
make[2]: *** [/home/philipp/Projects/uu/uhc/uhc/EHC/install-for-build/ins-flg-UHC-Compiler] Error 1
make[2]: Leaving directory `/home/philipp/Projects/uu/uhc/uhc/EHC'
make[1]: *** [ehc-haddock-variant] Error 2
make[1]: Leaving directory `/home/philipp/Projects/uu/uhc/uhc/EHC'
make: *** [101/hdoc] Error 2

I also checked manually if the file Ty.hs exists, and it was missing from the build/101/lib-ehc/UHC/Compiler/ directory.

--odir not possible for executable

when building an executable from the following line of code: (stored in Main.hs)
main = print "hello"

the error uhc returns is a s follows:

uhc --odir=. Main.hs
[1/1] Compiling Haskell Main (Main.hs)
compilation run
Number of definitions for 'main' exceeds limit:
limit : 0
module : Main

However "uhc --odir=. Main.hs -o Main" does work

failed to install uuagc-cabal on OSX 10.6.8

cabal install uuagc --reinstall
Resolving dependencies...
Configuring uuagc-bootstrap-0.9.40.2...
Building uuagc-bootstrap-0.9.40.2...
Preprocessing executable 'uuagc-bootstrap' for uuagc-bootstrap-0.9.40.2...
: cannot satisfy -package-id mtl-2.1.1-ae9b44386a2528180e60dcf2412689c0
(use -v for more information)
Configuring uuagc-cabal-1.0.2.0...
Building uuagc-cabal-1.0.2.0...
Preprocessing library uuagc-cabal-1.0.2.0...
: cannot satisfy -package-id mtl-2.1.1-ae9b44386a2528180e60dcf2412689c0
(use -v for more information)
cabal: Error: some packages failed to install:
uuagc-0.9.40.3 depends on uuagc-cabal-1.0.2.0 which failed to install.
uuagc-bootstrap-0.9.40.2 failed during the building phase. The exception was:
ExitFailure 1
uuagc-cabal-1.0.2.0 failed during the building phase. The exception was:
ExitFailure 1

Compiler doesn't output needed runtime libraries

Suppose I create a simple project and compile it with uhc --odir=./output --output=myproject.html.
The generated file myproject.html refers to prelude libraries that do not exist.
For example, I'd get as part of myproject.html:

<script type="text/javascript" src="/home/sstewartgallus/local/lib/uhc-1.1.5/lib/js/libEH-RTS.mjs"></script>
<script type="text/javascript" src="./output/UHC/UHC_Base.mjs"></script>
<script type="text/javascript" src="./output/Data/Data_Maybe.mjs"></script>
<script type="text/javascript" src="./output/UHC/UHC_ST.mjs"></script>
<script type="text/javascript" src="./output/UHC/UHC_Types.mjs"></script>
<script type="text/javascript" src="./output/UHC/UHC_Ptr.mjs"></script>
<script type="text/javascript" src="./output/UHC/UHC_Float.mjs"></script>
<script type="text/javascript" src="./output/UHC/UHC_MutVar.mjs"></script>

The runtime system and the prelude should be output in the ./output directory like any other package.

How to install 'shuffle'

I am trying to build shuffle as a prerequisite for uhc. However, I have no luck with several GHC versions. I am working with Cabal sandboxes.
With GHC-7.8.4 I seem to run into conflicts between different Cabal versions:

cabal: Error: some packages failed to install:
shuffle-0.1.3.3 failed during the configure step. The exception was:
user error ('/opt/ghc/7.8.4/bin/ghc-7.8.4' exited with an error:

/tmp/cabal-tmp-20215/shuffle-0.1.3.3/dist/dist-sandbox-ec9b2077/setup/setup.hs:21:10:
Couldn't match expected type ‘UserHooks’
with actual type ‘Cabal-1.18.1.5:Distribution.Simple.UserHooks.UserHooks’
NB: ‘UserHooks’
is defined in ‘Distribution.Simple.UserHooks’
in package ‘Cabal-1.22.4.0’
‘Cabal-1.18.1.5:Distribution.Simple.UserHooks.UserHooks’
is defined in ‘Distribution.Simple.UserHooks’
in package ‘Cabal-1.18.1.5’
In the second argument of ‘($)’, namely ‘uuagcLibUserHook uuagc’
In the second argument of ‘($)’, namely
‘addHook $ uuagcLibUserHook uuagc’
)

With GHC-7.6.3 I get:

shuffle-0.1.3.3 failed during the configure step. The exception was:
user error ('/opt/ghc/7.6.3/bin/ghc-7.6.3' exited with an error:

/tmp/cabal-tmp-5470/shuffle-0.1.3.3/dist/dist-sandbox-c2577f6e/setup/setup.hs:21:10:
Couldn't match expected type `UserHooks'
with actual type `Cabal-1.16.0:Distribution.Simple.UserHooks.UserHooks'
In the return type of a call of `uuagcLibUserHook'
In the second argument of `($)', namely `uuagcLibUserHook uuagc'
In the second argument of `($)', namely
`addHook $ uuagcLibUserHook uuagc'
)

With GHC-7.4.2 I get:

Configuring uulib-0.9.21...
Building uulib-0.9.21...
Preprocessing library uulib-0.9.21...
[ 1 of 27] Compiling UU.Util.Utils    ( src/UU/Util/Utils.hs, dist/dist-sandbox-f7ce0374/build/UU/Util/Utils.o )
[ 2 of 27] Compiling UU.Util.PermTree ( src/UU/Util/PermTree.hs, dist/dist-sandbox-f7ce0374/build/UU/Util/PermTree.o )
[ 3 of 27] Compiling UU.Util.BinaryTrees ( src/UU/Util/BinaryTrees.hs, dist/dist-sandbox-f7ce0374/build/UU/Util/BinaryTrees.o )
[ 4 of 27] Compiling UU.Pretty.Basic  ( src/UU/Pretty/Basic.hs, dist/dist-sandbox-f7ce0374/build/UU/Pretty/Basic.o )

src/UU/Pretty/Basic.hs:18:24:
    Module `Prelude' does not export `join'

With what GHC version have you build shuffle?

call to error fails in runtime

Something that leads to error throws an exception at runtime. In variant 101 it leads to a plain JS error Uncaught #<Object>, in the debug version (variant 99) it gives this error: Uncaught (A1#27'F1#17'UHC.Base.ErrorCall@args#1=(|(A0#13'F0#12'Main._5_2@args#0=(||))|)).

The only thing that is needed is this:

module Main where

main = error "This goes wrong"

This is an issue because you are not able to identify what went wrong when you run your program, you only know that it crashed. Furthermore the JS runtime shouldn't crash when an error is thrown.

Dependency on base is not strict enough

Building with base 4.6 fails:

[138 of 259] Compiling UHC.Compiler.CoreRun.Run.Val.Prim ( UHC/Compiler/CoreRun/Run/Val/Prim.hs, dist/build/UHC/Compiler/CoreRun/Run/Val/Prim.o )

src/ehc/CoreRun/Run/Val/Prim.chs:90:111:
    Not in scope: `bitSizeMaybe'

src/ehc/CoreRun/Run/Val/Prim.chs:91:93:
    Not in scope: `bitSizeMaybe'

bitSizeMaybe is not available before base 4.7. Problem is introduced by commit ea6b75a.

I don't see an easy work-around to get it working with base 4.6 . But at least the dependency in configure.ac should be updated. I can't fix and test it myself, as I am still using ghc 7.6/base4.6.

(Btw, is there a configure flag to disable CoreRun? I couldn't find one.)

Compile error: uhc-util v0.1.6.4 or higher missing

Hi,
just tried to compile UHC and after fixing missing uuagc with the solution of #4 i'm now running into compilation failure because uhc-util v0.1.6.4 or higher is missing.
At least the following dependencies are missing: uhc-util >=0.1.6.4 && <0.1.7
Currently installed version of uhc-util is 0.1.6.3, where/how can i get the new version? @atzedijkstra

Hopefully, using the master of UHC was the right way to compile as the releases (e.g. 1.0.0) seem a bit outdated...

Sincerely,
Tobias

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.