Using a type of a parameterized data type in a Haskell function -
let's have algebraic data type in haskell:
data foo = ...
i'd have function "extract" type a
, it, assuming satisfies conditions. specifically, need like:
fun :: bounded => foo ->
with intended usage follows:
fun foo = maxbound ::
of course notation incorrect in haskell, think intentions clear. possible this?
you don't need anything, works.
fun :: bounded => foo -> fun _ = maxbound
the compiler knows result of fun
a
, therefore call correct maxbound
.
Comments
Post a Comment