haskell - How to set undefine function in ghci -


i'm developing program in haskell , debug i've created file functions. few functions declarate how "underfined" , i'd set these function in interpreter (ghci).

for example:

r :: [string] r = undefined 

after loading file in ghci (:load experimental.hs), use following command:

let r = "example string"

but have next exception:

"*** exception: prelude.undefined 

can declarate in ghci function, in source file (.hs) underfined? or maybe exists other solutions?

it not possible, because breaks referential transparency: after "setting" function result of other function different. (you might argue undefined raising exception clear enough safe, need way make sure no function proper first definition redefined... it's not worth hassle.)

the correct way make undefined value explicit argument of function uses it. can change argument when invoking function interpreter.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -