augustss / MicroHs

Haskell implemented with combinators
Other
370 stars 25 forks source link

Record dot usage with Cont newtype provokes free type variable in output fundep #53

Closed ysangkok closed 4 months ago

ysangkok commented 4 months ago

File name Cont.hs:

{-# LANGUAGE OverloadedRecordDot, NoFieldSelectors #-}
module Cont where

newtype ContT r m a = ContT { runContT :: (a -> m r) -> m r }

instance Functor (ContT r m) where
    fmap f m = ContT $ \ c -> m.runContT (c . f)

main :: IO ()
main = pure ()

Compiles with GHC 9.10.1 using ghc -fforce-recomp -c Cont.hs, but fails with latest MicroHs invoked as mhs Cont:

mhs: "./Cont.hs": line 7, col 33: free type variable in output fundep

Since this compiles in GHC and I only use supported extensions, I was expecting this to compile in MicroHs.

If the instance is instead written as

instance Functor (ContT r m) where                                                  
    fmap f (ContT m) = ContT $ \ c -> m (c . f)

it compiles successfully.

augustss commented 4 months ago

Thanks for the report. Fixed in a1a8df36d1544818c7f56559da2f0e463c84612b