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

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -