packages feed

simple-expr 0.1.0.2 → 0.1.1.0

raw patch · 5 files changed

+26/−42 lines, 5 files

Files

CHANGELOG.md view
@@ -1,9 +1,16 @@ # Revision history for simple-expr -## 0.1.0.0 -- 2023-05-12+## [0.1.0.0] -- 2023-05-12 +### Added+ * Basic types `SimpleExpr`, `Expr` and instances for `NumHask` typeclasses. * Conversion to graphs from `graphite` package. * Visualization provided by `graphviz`. * Tutorial +## [0.1.1.0] -- 2023-08-05++### Fixed++* Compatibility up to LTS 21.6
simple-expr.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.18 --- This file has been generated from package.yaml by hpack version 0.35.1.+-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack  name:           simple-expr-version:        0.1.0.2+version:        0.1.1.0 synopsis:       Minimalistic toolkit for simple mathematical expression. description:    This is a minimalistic toolkit for simple mathematical expression developed for debug purposes similar to                 'simple-reflect' package
src/Debug/SimpleExpr.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_HADDOCK show-extensions #-}  -- | Module    :  Debug.SimpleExpr
src/Debug/SimpleExpr/Expr.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -Wcpp-undef #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_HADDOCK show-extensions #-} @@ -33,7 +35,7 @@ import Data.Fix (Fix (Fix, unFix)) import Data.Functor.Classes (Eq1, liftEq) import Data.List (intercalate, (++))-import NumHask (Additive, Distributive, Divisive, ExpField, Field, Multiplicative, Subtractive, TrigField, one, zero)+import NumHask (Additive, Divisive, ExpField, Multiplicative, Subtractive, TrigField, one, zero) import qualified NumHask as NH import Prelude   ( Bool (False),@@ -172,40 +174,6 @@ -- It includes `SimpleExpr` as well as list and tuples of `SimpleExpr` etc. type Expr = ListOf SimpleExpr ----- | Expression typeclass.--- class Eq a => Expr a where---  -- | Returns all simple expressions given expression consists of.---  -----  -- ==== __Examples of usage__---  -----  -- >>> import NumHask ((+), (*))---  -----  -- >>> x = variable "x"---  -- >>> y = variable "y"---  -- >>> z = variable "z"---  -----  -- >>> innerSimpleExprs [x, y + z]---  -- [x,y+z]---  -----  -- >>> innerSimpleExprs (x * (y + z))---  -- [x·(y+z)]---  innerSimpleExprs :: a -> [SimpleExpr]------ instance Expr () where---  innerSimpleExprs = P.const []------ instance Expr SimpleExpr where---  innerSimpleExprs e = [e]------ instance Expr (SimpleExpr, SimpleExpr) where---  innerSimpleExprs (e0, e1) = [e0, e1]------ instance Expr (SimpleExpr, SimpleExpr, SimpleExpr) where---  innerSimpleExprs (e0, e1, e2) = [e0, e1, e2]------ instance Expr [SimpleExpr] where---  innerSimpleExprs = P.id- instance {-# OVERLAPPING #-} Show SimpleExpr where   show (Fix e) = case e of     NumberF n -> show n@@ -266,12 +234,18 @@   one = number 1   (*) = binaryFunc "·" -instance Distributive SimpleExpr+#if MIN_VERSION_numhask(0,11,0)+#else+instance NH.Distributive SimpleExpr+#endif  instance Divisive SimpleExpr where   (/) = binaryFunc "/" -instance Field SimpleExpr+#if MIN_VERSION_numhask(0,11,0)+#else+instance NH.Field SimpleExpr+#endif  instance ExpField SimpleExpr where   exp = unaryFunc "exp"
src/Debug/SimpleExpr/GraphUtils.hs view
@@ -59,7 +59,11 @@ -- >>> x = variable "x" -- >>> y = variable "y" -- >>> exprToGraph [x + y, x - y]--- fromList [("x",[("x+y",()),("x-y",())]),("x+y",[]),("x-y",[]),("y",[("x+y",()),("x-y",())])]+-- ...+--+-- We expect something like+-- @fromList [("y",[("x-y",()),("x+y",())]),("x-y",[]),("x",[("x-y",()),("x+y",())]),("x+y",[])]@+-- depending on the packages version version. exprToGraph :: Expr d => d -> DGraph String () exprToGraph d = case content d of   [] -> empty -- insertVertex (name e) empty