29 Aug 18:38 2013

## Compiler stops at SpecConstr optimization

Hello.

While hacking in one of my projects, one of my modules stopped to compile for apparently no reason. The compiler just freezes (like if it where in an infinite loop) while trying to compile that particular module. Since I had this problem I have been trying to reduce the problem as much as I could, and I came out with this small piece of code:

> module Blah (foo) where

> import Data.Vector (Vector)
> import qualified Data.Vector as V

> foo :: (a -> a) -> Vector a -> Vector a
> foo f = V.fromList . V.foldl (\xs x -> f x : xs) []

The module I am importing comes from package vector-0.10.0.1. The compiler I am using is ghc-7.6.3. The problem arises when compiling using the following flags:

ghc Blah.hs -O1 -fspec-constr

If I compile it verbosely (with -v), I can see that the compiler stops in the SpecConstr optimization step. I have tried to reduce the -O1 flag to a particular set of flags, but I didn't manage yet to find the complete set of flags that -O1 translates to (optLevelFlags [1] seems to give not enough information).

Since this problem can be OS-dependent, my system is Debian 7 and I didn't try yet to reproduce my problem in other systems (mainly because I don't have access to other systems at the moment).

I am posting this here to, with the help of the Haskell Community, check first if this is indeed a bug and, in such case, to find out where that bug comes from (GHC, vector library, something else?). Then, if necessary, I would write a bug report where appropriate.

Thank you,
Daniel Díaz.

-- References

```_______________________________________________
```
29 Aug 19:00 2013

### Re: Compiler stops at SpecConstr optimization

```On Thu, Aug 29, 2013 at 12:08 PM, Daniel Díaz Casanueva
<dhelta.diaz <at> gmail.com> wrote:
> Since this problem can be OS-dependent, my system is Debian 7 and I didn't
> try yet to reproduce my problem in other systems (mainly because I don't

FWIW, it’s not just you — I can reproduce this on 7.4.2 (vector-0.10.0.1).

> \$ uname -a
> Linux lechuza 2.6.38-13-generic #57-Ubuntu SMP Mon Mar 5 18:10:14 UTC 2012 i686 i686 i386 GNU/Linux

_______________________________________________
```
29 Aug 20:29 2013

### Re: Compiler stops at SpecConstr optimization

This is a known GHC bug that (i believe?) is fixed in head. Links to the relevant tickets from when I hit this problem trying to build lambdabot are here https://github.com/mokus0/random-fu/issues/13

The work around is to build those libraries with -O1

On Thu, Aug 29, 2013 at 1:00 PM, Manuel Gómez wrote:
On Thu, Aug 29, 2013 at 12:08 PM, Daniel Díaz Casanueva
<dhelta.diaz <at> gmail.com> wrote:
> Since this problem can be OS-dependent, my system is Debian 7 and I didn't
> try yet to reproduce my problem in other systems (mainly because I don't

FWIW, it’s not just you — I can reproduce this on 7.4.2 (vector-0.10.0.1).

> \$ uname -a
> Linux lechuza 2.6.38-13-generic #57-Ubuntu SMP Mon Mar 5 18:10:14 UTC 2012 i686 i686 i386 GNU/Linux

_______________________________________________

```_______________________________________________
```
30 Aug 02:19 2013

### Re: Compiler stops at SpecConstr optimization

```
On 30/08/2013, at 2:38 AM, Daniel Díaz Casanueva wrote:

> While hacking in one of my projects, one of my modules stopped to compile for apparently no reason. The
compiler just freezes (like if it where in an infinite loop) while trying to compile that particular
module. Since I had this problem I have been trying to reduce the problem as much as I could, and I came out
with this small piece of code:
>
> > module Blah (foo) where
>
> > import Data.Vector (Vector)
> > import qualified Data.Vector as V
>
> > foo :: (a -> a) -> Vector a -> Vector a
> > foo f = V.fromList . V.foldl (\xs x -> f x : xs) []

Probably an instance of this one:

Ben.
```
1 Sep 22:58 2013

### Re: Compiler stops at SpecConstr optimization

Yes, that GHC ticket shows that this problem is well known.

Thank you.

On Fri, Aug 30, 2013 at 2:19 AM, Ben Lippmeier wrote:

On 30/08/2013, at 2:38 AM, Daniel Díaz Casanueva wrote:

> While hacking in one of my projects, one of my modules stopped to compile for apparently no reason. The compiler just freezes (like if it where in an infinite loop) while trying to compile that particular module. Since I had this problem I have been trying to reduce the problem as much as I could, and I came out with this small piece of code:
>
> > module Blah (foo) where
>
> > import Data.Vector (Vector)
> > import qualified Data.Vector as V
>
> > foo :: (a -> a) -> Vector a -> Vector a
> > foo f = V.fromList . V.foldl (\xs x -> f x : xs) []

Probably an instance of this one:

```_______________________________________________