Skip to content

Commit

Permalink
remove custom unicode operator for compose
Browse files Browse the repository at this point in the history
  • Loading branch information
kritzcreek committed Sep 28, 2023
1 parent 010e995 commit 20c015b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Pscid.Options (PscidSettings, optionParser, printCLICommand)
import Pscid.Process (execCommand)
import Pscid.Psa (filterWarnings, parseErrors, psaPrinter)
import Pscid.Server (restartServer, startServer', stopServer')
import Pscid.Util (both, (∘))
import Pscid.Util (both)
import Suggest (applySuggestions)
import Type.Prelude as TE

Expand All @@ -42,7 +42,7 @@ instance monadAskPscid :: TE.TypeEquals r (PscidSettings Int) => MonadAsk r Psci
ask = Pscid (map TE.from ask)

instance monadEffectPscid :: MonadEffect Pscid where
liftEffect = Pscid liftEffect
liftEffect = Pscid <<< liftEffect

runPscid :: forall a. Pscid a -> PscidSettings Int -> Effect a
runPscid (Pscid f) e = runReaderT f e
Expand Down Expand Up @@ -130,7 +130,7 @@ triggerRebuild :: Ref State -> String -> Pscid Unit
triggerRebuild stateRef file = do
{ port, testCommand, testAfterRebuild, censorCodes } <- ask
let fileName = changeExtension file "purs"
liftEffect catchLog "We couldn't talk to the server" $ launchAff_ do
liftEffect <<< catchLog "We couldn't talk to the server" $ launchAff_ do
result <- sendCommandR port (RebuildCmd fileName Nothing Nothing)
case result of
Left _ -> Console.log "We couldn't talk to the server"
Expand Down
3 changes: 1 addition & 2 deletions src/Pscid/Console.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import Ansi.Codes (Color(..))
import Ansi.Output (foreground, withGraphics)
import Effect (Effect)
import Effect.Console as Console
import Pscid.Util ((∘))

logColored :: Color -> String -> Effect Unit
logColored c = Console.log withGraphics (foreground c)
logColored c s = Console.log (withGraphics (foreground c) s)

owl :: String
owl =
Expand Down
5 changes: 2 additions & 3 deletions src/Pscid/Options.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Node.Platform (Platform(..))
import Node.Process (platform)
import Node.Process as Process
import Options.Applicative as OA
import Pscid.Util ((∘))

type PscidSettings a =
{ port :: a
Expand Down Expand Up @@ -46,7 +45,7 @@ scanDefaultDirectories =
defaultDirectories = [ "src", "app", "test", "tests" ]
mkGlob dir = dir <> "/**/*.purs"
in
Array.filterA (map (not Array.null) glob mkGlob) defaultDirectories
Array.filterA (map (not <<< Array.null) <<< glob <<< mkGlob) defaultDirectories

spagoCmd :: String
spagoCmd = if platform == Just Win32 then "spago.cmd" else "spago"
Expand Down Expand Up @@ -127,7 +126,7 @@ buildOptions defaults { port, testAfterRebuild, includes, outputDirectory, censo

sepArguments :: String -> String -> Array String
sepArguments sep =
Array.filter (not String.null) String.split (String.Pattern sep)
Array.filter (not String.null) <<< String.split (String.Pattern sep)

-- | A parser for pscid's options. A `Nothing` signals the user
-- | requested the version
Expand Down
5 changes: 2 additions & 3 deletions src/Pscid/Psa.purs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import Psa (Output, PsaError, PsaOptions, PsaResult, StatVerbosity(..), Suggesti
import Psa.Printer (renderAnsi, renderRow)
import Psa.Printer.Default (renderError, renderWarning)
import Psa.Util (iter_)
import Pscid.Util ((∘))

defaultOptions :: PsaOptions
defaultOptions =
Expand Down Expand Up @@ -54,7 +53,7 @@ print successMessage options { warnings, errors } = do
when (Array.null warnings && Array.null errors)
(Console.error successMessage)
where
toString = renderRow (String.joinWith "" map (renderAnsi options.ansi))
toString = renderRow (String.joinWith "" <<< map (renderAnsi options.ansi))

parseErrors :: Json -> Either String (Array PsaError)
parseErrors j = traverse parsePsaError =<< (lmap printJsonDecodeError $ decodeJson j)
Expand Down Expand Up @@ -99,7 +98,7 @@ reorderWarnings errors =
&& String.contains (String.Pattern "Prelude")
) replacement
{ yes, no } =
Array.partition (Maybe.maybe false isPreludeImport _.suggestion) errors
Array.partition (Maybe.maybe false isPreludeImport <<< _.suggestion) errors
in
no <> yes

Expand Down
3 changes: 1 addition & 2 deletions src/Pscid/Server.purs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ import Node.Process as Process
import PscIde as PscIde
import PscIde.Command (Message(..))
import PscIde.Server (ServerStartResult(..), defaultServerArgs, deleteSavedPort, getSavedPort, pickFreshPort, savePort, startServer, stopServer)
import Pscid.Util ((∘))

stopServer' :: Int -> Aff Unit
stopServer' port = do
_ <- liftEffect (Process.cwd >>= try deleteSavedPort)
_ <- liftEffect (Process.cwd >>= try <<< deleteSavedPort)
stopServer port

startServer'
Expand Down
6 changes: 1 addition & 5 deletions src/Pscid/Util.purs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
module Pscid.Util ((∘), both) where

import Prelude
module Pscid.Util (both) where

import Data.Either (Either(..))

infixr 9 compose as ∘

both :: forall a b. (a -> b) -> Either a a -> Either b b
both f e = case e of
Right x -> Right (f x)
Expand Down

0 comments on commit 20c015b

Please sign in to comment.