Skip to content

Commit

Permalink
Remove superfluous bool combinators
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Nov 8, 2024
1 parent 3537c8a commit c9b0d5c
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions unison-runtime/src/Unison/Runtime/Builtin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1413,15 +1413,6 @@ arg2To0 instr =
where
(arg1, arg2) = fresh

-- ... -> Bool
argNToBool :: Int -> ForeignOp
argNToBool n instr =
(replicate n BX,)
. TAbss args
$ TFOp instr args
where
args = freshes n

argNDirect :: Int -> ForeignOp
argNDirect n instr =
(replicate n BX,)
Expand Down Expand Up @@ -2252,7 +2243,7 @@ declareForeigns = do
. mkForeignIOF
$ \(mv :: MVar Val, x) -> swapMVar mv x

declareForeign Tracked "MVar.isEmpty" (argNToBool 1)
declareForeign Tracked "MVar.isEmpty" (argNDirect 1)
. mkForeign
$ \(mv :: MVar Val) -> isEmptyMVar mv

Expand Down Expand Up @@ -2347,7 +2338,7 @@ declareForeigns = do
declareForeign Tracked "Promise.tryRead" argToMaybe . mkForeign $
\(p :: Promise Val) -> tryReadPromise p

declareForeign Tracked "Promise.write" (argNToBool 2) . mkForeign $
declareForeign Tracked "Promise.write" (argNDirect 2) . mkForeign $
\(p :: Promise Val, a :: Val) -> writePromise p a

declareForeign Tracked "Tls.newClient.impl.v3" arg2ToEF . mkForeignTls $
Expand Down Expand Up @@ -2783,7 +2774,7 @@ declareForeigns = do
declareForeign Untracked "Pattern.run" arg2ToMaybeTup . mkForeign $
\(TPat.CP _ matcher, input :: Text) -> pure $ matcher input

declareForeign Untracked "Pattern.isMatch" (argNToBool 2) . mkForeign $
declareForeign Untracked "Pattern.isMatch" (argNDirect 2) . mkForeign $
\(TPat.CP _ matcher, input :: Text) -> pure . isJust $ matcher input

declareForeign Untracked "Char.Class.any" direct . mkForeign $ \() -> pure TPat.Any
Expand All @@ -2808,7 +2799,7 @@ declareForeigns = do
declareForeign Untracked "Char.Class.symbol" direct . mkForeign $ \() -> pure (TPat.CharClass TPat.Symbol)
declareForeign Untracked "Char.Class.separator" direct . mkForeign $ \() -> pure (TPat.CharClass TPat.Separator)
declareForeign Untracked "Char.Class.letter" direct . mkForeign $ \() -> pure (TPat.CharClass TPat.Letter)
declareForeign Untracked "Char.Class.is" (argNToBool 2) . mkForeign $ \(cl, c) -> evaluate $ TPat.charPatternPred cl c
declareForeign Untracked "Char.Class.is" (argNDirect 2) . mkForeign $ \(cl, c) -> evaluate $ TPat.charPatternPred cl c
declareForeign Untracked "Text.patterns.char" (argNDirect 1) . mkForeign $ \c ->
let v = TPat.cpattern (TPat.Char c) in pure v

Expand Down

0 comments on commit c9b0d5c

Please sign in to comment.