@@ -644,7 +644,9 @@ defmodule IEx.Introspection do
644644 types_not_found ( inspect ( module ) )
645645
646646 { :ok , types } ->
647- Enum . each ( types , & ( & 1 |> format_type ( ) |> IO . puts ( ) ) )
647+ types
648+ |> Enum . sort_by ( fn { _ , { name , _ , args } } -> { name , length ( args ) } end )
649+ |> Enum . each ( & ( & 1 |> format_type ( ) |> IO . puts ( ) ) )
648650 end
649651
650652 dont_display_result ( )
@@ -656,15 +658,19 @@ defmodule IEx.Introspection do
656658 no_beam ( module )
657659
658660 { :ok , types } ->
659- printed =
660- for { kind , { ^ type , _ , args } } = typespec <- types ,
661- kind != :typep do
662- type_doc ( module , type , length ( args ) , typespec )
663- |> print_typespec ( )
664- end
665-
666- if printed == [ ] do
667- types_not_found_or_private ( "#{ inspect ( module ) } .#{ type } " )
661+ types
662+ |> Enum . filter ( & match? ( { kind , { ^ type , _ , _ } } when kind in [ :type , :opaque ] , & 1 ) )
663+ |> Enum . sort_by ( fn { _ , { name , _ , args } } -> { name , length ( args ) } end )
664+ |> case do
665+ [ ] ->
666+ types_not_found_or_private ( "#{ inspect ( module ) } .#{ type } " )
667+
668+ types ->
669+ Enum . map ( types , fn { _ , { _ , _ , args } } = typespec ->
670+ module
671+ |> type_doc ( type , length ( args ) , typespec )
672+ |> print_typespec ( )
673+ end )
668674 end
669675 end
670676
@@ -677,16 +683,21 @@ defmodule IEx.Introspection do
677683 no_beam ( module )
678684
679685 { :ok , types } ->
680- printed =
681- for { kind , { ^ type , _ , args } } = typespec <- types ,
682- kind != :typep ,
683- length ( args ) == arity do
684- type_doc ( module , type , arity , typespec )
685- |> print_typespec ( )
686- end
686+ types
687+ |> Enum . find (
688+ & match? (
689+ { kind , { ^ type , _ , args } } when kind in [ :type , :opaque ] and length ( args ) == arity ,
690+ & 1
691+ )
692+ )
693+ |> case do
694+ nil ->
695+ types_not_found_or_private ( "#{ inspect ( module ) } .#{ type } " )
687696
688- if printed == [ ] do
689- types_not_found_or_private ( "#{ inspect ( module ) } .#{ type } " )
697+ typespec ->
698+ module
699+ |> type_doc ( type , arity , typespec )
700+ |> print_typespec ( )
690701 end
691702 end
692703
0 commit comments