-
-
Save Lysxia/da30abac357deb7981412f1faf0d2103 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RankNTypes #-} | |
module E where | |
data Variable | |
data Expression | |
class HasVar e where | |
fromVar :: Variable -> e | |
instance HasVar Variable | |
instance HasVar Expression | |
instance Num Expression | |
data Solver a | |
instance Functor Solver | |
instance Applicative Solver | |
instance Monad Solver | |
newtype V = V (forall e. HasVar e => e) | |
variable :: Solver V | |
variable = undefined | |
data Definition = (:=) Variable Expression | |
register :: Definition -> Solver () | |
register = undefined | |
(|:=|) :: Variable -> Expression -> Solver () | |
v |:=| e = register (v := e) | |
infix 1 :=, |:=| | |
data Equation | |
(|==|) :: Expression -> Expression -> Equation | |
(|==|) = undefined | |
solve :: Equation -> Solver () | |
solve = undefined | |
computation :: Solver () | |
computation = do | |
V x <- variable | |
V t <- variable | |
t |:=| x^2 - 1 | |
solve (t |==| 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment