Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE OverlappingInstances #-}
- {-# LANGUAGE FlexibleInstances #-}
- {-# LANGUAGE MultiParamTypeClasses #-}
- {-# LANGUAGE GADTs #-}
- 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)
Add Comment
Please, Sign In to add comment