Skip to content

Instantly share code, notes, and snippets.

@dcastro
Last active October 5, 2018 16:38
Show Gist options
  • Save dcastro/a7f9730981fa404415588224350dc918 to your computer and use it in GitHub Desktop.
Save dcastro/a7f9730981fa404415588224350dc918 to your computer and use it in GitHub Desktop.
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