Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8590983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:25:16+00:00 2026-06-11T23:25:16+00:00

I have this code let inline ProcessExpendableADGroups (input : (‘a * SPUser) seq) =

  • 0

I have this code

let inline ProcessExpendableADGroups (input : ('a * SPUser) seq) =
  input
  |> Seq.filter (fun (_, u : SPUser) -> u.IsDomainGroup = true)       
  |> Seq.filter (fun (_, u : SPUser) -> ADUtility.IsADGroupExpandable u.LoginName = true)      
  |> List.ofSeq
  |> List.iter( 
      fun ( li : 'a, u : SPUser) -> 
        let userList = ADUtility.GetUsers u.LoginName 
        if (Seq.length userList <= 500) then
          userList
          |> Seq.filter (fun l -> InfobarrierPolicy.IsUserInPolicy l "FW" = true) 
          |> Seq.iter (
              fun ln ->
                let x = ADUtility.GetNameAndEmail ln 
                let (email, name) = x.Value
                SPUtility.CopyRoleAssignment li u.LoginName ln email name
                li.Update()
              )
          SPUtility.RemoveRoleAssignment li u
      )      

list3 
|> List.iter (
    fun w -> 
      SPUtility.GetDirectAssignmentsforListItems w |> ProcessExpendableADGroups
      SPUtility.GetDirectAssignmentsforFolders w |> ProcessExpendableADGroups
      SPUtility.GetDirectAssignmentsforLists w |> ProcessExpendableADGroups
      SPUtility.GetDirectAssignmentsforWeb w |> ProcessExpendableADGroups
   )

Here the methods GetDirectAssignmentsforListItems returns a Sequence of tuples (SPListItem * SPUser)
GetDirectAssignmentsforWeb returns a sequence of tuples (SPWeb * SPUser).

I need to send this sequence to a function which does very similar processing on these items except that in the end I have to call a method called “Update” on these items.

I have written a method with Generic parameter but I am having a problem when I call Update on the generic parameter.

I am not able to constrain this parameter to say that the parameter must have a method called Update.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:25:17+00:00Added an answer on June 11, 2026 at 11:25 pm

    You can use member constraints and statically resolved type parameters to do so.

    let inline ProcessExpendableADGroups (input : (^a * SPUser) seq) = //'
      input
      |> Seq.filter (fun (_, u) -> u.IsDomainGroup && ADUtility.IsADGroupExpandable u.LoginName)       
      |> Seq.iter( 
          fun (li, u) -> 
            let userList = ADUtility.GetUsers u.LoginName 
            if (Seq.length userList <= 500) then
              userList
              |> Seq.filter (fun l -> InfobarrierPolicy.IsUserInPolicy l "FW") 
              |> Seq.iter (
                  fun ln ->
                    let x = ADUtility.GetNameAndEmail ln 
                    let (email, name) = x.Value
                    SPUtility.CopyRoleAssignment li u.LoginName ln email name
                    (^a : (member Update : unit -> unit) li) //'
                  )
              SPUtility.RemoveRoleAssignment li u
          ) 
    

    There is also a series of helpful articles on the topic here.

    A few improvements I have done on the function above:

    • A series of Seq.filter could be collapsed to one Seq.filter , and = true is always a code smell.
    • List.ofSeq and List.iter could be replaced by Seq.iter. When you use Seq.iter, a lazy sequence will be evaluated anyway.
    • Do not write redundant type annotations such as li: 'a and u: SPUser. Since you use piping and have type annotation for input, the type checker would be able to infer correct types.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code that has one button that let's me choose an entry
I have a curl class, called Curl. Let's presume i have this code: $url
Let's say I have this piece of code: CGColorSpaceRef colorSpaceRGB = CGColorSpaceCreateDeviceRGB(); CGContextSetStrokeColorSpace(context, colorSpaceRGB);
So I have this piece of code, and let's assume I'm filling out a
As a beginner in Ocaml, I have this current working code: ... let ch_in
Let us say if I have a Perl module Resounces.pm with this code snippet
Let's have a look at this HTML code: <!DOCTYPE html> <html> <head> <title>Test</title> </head>
Let's say that I have a code like this: NSAutoreleasePool* pool=[[NSAutoreleasePool alloc]init]; for(unsigned int
Let's say that I have a block of code like this: keysPressed = new
I'm a beginner in C and Let's say I have a code like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.