Skip to content

Instantly share code, notes, and snippets.

@dcastro
Last active October 5, 2018 16:38
Levity-polymorphic Num typeclass
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE TypeInType #-}
module LevNum where
import GHC.Prim
import GHC.Exts (TYPE)
class LevNum (a :: TYPE r) where
levAdd :: a -> a -> a
instance LevNum Int where levAdd = (+)
instance LevNum Int# where levAdd = (+#)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment