Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
AwesomePrelude example
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module MyLang where
import Prelude (Integer(..), Show(..),String(..))
import qualified Prelude as P
import Generic.Data.Bool
import Generic.Data.Num
data MyLang a where
MLFalse :: MyLang Bool
MLTrue :: MyLang Bool
MLValue :: a -> MyLang a
instance BoolC MyLang where
false = MLFalse
true = MLTrue
bool t _ MLTrue = t
bool _ e MLFalse = e
instance Num MyLang Integer where
fromInteger = MLValue
(MLValue a) + (MLValue b) = MLValue (a P.+ b)
(MLValue a) - (MLValue b) = MLValue (a P.- b)
(MLValue a) * (MLValue b) = MLValue (a P.* b)
test :: MyLang Integer
test = if' true (3 + 4) (4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment