Instantly share code, notes, and snippets.

@dcastro /LevNum.hs
Last active Oct 5, 2018

Embed
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