Quantcast
Viewing latest article 2
Browse Latest Browse All 4

Answer by Greg Bacon for Lifting class instance in Haskell

The generalized newtype deriving extension is what you want here:

{-# LANGUAGE GeneralizedNewtypeDeriving #-}module Main wherenewtype SomeType a = SomeCons a deriving (Num, Show, Eq)main = do  let a = SomeCons 2      b = SomeCons 3  print $ a + b

Output:

*Main> mainSomeCons 5

Viewing latest article 2
Browse Latest Browse All 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>