[GHC] #13306: Problems with type inference for static expressions
GHC
ghc-devs at haskell.org
Thu May 25 08:03:16 UTC 2017
#13306: Problems with type inference for static expressions
-------------------------------------+-------------------------------------
Reporter: edsko | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.2
Resolution: | Keywords:
| StaticPointers
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by edsko):
Here's another much simpler test case:
{{{#!hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE StaticPointers #-}
{-# OPTIONS_GHC -Wall #-}
import GHC.StaticPtr
data U :: * -> * where
UBool :: U Bool
UInt :: U Int
toDouble :: U a -> StaticPtr (a -> Double)
toDouble UBool = static (\x -> if x then 1 else 0)
toDouble UInt = static fromIntegral
}}}
The first line yields "Couldn't match expected type `Bool` with actual
type `a`", and the second line yields "No instance for (`Integral a`)".
Writing
{{{#!hs
toDouble UInt = static (fromIntegral :: Int -> Double)
}}}
instead yields "Couldn't match type `a` with `Int`; but
{{{#!hs
toDouble UInt = static fromIntegral :: StaticPtr (Int -> Double)
}}}
''is'' accepted. If we instead use
{{{#!hs
fakeStatic :: a -> StaticPtr a
fakeStatic = undefined
}}}
then of course
{{{#!hs
toDouble :: U a -> StaticPtr (a -> Double)
toDouble UBool = fakeStatic (\x -> if x then 1 else 0)
toDouble UInt = fakeStatic fromIntegral
}}}
is accepted as is.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13306#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list