Module System.Random issue

57 views
Skip to first unread message

Humbert

unread,
May 13, 2021, 10:37:00 AM5/13/21
to Idris Programming Language
Hi,

I'm trying to use rndSelect in module System.Random. I did import System.Random in my code and:

choose : List (String, Maybe m) -> IO (String, Maybe m)
choose enabledTs = rndSelect enabledTs

I get this message:
Undefined name Data.List.NonEmpty at:
      choose enabledTs = rndSelect enabledTs
                                                 ^^^^^^^^^^^^^^^^^^^
Any idea on what am I doing wrong?
Thanks in advance,

Humbert.

Denis Buzdalov

unread,
May 13, 2021, 5:29:02 PM5/13/21
to idris...@googlegroups.com
Well, the reason for this is a known issue of the compile.

A function `rndSelect` from module `System.Random` uses a type `NonEmpty` from the module `Data.List` in its signature. Since `Data.List` is imported in `System.Random`, `NonEmpty` can be freely used inside of it. But `System.Random` does not import `Data.List` publicly, thus is does not reexport definitions from `Data.List` for those who are importing the `System.Random` module.

I.e. definitions are not reexported from imported modules even if they are used in the public interface of a module.

So, for now, to solve the problem for your module, you can just add `import Data.List` to your module. An alternative solution would be a PR replacing `import Data.List` to `import public Data.List` in `System.Random`.

Humbert Fiorino

unread,
May 14, 2021, 12:51:42 PM5/14/21
to idris...@googlegroups.com
Thanks a lot! 

--
You received this message because you are subscribed to a topic in the Google Groups "Idris Programming Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/idris-lang/6_ySND4doGc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to idris-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idris-lang/CAP77jwUwRT19uquqT78kkoC01GUdrWt%3DdiM9PnftmKUQSmi9UQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages