<html><head></head><body dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I end up with a working poc, yes, without generics involved, like this:<div class=""><br class=""></div><div class="">```</div><div class=""><div style="color: rgb(212, 190, 152); background-color: rgb(41, 40, 40); font-family: Menlo, Monaco, "Courier New", monospace; line-height: 18px; white-space: pre;"><br><div><span style="color: #9b84da;">{-# </span><span style="color: #9b84da;font-weight: bold;">LANGUAGE</span><span style="color: #9b84da;"> </span></div><div><span style="color: #9b84da;">  </span><span style="color: #9b84da;text-decoration: underline;">ViewPatterns</span>,</div><div><span style="color: #9b84da;">  </span><span style="color: #9b84da;text-decoration: underline;">KindSignatures</span>,</div><div><span style="color: #9b84da;">  </span><span style="color: #9b84da;text-decoration: underline;">TypeOperators</span>,<span style="color: #9b84da;"> </span></div><div><span style="color: #9b84da;">  </span><span style="color: #9b84da;text-decoration: underline;">DataKinds</span>,<span style="color: #9b84da;"> </span></div><div><span style="color: #9b84da;">  </span><span style="color: #9b84da;text-decoration: underline;">FlexibleInstances</span>,<span style="color: #9b84da;"> </span></div><div><span style="color: #9b84da;">  </span><span style="color: #9b84da;text-decoration: underline;">FlexibleContexts</span>,<span style="color: #9b84da;"> </span></div><div><span style="color: #9b84da;">  </span><span style="color: #9b84da;text-decoration: underline;">PatternSynonyms</span>,<span style="color: #9b84da;"> </span></div><div><span style="color: #9b84da;">  </span><span style="color: #9b84da;text-decoration: underline;">ConstraintKinds</span>,<span style="color: #9b84da;"> </span></div><div><span style="color: #9b84da;">  </span><span style="color: #9b84da;text-decoration: underline;">ScopedTypeVariables</span>,<span style="color: #9b84da;"> </span></div><br><div><span style="color: #9b84da;">  </span><span style="color: #9b84da;text-decoration: underline;">BangPatterns</span></div><div><span style="color: #9b84da;">#-}</span></div><br><div><span style="color: #cc524b;">module</span><span style="color: #73a36c;"> Main </span><span style="color: #cc524b;">where</span></div><br><div><span style="color: #cc524b;">import</span><span style="color: #73a36c;">           Prelude</span></div><br><div><span style="color: #cc524b;">import</span><span style="color: #73a36c;">           GHC.TypeLits                   </span>(<span style="color: #73a36c;"> </span><span style="color: #6b95c5;">Symbol</span></div><div><span style="color: #73a36c;">                                                </span>,<span style="color: #73a36c;"> </span><span style="color: #6b95c5;">KnownSymbol</span></div><div><span style="color: #73a36c;">                                                </span>,<span style="color: #73a36c;"> </span><span style="color: #66a89d;">symbolVal</span></div><div><span style="color: #73a36c;">                                                </span>)</div><div><span style="color: #cc524b;">import</span><span style="color: #73a36c;">           Data.Kind                      </span>(<span style="color: #73a36c;"> </span><span style="color: #6b95c5;">Type</span><span style="color: #73a36c;"> </span>)</div><div><span style="color: #cc524b;">import</span><span style="color: #73a36c;">           Data.Maybe</span></div><div><span style="color: #cc524b;">import</span><span style="color: #73a36c;">           Data.Proxy</span></div><div><span style="color: #cc524b;">import</span><span style="color: #73a36c;">           Data.Dynamic</span></div><br><br><div><span style="color: #7e6b5f;">-- artifacts for named arguments</span></div><br><div><span style="color: #cc524b;">newtype</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">NamedArg</span><span style="color: #d4bfa0;"> </span>(<span style="color: #82aed8;font-style: italic;">t</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Type</span>)<span style="color: #d4bfa0;"> </span>(<span style="color: #82aed8;font-style: italic;">name</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Symbol</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">t</span></div><div><span style="color: #cc524b;">type</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">!:</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">t</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">NamedArg</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">t</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span></div><div><span style="color: #cc524b;">type</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">?:</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">t</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">NamedArg</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">Maybe</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">t</span>)<span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span></div><br><div><span style="color: #cc524b;">pattern</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">Arg</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">t</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">!:</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">t</span></div><div><span style="color: #cc524b;">pattern</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">Arg</span><span style="color: #d4bfa0;"> t </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> t</span></div><div><span style="color: #9b84da;">{-# </span><span style="color: #9b84da;font-weight: bold;">COMPLETE</span><span style="color: #9b84da;"> Arg #-}</span></div><br><div><span style="color: #66a89d;">arg</span><span style="color: #96b946;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #96b946;">  </span><span style="color: #82aed8;font-style: italic;">name</span><span style="color: #96b946;"> </span><span style="color: #6b95c5;">!:</span><span style="color: #96b946;"> </span><span style="color: #82aed8;font-style: italic;">t</span><span style="color: #96b946;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #96b946;"> </span><span style="color: #82aed8;font-style: italic;">t</span><span style="color: #96b946;"> </span></div><div><span style="color: #d4bfa0;">arg </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> a</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> a</span></div><br><div><span style="color: #66a89d;">optionalArg</span><span style="color: #96b946;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #96b946;"> </span><span style="color: #82aed8;font-style: italic;">name</span><span style="color: #96b946;"> </span><span style="color: #6b95c5;">?:</span><span style="color: #96b946;"> </span><span style="color: #82aed8;font-style: italic;">t</span><span style="color: #96b946;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #96b946;"> </span><span style="color: #6b95c5;">Maybe</span><span style="color: #96b946;"> </span><span style="color: #82aed8;font-style: italic;">t</span></div><div><span style="color: #d4bfa0;">optionalArg </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">ma</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> ma</span></div><br><div><span style="color: #66a89d;">defaultArg</span><span style="color: #96b946;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #96b946;"> </span><span style="color: #82aed8;font-style: italic;">t</span><span style="color: #96b946;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #96b946;"> </span><span style="color: #82aed8;font-style: italic;">name</span><span style="color: #96b946;"> </span><span style="color: #6b95c5;">?:</span><span style="color: #96b946;"> </span><span style="color: #82aed8;font-style: italic;">t</span><span style="color: #96b946;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #96b946;"> </span><span style="color: #82aed8;font-style: italic;">t</span></div><div><span style="color: #d4bfa0;">defaultArg </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">a </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">ma</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> fromMaybe a ma</span></div><br><br><div><span style="color: #7e6b5f;">-- * minimum data structures as interface with scripting code</span></div><br><div><span style="color: #cc524b;">type</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrKey</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">String</span></div><div><span style="color: #cc524b;">data</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">NilValue</span></div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">|</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">IntValue</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #6b95c5;">Integer</span></div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">|</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #6b95c5;">String</span></div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;">deriving</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">Eq</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Ord</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Typeable</span>)</div><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Show</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  show </span><span style="color: #cca143;">NilValue</span><span style="color: #d4bfa0;">      </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"nil"</span></div><div><span style="color: #d4bfa0;">  show </span>(<span style="color: #cca143;">IntValue</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">x</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> show x</span></div><div><span style="color: #d4bfa0;">  show </span>(<span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">x</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> show x</span></div><br><br><div><span style="color: #cc524b;">data</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">ArgsPack</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">{</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cca143;">positional'args</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span>[<span style="color: #6b95c5;">AttrVal</span>]</div><div><span style="color: #d4bfa0;">  </span>,<span style="color: #d4bfa0;"> </span><span style="color: #cca143;">keyword'args</span><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span>[(<span style="color: #6b95c5;">AttrKey</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span>)]</div><div><span style="color: #d4bfa0;">  </span><span style="color: #cca143;">}</span></div><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Semigroup</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">ArgsPack</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> p1 kw1</span>)<span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> p2 kw2</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>(<span style="color: #d4bfa0;">p1 </span><span style="color: #a3d349;">++</span><span style="color: #d4bfa0;"> p2</span>)<span style="color: #d4bfa0;"> </span>(<span style="color: #d4bfa0;">kw1 </span><span style="color: #a3d349;">++</span><span style="color: #d4bfa0;"> kw2</span>)</div><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Monoid</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">ArgsPack</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  mempty </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>[]<span style="color: #d4bfa0;"> </span>[]</div><br><div><span style="color: #d4bfa0;">takeKwArg</span></div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrKey</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span>[(<span style="color: #6b95c5;">AttrKey</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span>)]<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">Maybe</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span>,<span style="color: #d4bfa0;"> </span>[(<span style="color: #6b95c5;">AttrKey</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span>)])</div><div><span style="color: #d4bfa0;">takeKwArg </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">k </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> go </span>[]<span style="color: #d4bfa0;"> kwargs</span></div><div><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  go</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span>[(<span style="color: #6b95c5;">AttrKey</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span>)]</div><div><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span>[(<span style="color: #6b95c5;">AttrKey</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span>)]</div><div><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">Maybe</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span>,<span style="color: #d4bfa0;"> </span>[(<span style="color: #6b95c5;">AttrKey</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span>)])</div><div><span style="color: #d4bfa0;">  go _      </span>[]<span style="color: #d4bfa0;">                         </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">Nothing</span>,<span style="color: #d4bfa0;"> kwargs</span>)</div><div><span style="color: #d4bfa0;">  go others </span>(<span style="color: #d4bfa0;">p</span><span style="color: #cca143;">@</span>(<span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">key</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">val</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cca143;">:</span><span style="color: #d4bfa0;"> kwargs'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">if</span><span style="color: #d4bfa0;"> key </span><span style="color: #a3d349;">==</span><span style="color: #d4bfa0;"> k</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;">then</span><span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">Just</span><span style="color: #d4bfa0;"> val</span>,<span style="color: #d4bfa0;"> reverse others </span><span style="color: #a3d349;">++</span><span style="color: #d4bfa0;"> kwargs'</span>)</div><div><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;">else</span><span style="color: #d4bfa0;"> go </span>(<span style="color: #d4bfa0;">p </span><span style="color: #cca143;">:</span><span style="color: #d4bfa0;"> others</span>)<span style="color: #d4bfa0;"> kwargs'</span></div><br><br><div><span style="color: #cc524b;">type</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">ContProc</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">AttrVal</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">IO</span><span style="color: #d4bfa0;"> </span>())<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">IO</span><span style="color: #d4bfa0;"> </span>()</div><br><div><span style="color: #7e6b5f;">-- | Haskell functions callable with an apk</span></div><div><span style="color: #cc524b;">class</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #96b946;">  </span><span style="color: #66a89d;">call</span><span style="color: #96b946;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #96b946;"> </span><span style="color: #82aed8;font-style: italic;">fn</span><span style="color: #96b946;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #96b946;"> </span><span style="color: #6b95c5;">ArgsPack</span><span style="color: #96b946;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #96b946;"> </span><span style="color: #6b95c5;">ContProc</span></div><br><div><span style="color: #7e6b5f;">-- instance for nullary functions, which is the base case</span></div><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">ContProc</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">args </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs</span>)<span style="color: #d4bfa0;"> exit </span><span style="color: #cc524b;font-weight: bold;">=</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;">if</span><span style="color: #d4bfa0;"> null args </span><span style="color: #a3d349;">&&</span><span style="color: #d4bfa0;"> null kwargs </span><span style="color: #cc524b;">then</span><span style="color: #d4bfa0;"> fn exit </span><span style="color: #cc524b;">else</span><span style="color: #d4bfa0;"> error </span><span style="color: #97a2a7;">"extraneous args"</span></div><br><div><span style="color: #7e6b5f;">-- instance for repacking arg receiver</span></div><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">ArgsPack</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">apk </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> call </span>(<span style="color: #d4bfa0;">fn apk</span>)<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>[]<span style="color: #d4bfa0;"> </span>[])<span style="color: #d4bfa0;"> exit</span></div><br><div><span style="color: #7e6b5f;">-- instances for positional arg receivers</span></div><br><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">AttrVal</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>(<span style="color: #d4bfa0;">val </span><span style="color: #cca143;">:</span><span style="color: #d4bfa0;"> args</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit </span><span style="color: #cc524b;font-weight: bold;">=</span></div><div><span style="color: #d4bfa0;">    call </span>(<span style="color: #d4bfa0;">fn val</span>)<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args kwargs</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">  call _ _ _ </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> error </span><span style="color: #97a2a7;">"missing anonymous arg"</span></div><br><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">Maybe</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>[]<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit </span><span style="color: #cc524b;font-weight: bold;">=</span></div><div><span style="color: #d4bfa0;">    call </span>(<span style="color: #d4bfa0;">fn </span><span style="color: #cca143;">Nothing</span>)<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>[]<span style="color: #d4bfa0;"> kwargs</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>(<span style="color: #d4bfa0;">val </span><span style="color: #cca143;">:</span><span style="color: #d4bfa0;"> args</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit </span><span style="color: #cc524b;font-weight: bold;">=</span></div><div><span style="color: #d4bfa0;">    call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">Just</span><span style="color: #d4bfa0;"> val</span>))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args kwargs</span>)<span style="color: #d4bfa0;"> exit</span></div><br><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">String</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>(<span style="color: #d4bfa0;">val </span><span style="color: #cca143;">:</span><span style="color: #d4bfa0;"> args</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> val </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">val' </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> call </span>(<span style="color: #d4bfa0;">fn val'</span>)<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args kwargs</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">    _              </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> error </span><span style="color: #97a2a7;">"arg type mismatch"</span></div><div><span style="color: #d4bfa0;">  call _ _ _ </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> error </span><span style="color: #97a2a7;">"missing anonymous arg"</span></div><br><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">Maybe</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">String</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>[]<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit </span><span style="color: #cc524b;font-weight: bold;">=</span></div><div><span style="color: #d4bfa0;">    call </span>(<span style="color: #d4bfa0;">fn </span><span style="color: #cca143;">Nothing</span>)<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>[]<span style="color: #d4bfa0;"> kwargs</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>(<span style="color: #d4bfa0;">val </span><span style="color: #cca143;">:</span><span style="color: #d4bfa0;"> args</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> val </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">val' </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">Just</span><span style="color: #d4bfa0;"> val'</span>))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args kwargs</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">    _              </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> error </span><span style="color: #97a2a7;">"arg type mismatch"</span></div><br><div><span style="color: #7e6b5f;">-- todo instances for receivers of positional arg of (Maybe) Integer</span></div><div><span style="color: #7e6b5f;">-- type, and other types covered by AttrVal</span></div><br><div><span style="color: #7e6b5f;">-- instances for keyword arg receivers</span></div><br><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">KnownSymbol</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">NamedArg</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">args </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> takeKwArg argName kwargs </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">    </span>(<span style="color: #cca143;">Just</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">val</span>,<span style="color: #d4bfa0;"> kwargs'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span></div><div><span style="color: #d4bfa0;">      call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> val</span>))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args kwargs'</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">    </span>(<span style="color: #cca143;">Nothing</span>,<span style="color: #d4bfa0;"> kwargs'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> args </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">      </span>[]<span style="color: #d4bfa0;">            </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> error </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"missing named arg: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> argName</span></div><div><span style="color: #d4bfa0;">      </span>(<span style="color: #d4bfa0;">val </span><span style="color: #cca143;">:</span><span style="color: #d4bfa0;"> args'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> val</span>))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args' kwargs'</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;">where</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">argName </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> symbolVal </span>(<span style="color: #cca143;">Proxy</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Proxy</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span>)</div><br><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">KnownSymbol</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">NamedArg</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">Maybe</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span>)<span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">args </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> takeKwArg argName kwargs </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">    </span>(<span style="color: #cca143;">Nothing</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> args </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">      </span>[]<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">Nothing</span>))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>[]<span style="color: #d4bfa0;"> kwargs'</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">      val </span><span style="color: #cca143;">:</span><span style="color: #d4bfa0;"> args' </span><span style="color: #cc524b;font-weight: bold;">-></span></div><div><span style="color: #d4bfa0;">        call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">Just</span><span style="color: #d4bfa0;"> val</span>)))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args' kwargs'</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">    </span>(<span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">maybeVal</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span></div><div><span style="color: #d4bfa0;">      call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> maybeVal</span>))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args kwargs'</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;">where</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">argName </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> symbolVal </span>(<span style="color: #cca143;">Proxy</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Proxy</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span>)</div><br><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">KnownSymbol</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">NamedArg</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">String</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">args </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> takeKwArg argName kwargs </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">    </span>(<span style="color: #cca143;">Just</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">val</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> val </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">      </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">val' </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> val'</span>))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args kwargs'</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">      _              </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> error </span><span style="color: #97a2a7;">"arg type mismatch"</span></div><div><span style="color: #d4bfa0;">    </span>(<span style="color: #cca143;">Nothing</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> args </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">      </span>[]<span style="color: #d4bfa0;">          </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> error </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"missing named arg: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> argName</span></div><div><span style="color: #d4bfa0;">      val </span><span style="color: #cca143;">:</span><span style="color: #d4bfa0;"> args' </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> val </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">        </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">val' </span><span style="color: #cc524b;font-weight: bold;">-></span></div><div><span style="color: #d4bfa0;">          call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> val'</span>))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args' kwargs'</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">        _ </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> error </span><span style="color: #97a2a7;">"arg type mismatch"</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;">where</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">argName </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> symbolVal </span>(<span style="color: #cca143;">Proxy</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Proxy</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span>)</div><br><div><span style="color: #cc524b;">instance</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">KnownSymbol</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span>,<span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">=></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Callable</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">NamedArg</span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">Maybe</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">String</span>)<span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">fn'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><div><span style="color: #d4bfa0;">  call </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">args </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> takeKwArg argName kwargs </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">    </span>(<span style="color: #cca143;">Just</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">val</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> val </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">      </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">val' </span><span style="color: #cc524b;font-weight: bold;">-></span></div><div><span style="color: #d4bfa0;">        call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">Just</span><span style="color: #d4bfa0;"> val'</span>)))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args kwargs'</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">      _ </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> error </span><span style="color: #97a2a7;">"arg type mismatch"</span></div><div><span style="color: #d4bfa0;">    </span>(<span style="color: #cca143;">Nothing</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">kwargs'</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> args </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">      </span>[]<span style="color: #d4bfa0;">          </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">Nothing</span>))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>[]<span style="color: #d4bfa0;"> kwargs'</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">      val </span><span style="color: #cca143;">:</span><span style="color: #d4bfa0;"> args' </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> val </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">        </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">val' </span><span style="color: #cc524b;font-weight: bold;">-></span></div><div><span style="color: #d4bfa0;">          call </span>(<span style="color: #d4bfa0;">fn </span>(<span style="color: #cca143;">NamedArg</span><span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">Just</span><span style="color: #d4bfa0;"> val'</span>)))<span style="color: #d4bfa0;"> </span>(<span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> args' kwargs'</span>)<span style="color: #d4bfa0;"> exit</span></div><div><span style="color: #d4bfa0;">        _ </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> error </span><span style="color: #97a2a7;">"arg type mismatch"</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;">where</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">argName </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> symbolVal </span>(<span style="color: #cca143;">Proxy</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">Proxy</span><span style="color: #d4bfa0;"> </span><span style="color: #82aed8;font-style: italic;">name</span>)</div><br><div><span style="color: #7e6b5f;">-- todo instances for receivers of keyword arg of (Maybe) Integer</span></div><div><span style="color: #7e6b5f;">-- type, and other types covered by AttrVal</span></div><br><br><div><span style="color: #7e6b5f;">-- * functions to be callable from scripting code</span></div><br><div><span style="color: #7e6b5f;">-- | interfacing Haskell function meant to be easily called by scripting code</span></div><div><span style="color: #d4bfa0;">assert</span></div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"expect"</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">!:</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span></div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"target"</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">?:</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">AttrVal</span></div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"message"</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">?:</span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">String</span></div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span>(<span style="color: #6b95c5;">AttrVal</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">IO</span><span style="color: #d4bfa0;"> </span>())</div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #6b95c5;">IO</span><span style="color: #d4bfa0;"> </span>()</div><div><span style="color: #d4bfa0;">assert </span>(<span style="color: #cca143;">Arg</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">expect</span>)<span style="color: #d4bfa0;"> </span>(<span style="color: #d4bfa0;">optionalArg </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">maybeTarget</span>)<span style="color: #d4bfa0;"> </span>(<span style="color: #d4bfa0;">defaultArg </span><span style="color: #97a2a7;">"sth ought to be"</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">message</span>)<span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">exit</span></div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> maybeTarget </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cca143;">Nothing</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">case</span><span style="color: #d4bfa0;"> expect </span><span style="color: #cc524b;">of</span></div><div><span style="color: #d4bfa0;">      </span><span style="color: #cca143;">NilValue</span><span style="color: #d4bfa0;">    </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> error </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"* assertion failed: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> message</span></div><div><span style="color: #d4bfa0;">      </span><span style="color: #cca143;">IntValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">0</span><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> error </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"* assertion failed: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> message</span></div><div><span style="color: #d4bfa0;">      </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">""</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> error </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"* assertion failed: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> message</span></div><div><span style="color: #d4bfa0;">      _           </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> exit </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"* assertion passed: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> message</span></div><div><span style="color: #d4bfa0;">    </span><span style="color: #cca143;">Just</span><span style="color: #d4bfa0;"> target </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">if</span><span style="color: #d4bfa0;"> expect </span><span style="color: #a3d349;">==</span><span style="color: #d4bfa0;"> target</span></div><div><span style="color: #d4bfa0;">      </span><span style="color: #cc524b;">then</span><span style="color: #d4bfa0;"> exit </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"* assertion passed: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> message</span></div><div><span style="color: #d4bfa0;">      </span><span style="color: #cc524b;">else</span><span style="color: #d4bfa0;"> error </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"* assertion failed: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> message</span></div><br><br><div><span style="color: #7e6b5f;">-- mockup & test out</span></div><div><span style="color: #66a89d;">main</span><span style="color: #96b946;"> </span><span style="color: #cc524b;font-weight: bold;">::</span><span style="color: #96b946;"> </span><span style="color: #6b95c5;">IO</span><span style="color: #96b946;"> </span>()</div><div><span style="color: #d4bfa0;">main </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">do</span></div><div><span style="color: #d4bfa0;">  call assert apk1 </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">\</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">result </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> putStrLn </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"Got result1: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> show result</span></div><div><span style="color: #d4bfa0;">  call assert apk2 </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">\</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">result </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> putStrLn </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"Got result2: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> show result</span></div><div><span style="color: #d4bfa0;">  call assert apk3 </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">\</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">result </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> putStrLn </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"Got result3: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> show result</span></div><div><span style="color: #d4bfa0;">  call assert apk4 </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">\</span><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">result </span><span style="color: #cc524b;font-weight: bold;">-></span><span style="color: #d4bfa0;"> putStrLn </span><span style="color: #a3d349;">$</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"Got result4: "</span><span style="color: #d4bfa0;"> </span><span style="color: #a3d349;"><></span><span style="color: #d4bfa0;"> show result</span></div><br><div><span style="color: #d4bfa0;"> </span><span style="color: #cc524b;">where</span></div><br><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">apk1 </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">ArgsPack</span></div><div><span style="color: #d4bfa0;">    </span>[]</div><div><span style="color: #d4bfa0;">    </span>[<span style="color: #d4bfa0;"> </span>(<span style="color: #97a2a7;">"message"</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"as good will"</span>)</div><div><span style="color: #d4bfa0;">    </span>,<span style="color: #d4bfa0;"> </span>(<span style="color: #97a2a7;">"target"</span><span style="color: #d4bfa0;"> </span>,<span style="color: #d4bfa0;"> </span><span style="color: #cca143;">IntValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">333</span>)</div><div><span style="color: #d4bfa0;">    </span>,<span style="color: #d4bfa0;"> </span>(<span style="color: #97a2a7;">"expect"</span><span style="color: #d4bfa0;"> </span>,<span style="color: #d4bfa0;"> </span><span style="color: #cca143;">IntValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">333</span>)</div><div><span style="color: #d4bfa0;">    </span>]</div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">apk2 </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>[<span style="color: #cca143;">IntValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">333</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cca143;">IntValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">333</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cca143;">StrValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">"as good will"</span>]<span style="color: #d4bfa0;"> </span>[]</div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">apk3 </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>[<span style="color: #cca143;">IntValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">333</span>]<span style="color: #d4bfa0;"> </span>[(<span style="color: #97a2a7;">"target"</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cca143;">IntValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">333</span>)]</div><div><span style="color: #d4bfa0;">  </span><span style="color: #cc524b;font-weight: bold;">!</span><span style="color: #d4bfa0;">apk4 </span><span style="color: #cc524b;font-weight: bold;">=</span><span style="color: #d4bfa0;"> </span><span style="color: #cca143;">ArgsPack</span><span style="color: #d4bfa0;"> </span>[]<span style="color: #d4bfa0;"> </span>[(<span style="color: #97a2a7;">"target"</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cca143;">IntValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">333</span>),<span style="color: #d4bfa0;"> </span>(<span style="color: #97a2a7;">"expect"</span>,<span style="color: #d4bfa0;"> </span><span style="color: #cca143;">IntValue</span><span style="color: #d4bfa0;"> </span><span style="color: #97a2a7;">555</span>)]</div><br></div></div><div class="">```<br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 2020-09-11, at 00:50, YueCompl via Haskell-Cafe <<a href="mailto:haskell-cafe@haskell.org" class="">haskell-cafe@haskell.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Then any better approach, to auto (or at least semi-auto) adapt an ArgsPack toward applying an arbitrary Haskell function?<br class=""><br class=""><blockquote type="cite" class="">On 2020-09-11, at 00:35, Li-yao Xia <<a href="mailto:lysxia@gmail.com" class="">lysxia@gmail.com</a>> wrote:<br class=""><br class="">This doesn't sound like a use case for generics then. Just to spare you the trouble of following a red herring.<br class=""><br class="">On 9/10/2020 12:26 PM, YueCompl wrote:<br class=""><blockquote type="cite" class="">Li-yao, thanks for the pointer. And my case is not really about ADTs, but to introspect the arguments an arbitrary Haskell function takes, including how many and what type each argument is, so as to extract proper values from a given ArgsPack, then call that Haskell function with those values as args it expects.<br class="">I'm not sure at a glance, that generics-eot has demonstrated how to obtain argument list with type info for a function, and will look into the details as I can.<br class="">Thanks with regards,<br class="">Compl<br class=""><blockquote type="cite" class="">On 2020-09-10, at 23:08, Li-yao Xia <<a href="mailto:lysxia@gmail.com" class="">lysxia@gmail.com</a> <<a href="mailto:lysxia@gmail.com" class="">mailto:lysxia@gmail.com</a>>> wrote:<br class=""><br class="">Hi Compl,<br class=""><br class="">I couldn't tell what's generic (in the sense of GHC.Generics) about this example. A clearer example would be to give two applications with different algebraic data types, and to show how they consist of the same boilerplate, where the differences are only due to the differing numbers of fields and constructors.<br class=""><br class="">As for tutorials on generics, a good starting point might be generics-eot. Its documentation comes with a series of tutorials:<br class=""><br class=""><a href="https://generics-eot.readthedocs.io/en/stable/" class="">https://generics-eot.readthedocs.io/en/stable/</a><br class=""><br class="">Li-yao<br class=""><br class="">On 9/10/2020 9:44 AM, YueCompl via Haskell-Cafe wrote:<br class=""><blockquote type="cite" class="">Dear Cafe,<br class="">I'm tinkering with the idea for arbitrary Haskell functions to be easily called from scripting code, I see auto derive with GHC.Generics might be the most promising tool, but I'm lost after read <a href="https://wiki.haskell.org/GHC.Generics" class="">https://wiki.haskell.org/GHC.Generics</a> and hackage docs. I have no clue so far with how to start with it.<br class="">Specifically I want the section highlighted in blue get auto generated, within the following `runghc` ready example:<br class="">```<br class="">{-# LANGUAGEBangPatterns#-}<br class="">moduleMain where<br class="">importPrelude<br class="">importGHC.Generics<br class="">importData.Dynamic<br class="">-- * minimum data structures as interface with scripting code<br class="">typeAttrKey=String<br class="">dataAttrVal=NilValue<br class="">|IntValue!Integer<br class="">|StrValue!String<br class="">deriving(Eq,Ord,Typeable)<br class="">instanceShowAttrValwhere<br class="">show NilValue="nil"<br class="">show (IntValue!x)=show x<br class="">show (StrValue!x)=show x<br class="">dataArgsPack=ArgsPack{<br class="">positional'args::[AttrVal]<br class="">,keyword'args::[(AttrKey,AttrVal)]<br class="">}<br class="">instanceSemigroupArgsPackwhere<br class="">(ArgsPackp1 kw1)<>(ArgsPackp2 kw2)=ArgsPack(p1 ++p2)(kw1 ++kw2)<br class="">instanceMonoidArgsPackwhere<br class="">mempty =ArgsPack[][]<br class="">classCallableawhere<br class="">call::a->ArgsPack->(AttrVal->IO())->IO()<br class="">-- * functions to be callable from scripting code<br class="">newtypeAssert=Assert(<br class="">Expect->MaybeTarget->Message->IOMessage<br class="">)<br class="">typeExpect=AttrVal<br class="">typeTarget=AttrVal<br class="">typeMessage=String<br class="">instanceCallableAssertwhere<br class="">-- can this get auto-generated ? with <a href="https://wiki.haskell.org/GHC.Generics" class="">https://wiki.haskell.org/GHC.Generics</a><br class="">call (Assert!assert)(ArgsPack!args !kwargs)!exit =do<br class="">(expect,target,message)<-parseApk<br class="">result <-assert expect target message<br class="">exit $StrValueresult<br class="">where<br class="">parseApk::IO(Expect,MaybeTarget,Message)<br class="">parseApk =goParse<br class="">(Left"missing arg: expect",Nothing,Left"missing arg: message")<br class="">args<br class="">kwargs<br class="">goParse (got'expect,got'target,got'message)[][]=casegot'expect of<br class="">Leftmsg ->error msg<br class="">Rightexpect ->casegot'message of<br class="">Leftmsg ->error msg<br class="">Rightmessage ->return (expect,got'target,message)<br class="">goParse (got'expect,got'target,got'message)args' ((name,val):kwargs')<br class="">=casename of<br class="">"expect"->casegot'expect of<br class="">Right{}->error "duplicate arg: expect"<br class="">Left{}->goParse (Rightval,got'target,got'message)args' kwargs'<br class="">"target"->casegot'target of<br class="">Just{}->error "duplicate arg: target"<br class="">Nothing->goParse (got'expect,Justval,got'message)args' kwargs'<br class="">"message"->casegot'message of<br class="">Right{}->error "duplicate arg: message"<br class="">Left{}->caseval of<br class="">StrValuemessage -><br class="">goParse (got'expect,got'target,Rightmessage)args' kwargs'<br class="">_ ->error "bad arg type for: message"<br class="">_ ->error "unexpected keyword args"<br class="">goParse (got'expect,got'target,got'message)(val :args')[]=<br class="">casegot'expect of<br class="">Left{}->goParse (Rightval,got'target,got'message)args' []<br class="">Right{}->casegot'target of<br class="">Nothing->goParse (got'expect,Justval,got'message)args' []<br class="">Just{}->casegot'message of<br class="">Left{}->caseval of<br class="">StrValuemessage -><br class="">goParse (got'expect,got'target,Rightmessage)args' []<br class="">_ ->error "bad arg type for: message"<br class="">Right{}->error "extranous positional args"<br class="">-- mockup & test out<br class="">main::IO()<br class="">main =<br class="">call<br class="">(Assertassert)<br class="">(ArgsPack[IntValue333,StrValue"as good will"]<br class="">[("target",IntValue333)]<br class="">)<br class="">$\result ->putStrLn $"Got result: "<>show result<br class="">-- | plain Haskell function meant to be easily called by scripting code<br class="">assert::Expect->MaybeTarget->Message->IOMessage<br class="">assert !expect !maybeTarget !message =casemaybeTarget of<br class="">Nothing->return $"* assertion not applicable: "<>message<br class="">Justtarget ->ifexpect ==target<br class="">thenreturn $"* assertion passed: "<>message<br class="">elseerror $"* assertion failed: "<>message<br class="">```<br class="">I tried to understand how<br class=""> * The compiler can provide a default generic implementation for<br class="">   |parseJSON<br class="">   <<a href="https://hackage.haskell.org/package/aeson-1.5.4.0/docs/Data-Aeson.html#v:parseJSON" class="">https://hackage.haskell.org/package/aeson-1.5.4.0/docs/Data-Aeson.html#v:parseJSON</a>>|.<br class="">is implemented in [aeson](<a href="https://hackage.haskell.org/package/aeson" class="">https://hackage.haskell.org/package/aeson</a>) and it is overwhelming to me at the moment ...<br class="">Is there easier scaffold template for me to start with GHC.Generics? Or there're even better techniques to achieve my final goal?<br class="">Help please!<br class="">Best regards,<br class="">Compl<br class="">_______________________________________________<br class="">Haskell-Cafe mailing list<br class="">To (un)subscribe, modify options or view archives go to:<br class=""><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">Only members subscribed via the mailman list are allowed to post.<br class=""></blockquote></blockquote></blockquote></blockquote><br class="">_______________________________________________<br class="">Haskell-Cafe mailing list<br class="">To (un)subscribe, modify options or view archives go to:<br class=""><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">Only members subscribed via the mailman list are allowed to post.</div></div></blockquote></div><br class=""></div></div></div></div></div></body></html>