Skip to content

Instantly share code, notes, and snippets.

@spockz
Last active December 16, 2015 01:19
Show Gist options
  • Select an option

  • Save spockz/5353836 to your computer and use it in GitHub Desktop.

Select an option

Save spockz/5353836 to your computer and use it in GitHub Desktop.
{-# LANGUAGE GADTs, ScopedTypeVariables #-}
module Main where
import Prelude (Either(..), Bool, Int, flip, undefined)
import Data.Typeable
import Control.Concurrent.MVar
-- Bug
bug :: WrappedR Int -> SomeFunction
bug (Wrap node) = case node of
(Memo' (emptyT :: t a b) (memoize :: MVar (t a b) -> (a -> b) -> a -> b) (Var m :: R' a b Int) :: R' a b Int) -> -- breaks
--(Memo' (emptyT :: t a b) memoize (Var m) :: R' a b Int) -> -- also breaks
--(Memo' emptyT memoize (Var m) :: R' a b Int) -> -- Compiles
undefined
-- Data definitions
data R' a b r where
Memo' :: (Typeable a, Typeable b)
=> t a b -> (MVar (t a b) -> (a -> b) -> a -> b)
-> R' a b r -> R' a b r
Var :: (Typeable a, Typeable b)
=> r -> R' a b r
data SomeFunction where
SomeFunction :: (a -> b) -> SomeFunction
data WrappedR r where
Wrap :: (Typeable a, Typeable b) => R' a b r -> WrappedR r
[1 of 1] Compiling Main ( /Users/alessandro/Documents/Uni/thesis/test/bug-tvar-passed-renamer.hs, interpreted )
/Users/alessandro/Documents/Uni/thesis/test/bug-tvar-passed-renamer.hs:14:104:
GHC internal error: `a' is not in scope during type checking, but it passed the renamer
tcl_env of environment: [(awz,
Identifier[node::R' a b Int, <NotTopLevel>, 1]),
(rg7,
Identifier[bug::WrappedR Int -> SomeFunction, <NotTopLevel>, 1])]
In the type `R' a b Int'
In a pattern type signature: R' a b Int
In the pattern:
Memo' (emptyT :: t a b)
(memoize :: MVar (t a b) -> (a -> b) -> a -> b)
(Var m :: R' a b Int) :: R' a b Int
Failed, modules loaded: none.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment