Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,249
    • Issues 5,249
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 581
    • Merge requests 581
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #11552
Closed
Open
Issue created Feb 07, 2016 by bitemyapp@trac-bitemyapp

ScopedTypeVariables / InstanceSigs do not work in GHC 8.0

{-# LANGUAGE InstanceSigs        #-}
{-# LANGUAGE ScopedTypeVariables #-}

module MyMaybeT where

newtype MaybeT m a =
  MaybeT { runMaybeT :: m (Maybe a) }

instance (Functor m) => Functor (MaybeT m) where
  fmap f (MaybeT ma) =
    MaybeT $ (fmap . fmap) f ma

instance forall f . (Applicative f) => Applicative (MaybeT f) where
  pure :: a -> MaybeT f a
  pure x = MaybeT (pure (pure x))

  (<*>) :: forall a b . Applicative f => MaybeT f (a -> b) -> MaybeT f a -> MaybeT f b
  (MaybeT fab) <*> (MaybeT mma) =
   let fab' :: f (Maybe (a -> b))
       fab' = fab
   in MaybeT $ undefined

Works fine in 7.10.3, breaks in GHC 8.0:

Prelude> :l code/myMaybeT1.hs 
[1 of 1] Compiling MyMaybeT         ( code/myMaybeT1.hs, interpreted )

code/myMaybeT1.hs:13:10: error:
    Malformed instance: forall f.
                        (Applicative f) => Applicative (MaybeT f)

code/myMaybeT1.hs:14:3: error:
    The class method signature for ‘pure’ lacks an accompanying binding
      (The class method signature must be given where ‘pure’ is declared)

code/myMaybeT1.hs:17:3: error:
    The class method signature for ‘<*>’ lacks an accompanying binding
      (The class method signature must be given where ‘<*>’ is declared)

code/myMaybeT1.hs:17:37: error: Not in scope: type variable ‘f’

code/myMaybeT1.hs:17:49: error: Not in scope: type variable ‘f’

code/myMaybeT1.hs:17:70: error: Not in scope: type variable ‘f’

code/myMaybeT1.hs:17:84: error: Not in scope: type variable ‘f’
Failed, modules loaded: none.
$ ghci --version
The Glorious Glasgow Haskell Compilation System, version 8.0.0.20160122
Edited Mar 10, 2019 by bitemyapp
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking