Skip to content

Instantly share code, notes, and snippets.

Last active Oct 5, 2018
What would you like to do?
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