#Unqualified type imports not working?

1 messages ยท Page 1 of 1 (latest)

topaz anchor
#

I tried doing some modularization on my project by extracting some functions/types i would be using multiple times. But now that I'm importing type Node defined in util_generators.gleam file using the unqualified import like showed in Langauge Tour it can't seem to recognize it and i don't want to add the qualificator? Am I doing something wrong?

wispy thicket
#

If you have this code:

pub type Node {
  Node(...)
}

Then you import the type Node with .{type Node} and you import the constructor Node with .{Node}. If you want both type and constructor, you can do .{type Node, Node} in your import

polar osprey
#

Hello! Could you share the definition of Node? I have a hunch of what might be wrong but it's always best to make sure ๐Ÿ˜

topaz anchor
topaz anchor
polar osprey
#

Ah I see, so here you're defining a type called Node with a single constructor with the same name as the type

#

By doing import util_generators.{type Node} you're just importing the type and not the constructor

#

Oh greenfork beat me to it ๐Ÿ˜†

wispy thicket
#

Sorry ๐Ÿ˜„

topaz anchor
#

Thanks to you both for help anyways ๐Ÿ™‚

#

Also, one more quick question if you are still here. Is there a way to read user input from command line after running the project? Not how it's done with argv package

polar osprey