@@ -644,7 +644,9 @@ defmodule IEx.Introspection do
644
644
types_not_found ( inspect ( module ) )
645
645
646
646
{ :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 ( ) ) )
648
650
end
649
651
650
652
dont_display_result ( )
@@ -656,15 +658,19 @@ defmodule IEx.Introspection do
656
658
no_beam ( module )
657
659
658
660
{ :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 )
668
674
end
669
675
end
670
676
@@ -677,16 +683,21 @@ defmodule IEx.Introspection do
677
683
no_beam ( module )
678
684
679
685
{ :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 } " )
687
696
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 ( )
690
701
end
691
702
end
692
703
0 commit comments