Quantcast
Channel: Lifting class instance in Haskell - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Greg Bacon for Lifting class instance in Haskell

$
0
0

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 all articles
Browse latest Browse all 4

Trending Articles



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