From 4f6448743c34f83dbc1a467e3c9e0dd20d9d9f16 Mon Sep 17 00:00:00 2001 From: Franco Bulgarelli Date: Sun, 19 Apr 2020 13:50:46 -0300 Subject: [PATCH 1/2] Adding operators for collections and numbers --- src/Language/Mulang/Ast/Operator.hs | 62 ++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/src/Language/Mulang/Ast/Operator.hs b/src/Language/Mulang/Ast/Operator.hs index eb3466982..26e570e5c 100644 --- a/src/Language/Mulang/Ast/Operator.hs +++ b/src/Language/Mulang/Ast/Operator.hs @@ -6,43 +6,83 @@ import GHC.Generics data Operator = Equal - -- equal operator + -- ^ `==`-like equal operator | NotEqual - -- ^ distinct operator + -- ^ `!==`-like distinct operator | Negation - -- ^ not operator + -- ^ `!`-like not operator | And - -- ^ and operator + -- ^ `&&`-like and operator | Or - -- ^ or operator + -- ^ `||`-like or operator | Hash -- ^ hashcode operator | GreatherOrEqualThan + -- ^ `>=` operator | GreatherThan + -- ^ `>` operator | LessOrEqualThan + -- ^ `<=` operator | LessThan + -- ^ `<` operator | Otherwise -- ^ guard's otherwise operator | Plus + -- ^ numeric `+` operator | Minus + -- ^ numeric `-` operator | Multiply + -- ^ numeric `*` operator | Divide + -- ^ numeric `/` operator | ForwardComposition -- (f >> g)(x) = (g . f)(x) = g(f(x)) operator | BackwardComposition -- (f << g)(x) = (f . g)(x) = f(g(x)) operator | Modulo - -- ^ % operator + -- ^ numeric `%-like` modulo operator | BitwiseOr - -- ^ bit-level or operator | + -- ^ bit-level `|`-like or operator | BitwiseAnd - -- ^ bit-level and operator & + -- ^ bit-level `&`-like and operator | BitwiseXor - -- ^ bit-level xor operator + -- ^ bit-level `^`-like xor operator | BitwiseLeftShift - -- ^ bit-level left shift operator << + -- ^ bit-level left `<<`-like shift operator | BitwiseRightShift - -- ^ bit-level right shift operator >> + -- ^ bit-level right `>>`-like shift operator + | Absolute + -- ^ numeric `abs`-like absolute operator + | Round + -- ^ numeric `round`-like round operator + | Ceil + -- ^ numeric `ceil`-like ceiling operator + | Floor + -- ^ numeric `ceil`-like floor operator + | Max + -- ^ `max`-like maximum value binary operator + | Min + -- ^ `min`-like minimum value binary operator + | Size + -- ^ collection `length`-like size operator + | Detect + -- ^ collection `find`-like search operator + | DetectMax + -- ^ collection `max`-like maximum operator + | DetectMin + -- ^ collection `min`-like minumum operator + | Count + -- ^ collection `count`-like operator + | Select + -- ^ collection `filter`-like operator + | Collect + -- ^ collection `map`-like operator + | Inject + -- ^ collection `reduce`-like / `fold`-like operator + | AllSatisfy + -- ^ collection `all`-like / `every`-like operator + | AnySatisfy + -- ^ collection `any`-like / `some`-like operator deriving (Eq, Show, Read, Generic, Ord, Enum) From 6a5a52ec3dd339093f4b8bf20db6ad44eaefccc5 Mon Sep 17 00:00:00 2001 From: Franco Bulgarelli Date: Sat, 25 Apr 2020 17:21:53 -0300 Subject: [PATCH 2/2] Adding flatten and gather operators --- src/Language/Mulang/Ast/Operator.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Language/Mulang/Ast/Operator.hs b/src/Language/Mulang/Ast/Operator.hs index 26e570e5c..99d7be06c 100644 --- a/src/Language/Mulang/Ast/Operator.hs +++ b/src/Language/Mulang/Ast/Operator.hs @@ -83,6 +83,10 @@ data Operator -- ^ collection `all`-like / `every`-like operator | AnySatisfy -- ^ collection `any`-like / `some`-like operator + | Flatten + -- ^ collection `flatten`-like operator + | Gather + -- ^ collection `flatmap`-like operator deriving (Eq, Show, Read, Generic, Ord, Enum)