In ghci, how to remove an existing binding?

I get “snapping shadows of an existing snapping” similar to the one from this question.

Prelude Api.Facility Control.Monad.IO.Class> let t = getBadgesNot 1 (Nothing) (Just 1)

<interactive>:55:5: warning: [-Wname-shadowing]
    This binding for ‘t’ shadows the existing binding
      defined at <interactive>:39:5

I defined an existing binding earlier in the session, and now I'm trying to redefine it. Is there a way to remove an existing binding so that I can override t?

I notice that in other cases ghci does not cause an error when overriding an existing binding. for instance

Prelude> let t = 1
Prelude> let t = 2
Prelude> let t = "there"

Why is the ghci error when overriding an existing binding in some cases and not in others?

+4
source share
1 answer

Is there a way to remove an existing binding so that I can override t?

, . t , .

ghci , ?

ghci /; -Wname-shadowing (, , ghci cabal , .cabal). -Wname-shadowing t, -Werror .

, let ; , , :

% ghci -Wname-shadowing -Werror
> let t=3
> let t=4
<interactive>:3:5: warning: [-Wname-shadowing]
    This binding for ‘t’ shadows the existing binding
      defined at <interactive>:1:5

<no location info>: error: 
Failing due to -Werror.
> t
3
> t=4
> t
4
+3

Source: https://habr.com/ru/post/1680673/


All Articles