
On Sun, Apr 28, 2019 at 10:56:42AM +0100, Tom Ellis wrote:
On Sun, Apr 28, 2019 at 12:45:24PM +0300, Georgi Lyubenov wrote:
There are obviously a lot of cool tricks you can do with phantom parameters, but they are all lost when you start looking at a `MVar` holding a type with a phantom parameter.
That's an intriguing statement. Why are they lost?
The types don't look lost to me at first blush: ghci> import Control.Concurrent.MVar ghci> import Data.Proxy ghci> let p = Proxy :: Proxy Int ghci> m <- newMVar p ghci> let q = Proxy :: Proxy Char ghci> x <- readMVar m ghci> q == x <interactive>:20:6: error: • Couldn't match type ‘Int’ with ‘Char’ Expected type: Proxy Char Actual type: Proxy Int • In the second argument of ‘(==)’, namely ‘x’ In the expression: q == x In an equation for ‘it’: it = q == x ghci> modifyMVar_ m $ const $ return q <interactive>:25:17: error: • Couldn't match type ‘Char’ with ‘Int’ Expected type: Proxy Int -> IO (Proxy Int) Actual type: Proxy Int -> IO (Proxy Char) • In the second argument of ‘($)’, namely ‘const $ return q’ In the expression: modifyMVar_ m $ const $ return q In an equation for ‘it’: it = modifyMVar_ m $ const $ return q -- Viktor.