0
votes

Since there's nothing about this on google, I opened this issue.

I'm trying to compile this code:

module Random: Mirage_random.S = struct 
  include Mirage_random_stdlib
end

module Ipv4: Static_ipv4.Make(Random, Clock, Ethernet, Arp) = struct
  include Static_ipv4
end

but I get this:

root@66f08fd7c55b:/workspaces/ocaml_env/mirage-tcpip/examples/raw_ip_tcp_example# dune build raw_ip_tcp_example.exe
Entering directory '/workspaces/ocaml_env/mirage-tcpip'
File "examples/raw_ip_tcp_example/raw_ip_tcp_example.ml", line 44, characters 36-37:
44 | module Ipv4: Static_ipv4.Make(Random, Clock, Ethern
                                         ^
Error: Syntax error: module path expected.

You can see the static_ipv4 file here https://github.com/mirage/mirage-tcpip/blob/master/src/ipv4/static_ipv4.mli#L17

I don't have any idea of why this error happens. I didn't include Clock, Ethernet, Arp because the error is already on Random. You can see the random signature here: https://github.com/mirage/mirage-random/blob/master/src/mirage_random.ml and the implementation I'm including here https://github.com/mirage/mirage-random-stdlib

2

2 Answers

0
votes

I don't know about Mirage at all, but conventionally Make is a functor. I.e., it maps modules to modules. But you have the call in the syntactic position of a module type.

I would expect something more like this:

module Ipv4 = Static_ipv4.Make(. . .)

My apologies if this isn't helpful.

0
votes

First, you have a syntax error, functor application should be written:

Static_ipv4.Make(Random)(Clock)(Ethernet)(Arp)

Then you have a kind error: Static_ipv4.Make(Random)(Clock)(Ethernet)(Arp) is a module expression, not a module type. Moreover, it is not clear if you even need a signature constraint. Simply writing

module Ipv4 = struct
  include Static_ipv4
  let more = 0
end

works if you wanted to make an extended version of the Static_ipv4 module.

But maybe, you wanted to add few functions to the functor result? In this case, you can use:

module Ipv4 = struct
  include Static_ipv4.Make(Random)(Clock)(Ethernet)(Arp)
  let an_new_and_shiny_function = ()
end

If you really want to enforce that the type is the same, you need to reuse the signature of the functor result:

module Ipv4: sig
  include Mirage_protocols.IP with type ipaddr = Ipaddr.V4.t
  val connect : ip:(Ipaddr.V4.Prefix.t * Ipaddr.V4.t) -> ?gateway:Ipaddr.V4.t ->
  end
 = struct
  include Static_ipv4.Make(Random)(Clock)(Ethernet)(Arp)
  let an_new_and_shiny_function.
end