[Haskell-cafe] Non polymorphic numerals option -- avoiding type classes

Roman Cheplyaka roma at ro-che.info
Thu Dec 27 18:28:40 CET 2012


Forgot to say: if you go the first route, you'll also need to define your
fromInteger in every module — the one from .ghci won't be in scope.

You can define

  module MyPrelude (module Prelude, fromInteger) where

  import Prelude hiding (fromInteger)

  fromInteger = id

and import it instead.

* Roman Cheplyaka <roma at ro-che.info> [2012-12-27 19:22:53+0200]
> * Rustom Mody <rustompmody at gmail.com> [2012-12-27 22:18:15+0530]
> > But now we are in for new surprises:  Try out
> > f x y = x / y
> > Prelude> :l f
> > [1 of 1] Compiling Main             ( f.hs, interpreted )
> > 
> > f.hs:1:11: Not in scope: `/'
> > Failed, modules loaded: none.
> > Prelude> (/)
> 
> It's because RebindableSyntax implies NoImplicitPrelude. This is not an
> issue if you only work in the interpreter (you can put "import Prelude
> hiding (fromInteger)" in .ghci), but you'd also need to put that into
> every source file that you wish to load.
> 
> An alternative would be to create your own Prelude (or use an existing
> one, like [1]) and use it instead of the one defined in base (by hiding
> base and exposing a different package).
> 
> [1]: http://hackage.haskell.org/packages/archive/simpleprelude/1.0.1.3/doc/html/Prelude.html
> 
> Roman



More information about the Haskell-Cafe mailing list