Skip to content

Commit e8f1296

Browse files
author
Marty Stumpf
authored
Fix various things to comply with the style guide. (#5163)
1 parent 86fdfe0 commit e8f1296

File tree

85 files changed

+670
-442
lines changed

Some content is hidden

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

85 files changed

+670
-442
lines changed

.stylish-haskell.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ steps:
1111
remove_redundant: false
1212

1313
- trailing_whitespace: {}
14-
columns: 120
14+
columns: 100
1515
newline: native
1616
language_extensions:
1717
- DataKinds

doc/notes/fomega/cek-cps-experiments/src/CekMachine.cps.hs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
-- editorconfig-checker-disable-file
2-
31
-- This file contains a version of the CEK machine in
42
-- continuation-passing-style, where the frames and return
53
-- operation of the original version are replaced with explicit
@@ -14,7 +12,8 @@
1412
-- This is for efficiency reasons.
1513
-- The type checker pass is required as well (and in our case it subsumes the renamer pass).
1614
-- Feeding ill-typed terms to the CEK machine will likely result in a 'MachineException'.
17-
-- The CEK machine generates booleans along the way which might contain globally non-unique 'Unique's.
15+
-- The CEK machine generates booleans along the way which might contain globally non-unique
16+
-- 'Unique's.
1817
-- This is not a problem as the CEK machines handles name capture by design.
1918

2019
module PlutusCore.Interpreter.CekMachine
@@ -103,15 +102,23 @@ instantiateEvaluate
103102
instantiateEvaluate k env _ (TyAbs _ _ _ body) = computeCek k env body
104103
instantiateEvaluate k env ty fun
105104
| isJust $ termAsPrimIterApp fun = k env $ TyInst () fun ty
106-
| otherwise = throw $ MachineException NonPrimitiveInstantiationMachineError fun
105+
| otherwise =
106+
throw $ MachineException NonPrimitiveInstantiationMachineError fun
107107

108108
-- | Apply a function to an argument and proceed.
109-
-- If the function is a 'LamAbs', then extend the current environment with a new variable and proceed.
109+
-- If the function is a 'LamAbs', then extend the current environment with a new variable and
110+
-- proceed.
110111
-- If the function is not a 'LamAbs', then 'Apply' it to the argument and view this
111112
-- as an iterated application of a 'BuiltinName' to a list of 'Value's.
112113
-- If succesful, proceed with either this same term or with the result of the computation
113114
-- depending on whether 'BuiltinName' is saturated or not.
114-
applyEvaluate :: Cont -> Environment -> Environment -> Plain Value -> Plain Value -> EvaluationResult
115+
applyEvaluate ::
116+
Cont
117+
-> Environment
118+
-> Environment
119+
-> Plain Value
120+
-> Plain Value
121+
-> EvaluationResult
115122
applyEvaluate k funEnv argEnv lam@(LamAbs _ name _ body) arg =
116123
computeCek k (extendEnvironment name arg argEnv funEnv) body
117124
applyEvaluate k funEnv _ fun arg =
@@ -124,7 +131,8 @@ applyEvaluate k funEnv _ fun arg =
124131
ConstAppSuccess term' -> k funEnv term'
125132
ConstAppFailure -> EvaluationFailure
126133
ConstAppStuck -> k funEnv term
127-
ConstAppError err -> throw $ MachineException (ConstAppMachineError err) term
134+
ConstAppError err ->
135+
throw $ MachineException (ConstAppMachineError err) term
128136

129137
-- | Evaluate a term using the CEK machine. May throw a 'MachineException'.
130138
evaluateCek :: Term TyName Name () -> EvaluationResult

doc/notes/fomega/cek-cps-experiments/src/CekMachine.original.hs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
-- editorconfig-checker-disable-file
21
-- | The CEK machine.
32
-- Rules are the same as for the CK machine from "PlutusCore.Evaluation.CkMachine",
43
-- except we do not use substitution and use environments instead.
@@ -7,7 +6,8 @@
76
-- This is for efficiency reasons.
87
-- The type checker pass is required as well (and in our case it subsumes the renamer pass).
98
-- Feeding ill-typed terms to the CEK machine will likely result in a 'MachineException'.
10-
-- The CEK machine generates booleans along the way which might contain globally non-unique 'Unique's.
9+
-- The CEK machine generates booleans along the way which might contain globally non-unique
10+
-- 'Unique's.
1111
-- This is not a problem as the CEK machines handles name capture by design.
1212

1313
module PlutusCore.Interpreter.CekMachine
@@ -102,15 +102,23 @@ instantiateEvaluate
102102
instantiateEvaluate env con _ (TyAbs _ _ _ body) = computeCek env con body
103103
instantiateEvaluate env con ty fun
104104
| isJust $ termAsPrimIterApp fun = returnCek env con $ TyInst () fun ty
105-
| otherwise = throw $ MachineException NonPrimitiveInstantiationMachineError fun
105+
| otherwise =
106+
throw $ MachineException NonPrimitiveInstantiationMachineError fun
106107

107108
-- | Apply a function to an argument and proceed.
108-
-- If the function is a 'LamAbs', then extend the current environment with a new variable and proceed.
109+
-- If the function is a 'LamAbs', then extend the current environment with a new variable and
110+
-- proceed.
109111
-- If the function is not a 'LamAbs', then 'Apply' it to the argument and view this
110112
-- as an iterated application of a 'BuiltinName' to a list of 'Value's.
111113
-- If succesful, proceed with either this same term or with the result of the computation
112114
-- depending on whether 'BuiltinName' is saturated or not.
113-
applyEvaluate :: Environment -> Environment -> Context -> Plain Value -> Plain Value -> EvaluationResult
115+
applyEvaluate ::
116+
Environment
117+
-> Environment
118+
-> Context
119+
-> Plain Value
120+
-> Plain Value
121+
-> EvaluationResult
114122
applyEvaluate funEnv argEnv con (LamAbs _ name _ body) arg =
115123
computeCek (extendEnvironment name arg argEnv funEnv) con body
116124
applyEvaluate funEnv _ con fun arg =
@@ -123,7 +131,8 @@ applyEvaluate funEnv _ con fun arg =
123131
ConstAppSuccess term' -> returnCek funEnv con term'
124132
ConstAppFailure -> EvaluationFailure
125133
ConstAppStuck -> returnCek funEnv con term
126-
ConstAppError err -> throw $ MachineException (ConstAppMachineError err) term
134+
ConstAppError err ->
135+
throw $ MachineException (ConstAppMachineError err) term
127136

128137
-- | Evaluate a term using the CEK machine. May throw a 'MachineException'.
129138
evaluateCek :: Term TyName Name () -> EvaluationResult

doc/notes/fomega/cek-cps-experiments/src/CekMachine.recursive.hs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
-- editorconfig-checker-disable-file
21
{-# LANGUAGE BangPatterns #-}
32

43
-- This file contains a version of the CEK machine in
@@ -17,7 +16,8 @@
1716
-- This is for efficiency reasons.
1817
-- The type checker pass is required as well (and in our case it subsumes the renamer pass).
1918
-- Feeding ill-typed terms to the CEK machine will likely result in a 'MachineException'.
20-
-- The CEK machine generates booleans along the way which might contain globally non-unique 'Unique's.
19+
-- The CEK machine generates booleans along the way which might contain globally non-unique
20+
-- 'Unique's.
2121
-- This is not a problem as the CEK machines handles name capture by design.
2222

2323
module PlutusCore.Interpreter.CekMachine
@@ -84,12 +84,14 @@ evalCek !cl@(Closure term env) =
8484
Unwrap _ term' ->
8585
case evalCek $ Closure term' env of
8686
Closure (Wrap _ _ _ t) env' -> evalCek $ Closure t env'
87-
_ -> throw $ MachineException NonWrapUnwrappedMachineError term'
87+
_ ->
88+
throw $ MachineException NonWrapUnwrappedMachineError term'
8889

8990
Error{} -> throw $ MachineException OpenTermEvaluatedMachineError term
9091

9192
Var _ name -> case lookupName name env of
92-
Nothing -> throw $ MachineException OpenTermEvaluatedMachineError term
93+
Nothing ->
94+
throw $ MachineException OpenTermEvaluatedMachineError term
9395
Just cl@(Closure val7 env7) -> cl
9496

9597
-- | Instantiate a term with a type and proceed.
@@ -101,10 +103,12 @@ instantiateEvaluate
101103
instantiateEvaluate _ !(Closure (TyAbs _ _ _ body) env) = evalCek (Closure body env)
102104
instantiateEvaluate ty !(Closure fun env)
103105
| isJust $! termAsPrimIterApp fun = Closure (TyInst () fun ty) env
104-
| otherwise = throw $ MachineException NonPrimitiveInstantiationMachineError fun
106+
| otherwise =
107+
throw $ MachineException NonPrimitiveInstantiationMachineError fun
105108

106109
-- | Apply a function to an argument and proceed.
107-
-- If the function is a 'LamAbs', then extend the current environment with a new variable and proceed.
110+
-- If the function is a 'LamAbs', then extend the current environment with a new variable and
111+
-- proceed.
108112
-- If the function is not a 'LamAbs', then 'Apply' it to the argument and view this
109113
-- as an iterated application of a 'BuiltinName' to a list of 'Value's.
110114
-- If succesful, proceed with either this same term or with the result of the computation
@@ -121,9 +125,11 @@ applyEvaluate !(Closure funVal funEnv) !(Closure argVal argEnv) =
121125
Just (IterApp headName spine) ->
122126
case runQuote $! ((applyBuiltinName $! headName) $! spine) of
123127
ConstAppSuccess term' -> Closure term' funEnv
124-
ConstAppFailure -> throw $ MachineException OpenTermEvaluatedMachineError term
128+
ConstAppFailure ->
129+
throw $ MachineException OpenTermEvaluatedMachineError term
125130
ConstAppStuck -> Closure term funEnv
126-
ConstAppError err -> throw $ MachineException (ConstAppMachineError err) term
131+
ConstAppError err ->
132+
throw $ MachineException (ConstAppMachineError err) term
127133

128134
-- | Evaluate a term using the CEK machine. May throw a 'MachineException'.
129135
evaluateCek :: Term TyName Name () -> EvaluationResult

0 commit comments

Comments
 (0)