Skip to content

Commit 2a7d9ff

Browse files
committed
Run fourmolu against plutus-tx-plugin files
1 parent fd1c05b commit 2a7d9ff

File tree

64 files changed

+4109
-3474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+4109
-3474
lines changed

plutus-tx-plugin/app/GeneratePluginOptionsDoc.hs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,32 @@ import Options.Applicative qualified as OA
1717
import Prettyprinter
1818
import PyF (fmt)
1919

20-
2120
newtype Params = Params
22-
{paramOutputFile :: Text}
21+
{paramOutputFile :: Text}
2322

2423
parseParams :: OA.Parser Params
2524
parseParams = do
26-
paramOutputFile <-
27-
OA.argument OA.str $
28-
mconcat
29-
[ OA.metavar "OUTPUT_FILE"
30-
, OA.help "Output file path"
31-
]
32-
pure Params{..}
25+
paramOutputFile <-
26+
OA.argument OA.str $
27+
mconcat
28+
[ OA.metavar "OUTPUT_FILE"
29+
, OA.help "Output file path"
30+
]
31+
pure Params{..}
3332

3433
main :: IO ()
3534
main = do
36-
params <-
37-
OA.execParser $
38-
OA.info
39-
(parseParams OA.<**> OA.helper)
40-
(OA.fullDesc <> OA.header "Generate plugin option documentation")
41-
Text.writeFile (Text.unpack $ paramOutputFile params) optionsTable
35+
params <-
36+
OA.execParser $
37+
OA.info
38+
(parseParams OA.<**> OA.helper)
39+
(OA.fullDesc <> OA.header "Generate plugin option documentation")
40+
Text.writeFile (Text.unpack $ paramOutputFile params) optionsTable
4241

