Skip to content

Commit

Permalink
🧩 [remove-unused]: Record constructor of SExpr.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolyp committed Nov 1, 2024
1 parent a442734 commit debe98d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
2 changes: 0 additions & 2 deletions src/Pretty.purs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ exprType (Float _ _) = Simple
exprType (Str _ _) = Simple
exprType (Constr _ _ Nil) = Simple
exprType (Constr _ _ _) = Expression
exprType (Record _ _) = Simple
exprType (Dictionary _ _) = Simple
exprType (Matrix _ _ _ _) = Simple
exprType (Lambda _) = Simple
Expand Down Expand Up @@ -140,7 +139,6 @@ instance Ann a => Pretty (Expr a) where
pretty (Float α n) = highlightIf α $ text (show n)
pretty (Str α str) = highlightIf α $ text ("\"" <> str <> "\"")
pretty (Constr α c x) = highlightIf α $ prettyConstr c x
pretty (Record α xss) = highlightIf α $ curlyBraces (prettyOperator (.-.) xss)
pretty (Dictionary α sss) = highlightIf α $ curlyBraces (prettyDictEntries (.-.) sss)
pretty (Matrix α e (x × y) e') =
highlightIf α $ arrayBrackets
Expand Down
12 changes: 1 addition & 11 deletions src/SExpr.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Control.Monad.Error.Class (class MonadError)
import Data.Bitraversable (rtraverse)
import Data.Either (Either(..))
import Data.Filterable (filterMap)
import Data.Foldable (foldl, length)
import Data.Foldable (length)
import Data.Function (on)
import Data.Generic.Rep (class Generic)
import Data.List (List(..), drop, take, unzip, zip, zipWith, (:), (\\))
Expand Down Expand Up @@ -43,7 +43,6 @@ data Expr a
| Float a Number
| Str a String
| Constr a Ctr (List (Expr a))
| Record a (List (Bind (Expr a)))
| Dictionary a (List (DictEntry a × Expr a))
| Matrix a (Expr a) (Var × Var) (Expr a)
| Lambda (Clauses a)
Expand Down Expand Up @@ -241,10 +240,6 @@ exprFwd (Int α n) = pure (E.Int α n)
exprFwd (Float α n) = pure (E.Float α n)
exprFwd (Str α s) = pure (E.Str α s)
exprFwd (Constr α c ss) = E.Constr α c <$> traverse desug ss
exprFwd (Record α xss) = do
let ks × ss = unzip xss
es <- traverse desug ss
E.Dictionary α <$> pure (zipWith (\k v -> Pair k v) (ks <#> E.Str α) es)
exprFwd (Dictionary α sss) = do
let ks × ss = unzip sss
ks' <- traverse desug ks
Expand Down Expand Up @@ -274,11 +269,6 @@ exprBwd (E.Int α _) (Int _ n) = Int α n
exprBwd (E.Float α _) (Float _ n) = Float α n
exprBwd (E.Str α _) (Str _ str) = Str α str
exprBwd (E.Constr α _ es) (Constr _ c ss) = Constr α c (uncurry desugBwd <$> zip es ss)
exprBwd (E.Dictionary α ees) (Record _ xss) =
let
αs = (ees <#> unsafePartial \(Pair (E.Str β _) _) -> β) :: List a
in
Record (foldl (∨) α αs) (zipWith (\(Pair _ e) (x × s) -> x × desugBwd e s) ees xss)
exprBwd (E.Dictionary α ees) (Dictionary _ sss) =
Dictionary α (zipWith (\(Pair e e') (s × s') -> (desugBwd e s) × (desugBwd e' s')) ees sss)
exprBwd (E.Matrix α e1 _ e2) (Matrix _ s1 (x × y) s2) =
Expand Down

0 comments on commit debe98d

Please sign in to comment.