Alex
Alex

Reputation: 7919

How to import a local module?

I have a local auxiliary module, List.Extensions, which I would like to import into my Main.elm module. It exists in the same directory. When I try to do this, I get an error telling me that :

I cannot find module 'List.Extensions'.

Module 'Main' is trying to import it.

The content of List.Extensions.elm is:

module List.Extensions exposing (..)

test = 1

The content of Main.elm is:

import List.Extensions

[...]

I can't find any resources or guides to setting up local modules, how do I do this?

Upvotes: 2

Views: 950

Answers (1)

Alex
Alex

Reputation: 7919

It looks like local elm modules have to be named according to the file system structure. So, List.Extensions.elm has to be renamed to Extensions.elm and moved to List\Extensions.elm. I could not find any documentation about this but anecdotally it seems to be the case. Posting in case someone else runs across the same problem.

Upvotes: 8

Related Questions