[Haskell-cafe] A new type of newtype --- Type-level instance diversification and resolution (tl; dr)

Frank Staals frank at fstaals.net
Sat May 27 14:27:21 UTC 2017


"Albert Y. C. Lai" <trebla at vex.net> writes:

> <snip>
> 
> class MyOrd (resolver :: k) a where
>     mycmp :: p resolver -> a -> a -> Ordering
>
> <snip>
>
> data BST (resolver :: k) a = Nil | Bin !(BST resolver a) a !(BST resolver a)

Oh that is a pretty neat trick. I have to remember that. The unfortunate
thing even with it, you would need to reimplement all of the data
structures around to use it. I wonder if there is a way to use something
like this together with existing data structures such as Data.Map/Set
etc.

-- 

- Frank


More information about the Haskell-Cafe mailing list