#!/usr/local/bin/julia

# minimal working example to demostrate that one is
# unable to overwrite Base.show for Array{custom_type,1} when using REPL
#
# julia> versioninfo()
# Julia Version 0.4.0-dev+2895
# Commit a37025e* (2015-01-25 09:20 UTC)
#Platform Info:
#  System: Linux (x86_64-linux-gnu)
#  CPU: Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz
#  WORD_SIZE: 64
#  BLAS: libmkl_rt
#  LAPACK: libmkl_rt
#  LIBM: libimf
#  LLVM: libLLVM-3.3
#

module repl_test
    import Base.show
    export show

    type A
        value::Int64
    end

    show( io::IO, x::A ) = @printf(" A: %i\n", x.value )
    show( io::IO, x::Array{A,1} ) = @printf(" A: many values\n" )
end


x = repl_test.A( 5 )
show(x)  # as advertised
x        # same as above
# printout in  REPL
# A: 5
# A: many values

y = Array(repl_test.A, 10)
show(y)
# still works as expected
# julia> show(y)
# A: many values

###### like io::IO, x::Array{A,1} = ... didn't exist
y
# julia> y
# 10-element Array{repl_test.A,1}:
#  #undef
#  ... omitted
#  #undef

# The above code when evaluated in REPL uses built in Base.show for array and indirectly
# calls overwritten Base.show
# I find it very cumbersum and ugly when unable to pretty print large arrays of structs
# imported from other systems.

# Is there a better/working solution to use the REPL similarly to when interacting with GNU R?
