Re: [Haskell-cafe] Missing Functor instances in GHC 7?
On Fri, 2010-12-10 at 08:33 +, Simon Peyton-Jones wrote: > If there's a consensus that the behaviour is wrong, or at least > unexpected, would you like to make a reproducible test case and file a > ticket? I took Erik's mail as indicator that the behaviour of GHCi is inconsistent and unexpected: http://hackage.haskell.org/trac/ghc/ticket/4832 Sebastian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Missing Functor instances in GHC 7?
On Fri, Dec 10, 2010 at 09:33, Simon Peyton-Jones wrote: > | Interestingly, if I import only Control.Applicative from within GHCi, it > | does not find the instances defined in Control.Monad.Instances although > | this module is imported in Control.Applicative. On the other hand, if I > | write a file containing the line 'import Control.Applicative' and load > | this file in GHCi then the instances from Control.Monad.Instances are > | visible. > | > | Apparently, importing a module in GHCi differs from importing it in a > | Haskell file and loading this into GHCi. > > I don't believe that should happen, depending on exactly what you mean by > "importing a module in GHCi". I see this as well. Using "import Control.Applicative" in ghci doesn't seem to bring the instance into scope, while using ":m +Control.Applicative" does. See the log below. Note that the instance really isn't available, i.e. it's not a problem with :i. GHCi, version 7.0.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading package ffi-1.0 ... linking ... done. Prelude> :i Functor class Functor f where fmap :: (a -> b) -> f a -> f b (GHC.Base.<$) :: a -> f b -> f a -- Defined in GHC.Base instance Functor Maybe -- Defined in Data.Maybe instance Functor [] -- Defined in GHC.Base instance Functor IO -- Defined in GHC.Base Prelude> import Control.Applicative Prelude Control.Applicative> :i Functor class Functor f where fmap :: (a -> b) -> f a -> f b (<$) :: a -> f b -> f a -- Defined in GHC.Base instance Functor ZipList -- Defined in Control.Applicative instance Monad m => Functor (WrappedMonad m) -- Defined in Control.Applicative instance Functor (Const m) -- Defined in Control.Applicative instance Functor Maybe -- Defined in Data.Maybe instance Functor [] -- Defined in GHC.Base instance Functor IO -- Defined in GHC.Base Prelude Control.Applicative> :m +Control.Applicative Prelude Control.Applicative> :i Functor class Functor f where fmap :: (a -> b) -> f a -> f b (<$) :: a -> f b -> f a -- Defined in GHC.Base instance Functor (Either a) -- Defined in Control.Monad.Instances instance Functor ((->) r) -- Defined in Control.Monad.Instances instance Functor ((,) a) -- Defined in Control.Monad.Instances instance Functor ZipList -- Defined in Control.Applicative instance Monad m => Functor (WrappedMonad m) -- Defined in Control.Applicative instance Functor (Const m) -- Defined in Control.Applicative instance Functor Maybe -- Defined in Data.Maybe instance Functor [] -- Defined in GHC.Base instance Functor IO -- Defined in GHC.Base Prelude Control.Applicative> Erik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Missing Functor instances in GHC 7?
| Interestingly, if I import only Control.Applicative from within GHCi, it | does not find the instances defined in Control.Monad.Instances although | this module is imported in Control.Applicative. On the other hand, if I | write a file containing the line 'import Control.Applicative' and load | this file in GHCi then the instances from Control.Monad.Instances are | visible. | | Apparently, importing a module in GHCi differs from importing it in a | Haskell file and loading this into GHCi. I don't believe that should happen, depending on exactly what you mean by "importing a module in GHCi". If there's a consensus that the behaviour is wrong, or at least unexpected, would you like to make a reproducible test case and file a ticket? Thanks! Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Missing Functor instances in GHC 7?
On Fri, 2010-12-10 at 14:35 +0900, Sebastian Fischer wrote: > Yes, I cannot find the Functor instance for ((->) r). As the Applicative instance for ((->) r) depends on the Functor instance I "only" needed to go through the imports of Control.Applicative to find that the Functor instance of ((->) r) is defined in Control.Monad.Instances. If I import this module into GHCi, it finds the instance. Interestingly, if I import only Control.Applicative from within GHCi, it does not find the instances defined in Control.Monad.Instances although this module is imported in Control.Applicative. On the other hand, if I write a file containing the line 'import Control.Applicative' and load this file in GHCi then the instances from Control.Monad.Instances are visible. Apparently, importing a module in GHCi differs from importing it in a Haskell file and loading this into GHCi. Sebastian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Missing Functor instances in GHC 7?
Hi Antoine, On Thu, 2010-12-09 at 23:20 -0600, Antoine Latter wrote: > Are there any particular ones you're running into problems with? Yes, I cannot find the instance for ((->) r). Even if I import Control.Monad Control.Monad.Reader Control.Applicative Data.Functor Data.Function I still get ghci> ((+) <$> id <*> id) 21 :1:1: No instance for (Functor ((->) a)) Sebastian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Missing Functor instances in GHC 7?
Hi Sebastian, I imagine that many of the instances are defined in the module that defines the data type. For example, the STM instance is defined in the same module as the STM type. Are there any particular ones you're running into problems with? Take care, Antoine On Thu, Dec 9, 2010 at 11:10 PM, Sebastian Fischer wrote: > Hello, > > according to > > http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html > > Control.Monad exports 20 Functor instance declarations in base-4.3.0.0. > However: > > bash# ghc-pkg list | grep base > base-4.3.0.0 > bash# ghci --version > The Glorious Glasgow Haskell Compilation System, version 7.0.1 > bash# ghci > Prelude> import Control.Monad > Prelude Control.Monad> :i Functor > class Functor f where > fmap :: (a -> b) -> f a -> f b > (GHC.Base.<$) :: a -> f b -> f a > -- Defined in GHC.Base > instance Functor Maybe -- Defined in Data.Maybe > instance Functor [] -- Defined in GHC.Base > instance Functor IO -- Defined in GHC.Base > > There are only 3 instances instead of 20. Importing Control.Applicative > gives 3 more instances but for example the instance for ((->) r) is > still missing. > > Is my installation broken? Or has anybody similar problems finding > Functor instances in GHC 7? > > Sebastian > > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Missing Functor instances in GHC 7?
Hello, according to http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html Control.Monad exports 20 Functor instance declarations in base-4.3.0.0. However: bash# ghc-pkg list | grep base base-4.3.0.0 bash# ghci --version The Glorious Glasgow Haskell Compilation System, version 7.0.1 bash# ghci Prelude> import Control.Monad Prelude Control.Monad> :i Functor class Functor f where fmap :: (a -> b) -> f a -> f b (GHC.Base.<$) :: a -> f b -> f a -- Defined in GHC.Base instance Functor Maybe -- Defined in Data.Maybe instance Functor [] -- Defined in GHC.Base instance Functor IO -- Defined in GHC.Base There are only 3 instances instead of 20. Importing Control.Applicative gives 3 more instances but for example the instance for ((->) r) is still missing. Is my installation broken? Or has anybody similar problems finding Functor instances in GHC 7? Sebastian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe