On Fri, 13 Jul 2007 16:18:46 +0200, Andreas Rossberg wrote:

> If you define your own abstract types - e.g. via applying a
functor -
> then you can register simple printers for them with the inspector. For
> example,
> 
>   structure Set = MkRedBlackSet String
>   fun setToString s =
>       "{" ^ String.concatWith ", " (map (fn x => "\""^String.toString
> x^"\"") (Set.toList s)) ^ "}"
> 
>   Inspector.register setToString

I see, thanks, but how does it work internally ?
I mean, how does Inspector knows that it should call
function XyzToString for type XYZ ? 
Do we have runtime introspection to know the type of a value? 
It would make sense, because the REPL can print it, I just expected it to
be impossible.

I will look at the sources but I'm slightly afraid they're
completely over my head :)

 
<snip> 
> In a similar vein, you can register the same printer to be used by the
> REPL:
> 
>   > Print.register setToString
>   val it : unit = ()
>   > val s = Set.fromList ["a", "c", "b"]
>   val s : Set.set = {"a", "b", "c"}

very nice


>   >
> Hope this helps,

once again, yes, thank you.

_______________________________________________
alice-users mailing list
[email protected]
http://www.ps.uni-sb.de/mailman/listinfo/alice-users

Reply via email to