diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-11-09 22:59:12 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-11-09 22:59:12 +0100 |
commit | d4d4473ee229674f73929c0860a7e29302330361 (patch) | |
tree | 65efd81ff635bad0e85cc518dc67c7c204313c73 /src/Language/AST.hs | |
parent | 34887168c0e2deb549e0e7c77e837ab269d894a2 (diff) |
Cleanup, more Language operations
Diffstat (limited to 'src/Language/AST.hs')
-rw-r--r-- | src/Language/AST.hs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Language/AST.hs b/src/Language/AST.hs index 0ed4e51..8c91d59 100644 --- a/src/Language/AST.hs +++ b/src/Language/AST.hs @@ -98,6 +98,27 @@ instance (t ~ TScal st, ScalIsNumeric st ~ True, KnownScalTy st, Num (ScalRep st in case scalRepIsShow ty of Dict -> NEConst ty . fromInteger +instance (t ~ TScal st, ScalIsNumeric st ~ True, ScalIsFloating st ~ True, KnownScalTy st, Fractional (ScalRep st)) + => Fractional (NExpr env t) where + recip e = NEOp (ORecip knownScalTy) e + fromRational = + let ty = knownScalTy + in case scalRepIsShow ty of + Dict -> NEConst ty . fromRational + +instance (t ~ TScal st, ScalIsNumeric st ~ True, ScalIsFloating st ~ True, KnownScalTy st, Floating (ScalRep st)) + => Floating (NExpr env t) where + pi = + let ty = knownScalTy + in case scalRepIsShow ty of + Dict -> NEConst ty pi + exp = NEOp (OExp knownScalTy) + log = NEOp (OExp knownScalTy) + sin = undefined ; cos = undefined ; tan = undefined + asin = undefined ; acos = undefined ; atan = undefined + sinh = undefined ; cosh = undefined + asinh = undefined ; acosh = undefined ; atanh = undefined + instance (KnownTy t, KnownSymbol name, name ~ n') => IsLabel name (Var n' t) where fromLabel = Var symbolSing knownTy |