Skip to content

Commit

Permalink
(not compiling) wip on offers, taking a break
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxWilson committed Jan 5, 2024
1 parent c04135e commit 513492f
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions test/Chargen.Accept.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ type OfferConfig = {
label: string option
}
with static member blank = { key = None; label = None }
type 't Offer = { config: OfferConfig; func: (OfferConfig -> OfferInput -> 't) }
with member this.recur input = this.func this.config input
type 't Offer = { config: OfferConfig; func: (OfferConfig -> OfferInput -> 't * MenuOutput) }
with
member this.recur input = this.func this.config input
type 't ListOffer = ('t list) Offer
type 't OptionOffer = ('t option) Offer

Expand Down Expand Up @@ -72,10 +73,33 @@ let render (render: 'reactElement RenderApi) (menus: MenuOutput list) =
menus |> List.map (recur true render.unconditional) |> render.combine

type Op =
static member skill v: 't OptionOffer = notImpl()
static member trait' v: 't OptionOffer = notImpl()
static member offer(config, func) = { config = config; func = func }
static member offer func = Op.offer(OfferConfig.blank, func)

static member skill (name: string, level: int): _ OptionOffer =
Op.skill(OfferConfig.blank, (name, [level]))
static member skill (name: string, levels: int list): _ OptionOffer =
Op.skill(OfferConfig.blank, (name, levels))
static member skill (config, (name: string, levels: int list)): _ OptionOffer =
Op.offer(config, fun config input -> None, (Leaf (defaultArg config.label (toString v))))

Check failure on line 84 in test/Chargen.Accept.fs

View workflow job for this annotation

GitHub Actions / build

The value or constructor 'v' is not defined.

static member trait' v: 't OptionOffer =
Op.trait'(OfferConfig.blank, v)
static member trait' (config, v): 't OptionOffer =
Op.offer(config, fun config input -> Some v, (Leaf (defaultArg config.label (toString v))))

static member budgeted v: 't ListOffer = notImpl()
static member either v : 't OptionOffer = notImpl()

static member either options : 't OptionOffer =
Op.either(OfferConfig.blank, options)
static member either (config, options: 't OptionOffer list) : 't OptionOffer =
Op.offer(
config,
fun config input ->
let children = options |> List.map (fun o -> o.recur input |> Tuple2.mapfst Option.isSome)
None, Either(config.label, children)
)

static member and' v : 't OptionOffer = notImpl()
static member eitherN v : 't ListOffer = notImpl()
static member andN' v : 't ListOffer = notImpl()
Expand Down

0 comments on commit 513492f

Please sign in to comment.