Sorry about the title, I don't know if there's a better way to describe it in one short sentence.
The idea is I want a function type to express that the function accepts one argument but will never evaluate it.
There are few alternatives I can think of, and I want to know what would be the best one:
(for all following examples, Int
is just an arbitrary choice from any concrete types)
f :: forall a . a -> Int
, feedingf
with anything will dof :: () -> Int
, there's nothing but a trivial value to be evaluatedf :: Void -> Int
, this could be a bad idea, as it's possible thatf = absurd
andf
is applied withundefined
orlet x = x in x
, but if you knowf
terminates, then you also know it will never evaluate its argument.- I don't know if there are other ways, please give your suggestions if any.
About why I need a function like this in the first place: suppose I want to design a stream-processing library and let type of stream processors be like SP <input-type> <output-type>
and it's possible that a processor doesn't need any input. and at some point I'll have to deal with a function like <input-type> -> <output-type>
if I want to make this an Arrow
.