Skip to content

ghci "*** Exception: expectJust upseep1"

ghci gets confused, reporting "*** Exception: expectJust upseep1". I think it's related to having pre-compiled source files that cyclicly import each other, but havn't double checked/proven it.

Trace to reproduce the bug here: (notice that at the start Simplify.hs has a bug in it, and after loading it, but before doing :!cat Simplify.hs I have fixed the error in Simplify.hs)

16:56:38 - tora@colorado:/tmp/GhcBug.hs
>ls
Bookmarks.hs  Bookmarks.hs-boot  Cursor.hs  Simplify.hs

16:56:51 - tora@colorado:/tmp/GhcBug.hs
>ghc --make -c Cursor.hs Bookmarks.hs
[1 of 3] Compiling Bookmarks[boot]  ( Bookmarks.hs-boot, Bookmarks.o-boot )
[2 of 3] Compiling Cursor           ( Cursor.hs, Cursor.o )
[3 of 3] Compiling Bookmarks        ( Bookmarks.hs, Bookmarks.o )

16:57:05 - tora@colorado:/tmp/GhcBug.hs
>cat Simplify.hs 
module HExp.Simplify where

import Cursor(Cursor)

iterateMaybe :: (a -> Maybe a) -> a -> [a]
iterateMaybe f init = init : maybe [] (iterateMaybe) (f init)


16:57:20 - tora@colorado:/tmp/GhcBug.hs
>ghci Simplify.hs 
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
[3 of 4] Compiling HExp.Simplify    ( Simplify.hs, interpreted )

Simplify.hs:6:39:
    Couldn't match expected type `[a]'
           against inferred type `a1 -> [a1]'
    Probable cause: `iterateMaybe' is applied to too few arguments
    In the second argument of `maybe', namely `(iterateMaybe)'
    In the second argument of `(:)', namely
        `maybe [] (iterateMaybe) (f init)'
Failed, modules loaded: Cursor, Bookmarks, Bookmarks.
Prelude Bookmarks> :!cat Simplify.hs 
module HExp.Simplify where

import Cursor(Cursor)

iterateMaybe :: (a -> Maybe a) -> a -> [a]
iterateMaybe f init = init : maybe [] (iterateMaybe f) (f init)

Prelude Bookmarks> :r
*** Exception: expectJust upseep1
> Leaving GHCi.
Trac metadata
Trac field Value
Version 6.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC tora@zonetora.co.uk
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information