Skip to content

Commit

Permalink
Add RequireQualifiedAccess attribute to ProcListValue
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Aug 28, 2024
1 parent 503eff1 commit 996c6f7
Showing 1 changed file with 36 additions and 35 deletions.
71 changes: 36 additions & 35 deletions src/Aardvark.Base.Incremental/Proc/ProcList.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ open System.Threading.Tasks

open Aardvark.Base

[<RequireQualifiedAccess>]
type ProcListValue<'a, 'r> =
| Nil
| Cons of 'a * ProcList<'a, 'r>

and ProcList<'a, 'r>(run : Proc<ProcListValue<'a, 'r>, 'r>) =
static let empty = ProcList<'a, 'r>(Proc.Create Nil)
static let empty = ProcList<'a, 'r>(Proc.Create ProcListValue.Nil)

static member Empty = empty

Expand All @@ -22,15 +23,15 @@ module ProcList =
let empty<'a, 'r> = ProcList<'a, 'r>.Empty

let single (v : 'a) : ProcList<'a, 'r> =
ProcList<'a, 'r>(Proc.create <| Cons(v, empty))
ProcList<'a, 'r>(Proc.create <| ProcListValue.Cons(v, empty))

let ofSeq (v : seq<'a>) : ProcList<'a, 'r> =
use e = v.GetEnumerator()
let rec build() =
if e.MoveNext() then
let v = e.Current
let rest = build()
ProcList(Proc.create <| Cons(v, rest))
ProcList(Proc.create <| ProcListValue.Cons(v, rest))
else
empty
build()
Expand All @@ -41,7 +42,7 @@ module ProcList =
empty

| h :: rest ->
Cons(h, ofList rest)
ProcListValue.Cons(h, ofList rest)
|> Proc.Create
|> ProcList

Expand All @@ -50,7 +51,7 @@ module ProcList =
if i >= arr.Length then
empty
else
ProcList(Proc.create <| Cons(arr.[i], build (i+1) arr))
ProcList(Proc.create <| ProcListValue.Cons(arr.[i], build (i+1) arr))
build 0 arr


Expand All @@ -59,11 +60,11 @@ module ProcList =
proc {
let! c = list.run
match c with
| Nil ->
return Nil
| ProcListValue.Nil ->
return ProcListValue.Nil

| Cons(h,tail) ->
return Cons(mapping h, map mapping tail)
| ProcListValue.Cons(h,tail) ->
return ProcListValue.Cons(mapping h, map mapping tail)
}
)

Expand All @@ -72,15 +73,15 @@ module ProcList =
proc {
let! c = list.run
match c with
| Nil ->
return Nil

| Cons(h,tail) ->
match mapping h with
| Some v ->
return Cons(v, choose mapping tail)
| None ->
return! (choose mapping tail).run
| ProcListValue.Nil ->
return ProcListValue.Nil

| ProcListValue.Cons(h,tail) ->
match mapping h with
| Some v ->
return ProcListValue.Cons(v, choose mapping tail)
| None ->
return! (choose mapping tail).run
}
)

Expand All @@ -89,12 +90,12 @@ module ProcList =
proc {
let! l = list.run
match l with
| Nil -> return Nil
| Cons(h,tail) ->
if predicate h then
return Cons(h, filter predicate tail)
else
return! (filter predicate tail).run
| ProcListValue.Nil -> return ProcListValue.Nil
| ProcListValue.Cons(h,tail) ->
if predicate h then
return ProcListValue.Cons(h, filter predicate tail)
else
return! (filter predicate tail).run
}
)

Expand All @@ -103,8 +104,8 @@ module ProcList =
proc {
let! l = l.run
match l with
| Nil -> return! r.run
| Cons(h,tail) -> return Cons(h, append tail r)
| ProcListValue.Nil -> return! r.run
| ProcListValue.Cons(h,tail) -> return ProcListValue.Cons(h, append tail r)
}
)

Expand All @@ -113,11 +114,11 @@ module ProcList =
proc {
let! l = l.run
match l with
| Nil ->
return Nil
| ProcListValue.Nil ->
return ProcListValue.Nil

| Cons(h,t) ->
return! (append h (concat t)).run
| ProcListValue.Cons(h,t) ->
return! (append h (concat t)).run
}
)

Expand All @@ -134,12 +135,12 @@ module ProcList =
proc {
let! list = list.run
match list with
| Nil ->
return Nil
| ProcListValue.Nil ->
return ProcListValue.Nil

| Cons(h,tail) ->
let res = append (mapping h) (collect mapping tail)
return! res.run
| ProcListValue.Cons(h,tail) ->
let res = append (mapping h) (collect mapping tail)
return! res.run
}
)

Expand Down

0 comments on commit 996c6f7

Please sign in to comment.