This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 214
Store evaluation with its simulation #155
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
module MainFrame.Lenses | ||
( _demoFilesMenuVisible | ||
, _gistErrorPaneVisible | ||
, _currentView | ||
( _actionDrag | ||
, _authStatus | ||
, _balancesChartSlot | ||
, _blockchainVisualisationState | ||
, _compilationResult | ||
, _contractDemoEditorContents | ||
, _contractDemos | ||
, _createGistResult | ||
, _currentDemoName | ||
, _currentView | ||
, _demoFilesMenuVisible | ||
, _editorSlot | ||
, _editorState | ||
, _simulations | ||
, _actionDrag | ||
, _evaluationResult | ||
, _successfulEvaluationResult | ||
, _lastEvaluatedSimulation | ||
, _compilationResult | ||
, _successfulCompilationResult | ||
, _lastSuccessfulCompilationResult | ||
, _authStatus | ||
, _createGistResult | ||
, _functionSchema | ||
, _gistErrorPaneVisible | ||
, _gistUrl | ||
, _blockchainVisualisationState | ||
, _editorSlot | ||
, _balancesChartSlot | ||
, _contractDemoEditorContents | ||
, _simulationId | ||
, _knownCurrencies | ||
, _lastSuccessfulCompilationResult | ||
, _result | ||
, _resultRollup | ||
, _simulation | ||
, _simulationActions | ||
, _simulationBlockchainVisualisationState | ||
, _simulationEvaluationResult | ||
, _simulationId | ||
, _simulationWallets | ||
, _resultRollup | ||
, _functionSchema | ||
, _simulations | ||
, _successfulCompilationResult | ||
, _successfulEvaluationResult | ||
, _walletKeys | ||
, _knownCurrencies | ||
, _result | ||
, _warnings | ||
, getKnownCurrencies | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔠 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The vscode plugin apparently sorts the exports if you tell it to add another one. |
||
) where | ||
|
@@ -36,19 +38,20 @@ import Prologue | |
import Auth (AuthStatus) | ||
import Chain.Types as Chain | ||
import Control.Monad.State.Class (class MonadState) | ||
import Cursor (Cursor) | ||
import Data.Lens (Lens', Traversal', _Right, lens, preview) | ||
import Cursor (Cursor, _current) | ||
import Data.Lens (Lens', _Right, lens, preview, set) | ||
import Data.Lens.Extra (peruse) | ||
import Data.Lens.Iso.Newtype (_Newtype) | ||
import Data.Lens.Record (prop) | ||
import Data.Lens.Types (AffineTraversal') | ||
import Data.Maybe (fromMaybe) | ||
import Editor.Types (State) as Editor | ||
import Gist (Gist) | ||
import Language.Haskell.Interpreter (InterpreterError, InterpreterResult, SourceCode, _InterpreterResult) | ||
import Ledger.CardanoWallet (WalletNumber) | ||
import MainFrame.Types (State, View, WebData) | ||
import Network.RemoteData (_Success) | ||
import Playground.Types (CompilationResult, ContractCall, ContractDemo, EvaluationResult, FunctionSchema, KnownCurrency, PlaygroundError, Simulation, SimulatorWallet) | ||
import MainFrame.Types (FullSimulation, State, View, WebData, WebEvaluationResult) | ||
import Network.RemoteData (_Success, RemoteData(NotAsked)) | ||
import Playground.Types (CompilationResult, ContractCall, ContractDemo, EvaluationResult, FunctionSchema, KnownCurrency, Simulation, SimulatorWallet) | ||
import Plutus.V1.Ledger.Crypto (PubKeyHash) | ||
import Schema (FormSchema) | ||
import Schema.Types (FormArgument) | ||
|
@@ -73,21 +76,18 @@ _currentDemoName = _Newtype <<< prop (Proxy :: _ "currentDemoName") | |
_editorState :: Lens' State Editor.State | ||
_editorState = _Newtype <<< prop (Proxy :: _ "editorState") | ||
|
||
_simulations :: Lens' State (Cursor Simulation) | ||
_simulations :: Lens' State (Cursor FullSimulation) | ||
_simulations = _Newtype <<< prop (Proxy :: _ "simulations") | ||
|
||
_actionDrag :: Lens' State (Maybe Int) | ||
_actionDrag = _Newtype <<< prop (Proxy :: _ "actionDrag") | ||
|
||
_evaluationResult :: Lens' State (WebData (Either PlaygroundError EvaluationResult)) | ||
_evaluationResult = _Newtype <<< prop (Proxy :: _ "evaluationResult") | ||
_evaluationResult :: Lens' State WebEvaluationResult | ||
_evaluationResult = withDefault NotAsked (_simulations <<< _current <<< _simulationEvaluationResult) | ||
|
||
_successfulEvaluationResult :: Traversal' State EvaluationResult | ||
_successfulEvaluationResult :: AffineTraversal' State EvaluationResult | ||
_successfulEvaluationResult = _evaluationResult <<< _Success <<< _Right | ||
|
||
_lastEvaluatedSimulation :: Lens' State (Maybe Simulation) | ||
_lastEvaluatedSimulation = _Newtype <<< prop (Proxy :: _ "lastEvaluatedSimulation") | ||
|
||
_compilationResult :: Lens' State (WebData (Either InterpreterError (InterpreterResult CompilationResult))) | ||
_compilationResult = _Newtype <<< lens g s | ||
where | ||
|
@@ -97,7 +97,7 @@ _compilationResult = _Newtype <<< lens g s | |
Just cr -> r { compilationResult = c, lastSuccessfulCompilationResult = Just cr } | ||
Nothing -> r { compilationResult = c } | ||
|
||
_successfulCompilationResult :: Traversal' State CompilationResult | ||
_successfulCompilationResult :: AffineTraversal' State CompilationResult | ||
_successfulCompilationResult = _compilationResult <<< _Success <<< _Right <<< _InterpreterResult <<< _result | ||
|
||
_lastSuccessfulCompilationResult :: Lens' State (Maybe CompilationResult) | ||
|
@@ -113,7 +113,24 @@ _gistUrl :: Lens' State (Maybe String) | |
_gistUrl = _Newtype <<< prop (Proxy :: _ "gistUrl") | ||
|
||
_blockchainVisualisationState :: Lens' State Chain.State | ||
_blockchainVisualisationState = _Newtype <<< prop (Proxy :: _ "blockchainVisualisationState") | ||
_blockchainVisualisationState = withDefault Chain.initialState (_simulations <<< _current <<< _simulationBlockchainVisualisationState) | ||
|
||
_simulation :: Lens' FullSimulation Simulation | ||
_simulation = prop (Proxy :: _ "simulation") | ||
|
||
_simulationEvaluationResult :: Lens' FullSimulation WebEvaluationResult | ||
_simulationEvaluationResult = prop (Proxy :: _ "evaluationResult") | ||
|
||
_simulationBlockchainVisualisationState :: Lens' FullSimulation Chain.State | ||
_simulationBlockchainVisualisationState = prop (Proxy :: _ "blockchainVisualisationState") | ||
|
||
------------------------------------------------------------ | ||
withDefault :: forall s a. a -> AffineTraversal' s a -> Lens' s a | ||
withDefault def l = lens doGet doSet | ||
where | ||
doGet s = fromMaybe def $ preview l s | ||
|
||
doSet s a = set l a s | ||
|
||
------------------------------------------------------------ | ||
_editorSlot :: Proxy "editorSlot" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