Rewinding numeric literal syntax with NoImplicitPrelude

It seems that my understanding of the -XNoImplicitPrelude flag in ghci is wrong, and I'm very confused.

documentation says

Integer literal 368 means "fromInteger (368 :: Integer)" and not "Prelude.fromInteger (368 :: Integer)".

However, when I download this code:

{-# LANGUAGE NoImplicitPrelude #-} module Try where import Prelude (Float,Integer, realToFrac) data MyNum = Nummy Float fromInteger :: Integer -> MyNum fromInteger x = Nummy (realToFrac x) 

In ghci, I get the following:

 ~/tmp$ ghci -XNoImplicitPrelude try.hs [1 of 1] Compiling Try ( try.hs, interpreted ) Ok, modules loaded: Try. *Try> 4 4 

When I expect to receive:

 *Try> 4 Nummy 4.0 *Try> 

Simliar comes from the Try module; for example, there is a type error when I declare a function return type MyNum and define it as an integer literal.

+4
source share
1 answer

The docs you pointed out say you need to activate the RebindableSyntax extension for this.

+4
source

All Articles