Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Basetype module #66

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading