Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

MonadMakers

Guides

  • Monad making

Tech Notes

  • Monad code generation and extension

Symbols

  • AssociationModule
  • GenerateMonadAccessors
  • GenerateMonadDroper
  • GenerateMonadSetter
  • GenerateMonadTaker
  • GenerateStateMonadCode
  • Grid87
  • TraceMonadBind
  • TraceMonadEchoGrid
  • TraceMonad
  • TraceMonadTakeGrid
  • TraceMonadUnit
  • $TraceMonadFailure
AntonAntonov`MonadMakers`
GenerateStateMonadCode
​
GenerateStateMonadCode
[prefix]
generate a state monad for a specified prefix
​
Details and Options

Examples  
(2)
Basic Examples  
(1)
Generate a software monad with prefix "MState":
In[1]:=
GenerateStateMonadCode
["MState"]
Execute monadic pipeline with MState:
In[2]:=
SeedRandom[34];​​MStateUnit[RandomReal[{0,1},{3,2}],"mark""None","threshold"0.5]⟹​​MStateEchoValue⟹​​MStateEchoContext⟹​​MStateAddToContext["data"]⟹​​(MStateUnit[#1/.(x_/;x<#2["threshold"]#2["mark"]),#2]&)⟹MStateEchoValue⟹MStateModifyContext[Join[#1,"mark""Lesser","threshold"0.8]&]⟹MStateEchoContext⟹​​(MStateUnit[#2["data"]/.(x_/;x<#2["threshold"]#2["mark"]),#2]&)⟹​​MStateEchoValue;
»
value:{{0.789884,0.831468},{0.421298,0.50537},{0.0375957,0.289442}}
»
context:markNone,threshold0.5
»
value:{{0.789884,0.831468},{None,0.50537},{None,None}}
»
context:markLesser,threshold0.8,data{{0.789884,0.831468},{0.421298,0.50537},{0.0375957,0.289442}}
»
value:{{Lesser,0.831468},{Lesser,Lesser},{Lesser,Lesser}}
The command above defined these functions:
In[3]:=
Names["MState*"]
Out[3]=
{MState,MStateAddToContext,MStateAssignContextTo,MStateAssignTo,MStateAssignValueTo,MStateBind,MStateContexts,MStateDropFromContext,MStateEcho,MStateEchoContext,MStateEchoFunctionContext,MStateEchoFunctionValue,MStateEchoValue,MStateFail,MStateFold,MStateIf,MStateIfElse,MStateIterate,MStateModifyContext,MStateModule,MStateNest,MStateNestWhile,MStateOption,MStatePutContext,MStatePutValue,MStateRetrieveFromContext,MStateSetContext,MStateSetValue,MStateSucceed,MStateTakeContext,MStateTakeValue,MStateUnit,MStateUnitQ,MStateWhen}
Properties & Relations  
(1)

SeeAlso
"XXXX"
TechNotes
▪
Monad code generation and extension
RelatedGuides
▪
Monad making
""

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com