The function const
is defined in Prelude as:
const x _ = x
In GHCi, when I tried
Prelude> const 6 5 -> Gives 6
But when I tried
Prelude> const id 6 5 -> Gives 5
Even after making changes like
Prelude> (const id 6) 5 -> Gives 5
Shouldn't this function give 6
as the output of function id
has type id :: a -> a
which should bind like
Prelude> (const 6) 5 -> Gives 6
Why does function const
behave differently?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…