Skip to content
This repository has been archived by the owner on Feb 10, 2020. It is now read-only.

Commit

Permalink
Fill in a few inlines that were undone
Browse files Browse the repository at this point in the history
  • Loading branch information
nwolverson committed Aug 3, 2018
1 parent e22f95f commit 0bb0c0f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/Language/PureScript/CodeGen/Erl/Optimizer/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Language.PureScript.CodeGen.Erl.Optimizer.Common where
import Prelude.Compat
import Data.Text (Text)

import Data.Monoid ((<>))
import Data.Maybe (fromMaybe)

import Language.PureScript.PSString (PSString)
Expand Down
41 changes: 17 additions & 24 deletions src/Language/PureScript/CodeGen/Erl/Optimizer/Inliner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,21 @@ inlineCommonValues :: Erl -> Erl
inlineCommonValues = everywhereOnErl convert
where
convert :: Erl -> Erl
convert = id
-- convert (JSApp ss fn [dict])
-- | isDict' [semiringNumber, semiringInt] dict && isFn fnZero fn = JSNumericLiteral ss (Left 0)
-- | isDict' [semiringNumber, semiringInt] dict && isFn fnOne fn = JSNumericLiteral ss (Left 1)
-- | isDict boundedBoolean dict && isFn fnBottom fn = JSBooleanLiteral ss False
-- | isDict boundedBoolean dict && isFn fnTop fn = JSBooleanLiteral ss True
-- convert (JSApp ss (JSApp _ (JSApp _ fn [dict]) [x]) [y])
-- | isDict semiringInt dict && isFn fnAdd fn = intOp ss Add x y
-- | isDict semiringInt dict && isFn fnMultiply fn = intOp ss Multiply x y
-- | isDict euclideanRingInt dict && isFn fnDivide fn = intOp ss Divide x y
-- | isDict ringInt dict && isFn fnSubtract fn = intOp ss Subtract x y
-- convert other = other
-- fnZero = (C.dataSemiring, C.zero)
-- fnOne = (C.dataSemiring, C.one)
-- fnBottom = (C.dataBounded, C.bottom)
-- fnTop = (C.dataBounded, C.top)
-- fnAdd = (C.dataSemiring, C.add)
-- fnDivide = (C.dataEuclideanRing, C.div)
-- fnMultiply = (C.dataSemiring, C.mul)
-- fnSubtract = (C.dataRing, C.sub)
-- intOp ss op x y = JSBinary ss BitwiseOr (JSBinary ss op x y) (JSNumericLiteral ss (Left 0))
--
convert (EApp fn [dict])
| isDict semiringInt dict && isUncurriedFn fnZero fn = ENumericLiteral (Left 0)
| isDict semiringNumber dict && isUncurriedFn fnZero fn = ENumericLiteral (Right 0.0)
| isDict semiringInt dict && isUncurriedFn fnOne fn = ENumericLiteral (Left 1)
| isDict semiringNumber dict && isUncurriedFn fnOne fn = ENumericLiteral (Right 1.0)

| isDict boundedBoolean dict && isUncurriedFn fnBottom fn = EAtomLiteral $ Atom Nothing "false"
| isDict boundedBoolean dict && isUncurriedFn fnTop fn = EAtomLiteral $ Atom Nothing "true"
convert other = other

fnZero = (EC.dataSemiring, C.zero)
fnOne = (EC.dataSemiring, C.one)
fnBottom = (C.dataBounded, C.bottom)
fnTop = (C.dataBounded, C.top)

inlineCommonOperators :: Erl -> Erl
inlineCommonOperators = applyAll
[ binary semiringNumber opAdd Add
Expand Down Expand Up @@ -201,8 +194,8 @@ ordChar = (EC.dataOrd, C.ordChar)
-- semigroupString :: forall a b. (IsString a, IsString b) => (a, b)
-- semigroupString = (EC.dataSemigroup, C.semigroupString)

-- boundedBoolean :: forall a b. (IsString a, IsString b) => (a, b)
-- boundedBoolean = (EC.dataBounded, C.boundedBoolean)
boundedBoolean :: forall a b. (IsString a, IsString b) => (a, b)
boundedBoolean = (EC.dataBounded, C.boundedBoolean)

heytingAlgebraBoolean :: forall a b. (IsString a, IsString b) => (a, b)
heytingAlgebraBoolean = (EC.dataHeytingAlgebra, C.heytingAlgebraBoolean)
Expand Down

0 comments on commit 0bb0c0f

Please sign in to comment.