4342
optionsTable :: Text
44-
optionsTable = Text.stripStart $ [fmt|
43+
optionsTable =
44+
Text.stripStart $
45+
[fmt|
4546
---
4647
sidebar_position: 5
4748
---
@@ -70,5 +71,5 @@ For each boolean option, you can add a `no-` prefix to switch it off, such as `n
7071
genRow :: O.OptionKey -> O.PluginOption -> Text
7172
genRow k (O.PluginOption tr _ field desc _) =
7273
[fmt||`{k}`|{show tr}|{show (pretty defaultValue)}|{desc}||]
73-
where
74-
defaultValue = O.defaultPluginOptions ^. field
74+
where
75+
defaultValue = O.defaultPluginOptions ^. field

plutus-tx-plugin/src/PlutusTx/Compiler/Binders.hs

Lines changed: 84 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -31,99 +31,105 @@ first.
3131
variable *last* (so it is on the outside, so will be first when applying).
3232
-}
3333

34-
withVarScoped ::
35-
CompilingDefault uni fun m ann =>
36-
GHC.Var ->
37-
Ann ->
38-
Maybe (PIRTerm uni fun) ->
39-
(PIR.VarDecl PIR.TyName PIR.Name uni Ann -> m a) ->
40-
m a
34+
withVarScoped
35+
:: (CompilingDefault uni fun m ann)
36+
=> GHC.Var
37+
-> Ann
38+
-> Maybe (PIRTerm uni fun)
39+
-> (PIR.VarDecl PIR.TyName PIR.Name uni Ann -> m a)
40+
-> m a
4141
withVarScoped v ann def k = do
42-
let ghcName = GHC.getName v
43-
var <- compileVarFresh ann v
44-
local (\c -> c {ccScope=pushName ghcName var def (ccScope c)}) (k var)
45-
46-
-- | Like `withVarScoped`, but takes a `PIRType`, and uses it for the type
47-
-- of the compiled `GHC.Var`.
48-
withVarTyScoped ::
49-
CompilingDefault uni fun m ann =>
50-
GHC.Var ->
51-
PIRType uni ->
52-
(PIR.VarDecl PIR.TyName PIR.Name uni Ann -> m a) ->
53-
m a
42+
let ghcName = GHC.getName v
43+
var <- compileVarFresh ann v
44+
local (\c -> c{ccScope = pushName ghcName var def (ccScope c)}) (k var)
45+
46+
{-| Like `withVarScoped`, but takes a `PIRType`, and uses it for the type
47+
of the compiled `GHC.Var`.
48+
-}
49+
withVarTyScoped
50+
:: (CompilingDefault uni fun m ann)
51+
=> GHC.Var
52+
-> PIRType uni
53+
-> (PIR.VarDecl PIR.TyName PIR.Name uni Ann -> m a)
54+
-> m a
5455
withVarTyScoped v t k = do
55-
let ghcName = GHC.getName v
56-
var <- compileVarWithTyFresh annMayInline v t
57-
local (\c -> c {ccScope=pushName ghcName var Nothing (ccScope c)}) (k var)
58-
59-
withVarsScoped ::
60-
CompilingDefault uni fun m ann =>
61-
[(GHC.Var, Maybe (PIRTerm uni fun))] ->
62-
([PIR.VarDecl PIR.TyName PIR.Name uni Ann] -> m a) ->
63-
m a
56+
let ghcName = GHC.getName v
57+
var <- compileVarWithTyFresh annMayInline v t
58+
local (\c -> c{ccScope = pushName ghcName var Nothing (ccScope c)}) (k var)
59+
60+
withVarsScoped
61+
:: (CompilingDefault uni fun m ann)
62+
=> [(GHC.Var, Maybe (PIRTerm uni fun))]
63+
-> ([PIR.VarDecl PIR.TyName PIR.Name uni Ann] -> m a)
64+
-> m a
6465
withVarsScoped vs k = do
65-
vars <- for vs $ \(v, def) -> do
66-
let name = GHC.getName v
67-
var' <- compileVarFresh annMayInline v
68-
pure (name, var', def)
69-
local (\c -> c {ccScope=pushNames vars (ccScope c)}) (k (fmap snd3 vars))
70-
71-
withTyVarScoped ::
72-
Compiling uni fun m ann =>
73-
GHC.Var ->
74-
(PIR.TyVarDecl PIR.TyName Ann -> m a) ->
75-
m a
66+
vars <- for vs $ \(v, def) -> do
67+
let name = GHC.getName v
68+
var' <- compileVarFresh annMayInline v
69+
pure (name, var', def)
70+
local (\c -> c{ccScope = pushNames vars (ccScope c)}) (k (fmap snd3 vars))
71+
72+
withTyVarScoped
73+
:: (Compiling uni fun m ann)
74+
=> GHC.Var
75+
-> (PIR.TyVarDecl PIR.TyName Ann -> m a)
76+
-> m a
7677
withTyVarScoped v k = do
77-
let ghcName = GHC.getName v
78-
var <- compileTyVarFresh v
79-
local (\c -> c {ccScope=pushTyName ghcName var (ccScope c)}) (k var)
80-
81-
withTyVarsScoped ::
82-
Compiling uni fun m ann =>
83-
[GHC.Var] ->
84-
([PIR.TyVarDecl PIR.TyName Ann] -> m a) ->
85-
m a
78+
let ghcName = GHC.getName v
79+
var <- compileTyVarFresh v
80+
local (\c -> c{ccScope = pushTyName ghcName var (ccScope c)}) (k var)
81+
82+
withTyVarsScoped
83+
:: (Compiling uni fun m ann)
84+
=> [GHC.Var]
85+
-> ([PIR.TyVarDecl PIR.TyName Ann] -> m a)
86+
-> m a
8687
withTyVarsScoped vs k = do
87-
vars <- for vs $ \v -> do
88-
let name = GHC.getName v
89-
var' <- compileTyVarFresh v
90-
pure (name, var')
91-
local (\c -> c {ccScope=pushTyNames vars (ccScope c)}) (k (fmap snd vars))
92-
93-
-- | Builds a lambda, binding the given variable to a name that
94-
-- will be in scope when running the second argument.
95-
mkLamAbsScoped ::
96-
CompilingDefault uni fun m ann =>
97-
Ann ->
98-
GHC.Var ->
99-
m (PIRTerm uni fun) ->
100-
m (PIRTerm uni fun)
88+
vars <- for vs $ \v -> do
89+
let name = GHC.getName v
90+
var' <- compileTyVarFresh v
91+
pure (name, var')
92+
local (\c -> c{ccScope = pushTyNames vars (ccScope c)}) (k (fmap snd vars))
93+
94+
{-| Builds a lambda, binding the given variable to a name that
95+
will be in scope when running the second argument.
96+
-}
97+
mkLamAbsScoped
98+
:: (CompilingDefault uni fun m ann)
99+
=> Ann
100+
-> GHC.Var
101+
-> m (PIRTerm uni fun)
102+
-> m (PIRTerm uni fun)
101103
mkLamAbsScoped ann v body =
102-
withVarScoped v ann Nothing $ \(PIR.VarDecl _ n t) ->
103-
PIR.LamAbs ann n t <$> body
104+
withVarScoped v ann Nothing $ \(PIR.VarDecl _ n t) ->
105+
PIR.LamAbs ann n t <$> body
104106

105-
-- | Builds a type abstraction, binding the given variable to a name that
106-
-- will be in scope when running the second argument.
107-
mkTyAbsScoped :: Compiling uni fun m ann => GHC.Var -> m (PIRTerm uni fun) -> m (PIRTerm uni fun)
107+
{-| Builds a type abstraction, binding the given variable to a name that
108+
will be in scope when running the second argument.
109+
-}
110+
mkTyAbsScoped :: (Compiling uni fun m ann) => GHC.Var -> m (PIRTerm uni fun) -> m (PIRTerm uni fun)
108111
mkTyAbsScoped v body = withTyVarScoped v $ \(PIR.TyVarDecl _ t k) -> PIR.TyAbs annMayInline t k <$> body
109112

110-
mkIterTyAbsScoped :: Compiling uni fun m ann => [GHC.Var] -> m (PIRTerm uni fun) -> m (PIRTerm uni fun)
113+
mkIterTyAbsScoped
114+
:: (Compiling uni fun m ann) => [GHC.Var] -> m (PIRTerm uni fun) -> m (PIRTerm uni fun)
111115
mkIterTyAbsScoped vars body = foldr (\v acc -> mkTyAbsScoped v acc) body vars
112116

113-
-- | Builds a forall, binding the given variable to a name that
114-
-- will be in scope when running the second argument.
115-
mkTyForallScoped :: Compiling uni fun m ann => GHC.Var -> m (PIRType uni) -> m (PIRType uni)
117+
{-| Builds a forall, binding the given variable to a name that
118+
will be in scope when running the second argument.
119+
-}
120+
mkTyForallScoped :: (Compiling uni fun m ann) => GHC.Var -> m (PIRType uni) -> m (PIRType uni)
116121
mkTyForallScoped v body =
117-
withTyVarScoped v $ \(PIR.TyVarDecl _ t k) -> PIR.TyForall annMayInline t k <$> body
122+
withTyVarScoped v $ \(PIR.TyVarDecl _ t k) -> PIR.TyForall annMayInline t k <$> body
118123

119-
mkIterTyForallScoped :: Compiling uni fun m ann => [GHC.Var] -> m (PIRType uni) -> m (PIRType uni)
124+
mkIterTyForallScoped :: (Compiling uni fun m ann) => [GHC.Var] -> m (PIRType uni) -> m (PIRType uni)
120125
mkIterTyForallScoped vars body = foldr (\v acc -> mkTyForallScoped v acc) body vars
121126

122-
-- | Builds a type lambda, binding the given variable to a name that
123-
-- will be in scope when running the second argument.
124-
mkTyLamScoped :: Compiling uni fun m ann => GHC.Var -> m (PIRType uni) -> m (PIRType uni)
127+
{-| Builds a type lambda, binding the given variable to a name that
128+
will be in scope when running the second argument.
129+
-}
130+
mkTyLamScoped :: (Compiling uni fun m ann) => GHC.Var -> m (PIRType uni) -> m (PIRType uni)
125131
mkTyLamScoped v body =
126-
withTyVarScoped v $ \(PIR.TyVarDecl _ t k) -> PIR.TyLam annMayInline t k <$> body
132+
withTyVarScoped v $ \(PIR.TyVarDecl _ t k) -> PIR.TyLam annMayInline t k <$> body
127133

128-
mkIterTyLamScoped :: Compiling uni fun m ann => [GHC.Var] -> m (PIRType uni) -> m (PIRType uni)
134+
mkIterTyLamScoped :: (Compiling uni fun m ann) => [GHC.Var] -> m (PIRType uni) -> m (PIRType uni)
129135
mkIterTyLamScoped vars body = foldr (\v acc -> mkTyLamScoped v acc) body vars

0 commit comments

Comments
 (0)