Skip to content

Commit

Permalink
Merge pull request #66 from JuliaReach/schillic/basetype
Browse files Browse the repository at this point in the history
Add Basetype module
  • Loading branch information
schillic authored May 2, 2024
2 parents 8511894 + fac6a42 commit be88e28
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ makedocs(; sitename="ReachabilityBase.jl",
"Subtypes" => "lib/Subtypes.md",
"Arrays" => "lib/Arrays.md",
"Timing" => "lib/Timing.md",
"CurrentPath" => "lib/CurrentPath.md"
"CurrentPath" => "lib/CurrentPath.md",
"Basetype" => "lib/Basetype.md"
#
],
"About" => "about.md"],
Expand Down
17 changes: 17 additions & 0 deletions docs/src/lib/Basetype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Basetype

This section of the manual describes the `Basetype` module.

```@contents
Pages = ["Basetype.md"]
Depth = 3
```

```@meta
CurrentModule = ReachabilityBase.Basetype
```

```@docs
Basetype
basetype
```
62 changes: 62 additions & 0 deletions src/Basetype/Basetype.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""
Basetype
This module provides the functionality to obtain the base type of a type or object.
"""
module Basetype

export basetype

"""
basetype(T::Type)
Return the base type of the given type (i.e., without type parameters).
### Input
- `T` -- type
### Output
The base type of `T`.
```jldoctest
julia> using ReachabilityBase.Basetype
julia> basetype(Float64)
Float64
julia> basetype(Rational{Int})
Rational
```
"""
basetype(T::Type) = Base.typename(T).wrapper

"""
basetype(x)
Return the base type of the given object (i.e., without type parameters).
### Input
- `x` -- object
### Output
The base type of `x`.
### Examples
```jldoctest
julia> using ReachabilityBase.Basetype
julia> basetype(1.0)
Float64
julia> basetype(1//1)
Rational
```
"""
basetype(x) = basetype(typeof(x))

end # module
1 change: 1 addition & 0 deletions src/ReachabilityBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ include("Subtypes/Subtypes.jl")
include("Arrays/Arrays.jl")
include("Timing/Timing.jl")
include("CurrentPath/CurrentPath.jl")
include("Basetype/Basetype.jl")

end # module

0 comments on commit be88e28

Please sign in to comment.