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 5930443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:33:22+00:00 2026-05-22T14:33:22+00:00

I have a problem with types in the following code (some easy module functional

  • 0

I have a problem with types in the following code (some easy module functional graph implementation). It seems that types are living their own lives.

I have type t = NotaEdge | Edge of int*v*v implemented in module Edge, this type in module Graph becomes type edge = E.t. Everything seems fine to me, except fact i can’t pattern match on it, cause the constructor Edge is still undefined in module Graph.

Exactly in function suc when i try to match with Edge(l,n,m): #Error: Unbound constructor Edge

Hope someone can present it nicely, thx in advance 🙂

 module Vertex : Vertex with type label = int =

struct

  type t = NotaNode |  Node of int
  type label = int
  exception No of string

…

module Edge : Edge  with type label = int and type v = Vertex.t =
struct 

  type v = Vertex.t
  type t = NotaEdge | Edge of int*v*v
  type label = int      

  exception No of string

…

module Graph (E : Edge) (V : Vertex) : Graph with type vertex = V.t and type edge = E.t =
struct 

  type vertex = V.t
  type edge = E.t
  type t = E.t list* V.t list

  let empty = ([],[])

 let rec suc (x:edge list) (v1:vertex) =
     match x with 
         y::ys -> (match y with
   (*Error-->*)       Edge(l,n,m) -> if n == v1 then m::(suc ys v1) else suc ys v1  
                     | _ -> [])
       |[] -> []

  let succ (t1:t) (v1:vertex) = 
    match t1 with
        (x,_) -> suc x v1

…

  • 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-22T14:33:23+00:00Added an answer on May 22, 2026 at 2:33 pm

    Things are a bit messy here; Error is never defined, and what I presume to be a few typos. It would be much more helpful if you gave code that compiled. Par it down, but syntactically correct. I can only make conjectures on the limited information and common pitfalls.

    It would be very helpful to know the signatures to Vertex and Edge

    If in the signature Edge the type t is defined the same as in the implementation of Edge that you give, then you can match the variant with E.Edge and E.NotaEdge. If the type t is abstract (the only information in the signature is type t), then you wont (and reasonably should not) be able to access the implementation or pattern match in that way. In this case the implementation is hidden behind the signature. This is usually fine (and intended) when dealing with functors since you can implement the module in any way that is necessary and convenient.

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

Sidebar

Related Questions

Hi following code sample seems to have some problem or either it has to
I have some code that looks like the following. First I have some domain
I have problem in some JavaScript that I am writing where the Switch statement
I have the following code implementation of Breadth-First search. trait State{ def successors:Seq[State] def
I'm trying to do some refactoring of code, and have run into a problem.
I have some legacy code with linq2sql classes. DataContext class has following definition for
I have a problem downloading particular file types by WebClient. So there are no
Possible Duplicate: Java - Regex problem I have list of URLs of types: http://www.example.com/pk/etc
I have some problems with OpenCV s cvCanny(...) and the Image data types it
I have a problem with reflection. I need to find the type that instantiates

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.