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

  • Home
  • SEARCH
  • 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 6925297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:46:17+00:00 2026-05-27T10:46:17+00:00

Here is my problem… I don’t understand why this isn’t working for me :)

  • 0

Here is my problem… I don’t understand why this isn’t working for me 🙂

To be more specific I have a get files function (not the problem but feedback is welcome):

type DirectoryOptions = Directory of string * Option<SearchOption>

type SearchOptions =
    | SearchSubDirectories
    | SearchCurrentDirectory

let WithExtensionIn extlist filename =
    let fileext = Path.GetExtension filename
    extlist |> Seq.exists (fun e -> e = fileext)

let GetFiles dir extlist =
    match dir with
        | Some diroptions ->
            let directoryname, suboptions = diroptions
            match suboptions with
                | Some SearchSubDirectories | None ->
                    Directory.GetFiles(directoryname, "*.*", SearchOption.AllDirectories)
                    |> Seq.filter (WithExtensionIn extlist)
                | Some SearchCurrentDirectory ->
                    Directory.GetFiles(directoryname, "*.*", SearchOption.TopDirectoryOnly)
                    |> Seq.filter (WithExtensionIn extlist)
        | None ->
            Directory.GetFiles(Directory.GetCurrentDirectory(), "*.*", SearchOption.AllDirectories)
                    |> Seq.filter (WithExtensionIn extlist)

I want to compose this into a Get duplicate files function. I may not be able to but I am trying to get my head into the functional mindset. My current attempt, which based on my understanding should work, isn’t working. This means that my understanding is wrong and I would like some help/clarification on how to solve this. My understanding is that in function composition the inner most function can have n input parameters but only one output and the remaining functions that wrap it can only have one in and one out. I’m not entirely sure how the first function is interpreted (might be a bad word to use) in the context of composition in F# because there is no distinct input/output. I believe this is the direct affect of currying.

Here is my current attempt:

let GetDuplicateFiles =
    let LengthAndExtension file =
        //this is faked for simplicity
        (12, ".htm")

    let GroupSizeGreaterThanOne group =
        let _, values = group
        Seq.length values > 1

    let content file =
        //again faked
        ()

    let groups items =
        snd items

    GetFiles
    >> Seq.groupBy LengthAndExtension
    >> Seq.filter GroupSizeGreaterThanOne
    >> Seq.collect groups
    >> Seq.groupBy content
    >> Seq.filter GroupSizeGreaterThanOne
    >> Seq.collect groups

This gives me a compile error on Seq.groupBy LengthAndExtension
the error is The type ”b -> seq’ is not compatible with the type ‘seq<‘a>’

Any thoughts/feedback is welcome. I think I’m looking for an ah ha moment if you know what I mean

  • 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-05-27T10:46:17+00:00Added an answer on May 27, 2026 at 10:46 am

    Forward-composition (>>) creates a new function, passing the output of the first as input to the second.

    The signature reveals the problem: ( >> ) : ('T1 -> 'T2) -> ('T2 -> 'T3) -> 'T1 -> 'T3

    It accepts two functions each taking a single argument. But GetFiles takes two args. A quick solution is to change GetFiles to take a tuple: let GetFiles (dir, extlist) = ....

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
I've got some problem with my function and don't know how to solve this
I have a problem here with the php function substr Let's say I have
I have a problem here. My Zend_Forms do not render in view script. Via
I've got a problem here with an MSI deployment that I'm working on (using
I'm having a strange problem here... I have an ASP.NET 3.5 application that has
I have an interesting problem here I've been trying to solve for the last
I'm trying to solve the problem here but I don't know why my code
Now here's a fun problem. I have an object array as the following: objRequests
Well the problem here is that if you have one DataTemplate for a type

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.