Skip to content

Commit

Permalink
Merge Feature/4 create card typetemplate (#23)
Browse files Browse the repository at this point in the history
* Add next() for platform inconsistency

* the Android cursor implementation does not prime the cursor to the first row of the returned data set

* Fix LadyBug default toolchain using JDK 21

* Add code note

* remove top app bar colors

* Ignore db file

* Remove unused naive Graph type

* Move empty Module

* Create system types

* Create simple Record type

* Mark all types except Int as experimental
  • Loading branch information
TSampley authored Oct 3, 2024
1 parent 7726b4e commit dfdf81c
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ captures
local.properties
xcuserdata

## Test Data
/ontology.db

## Release Information
/release.keystore
/app-android/debug/app-android-debug.aab
Expand Down
4 changes: 4 additions & 0 deletions app-desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ plugins {
alias(libs.plugins.compose.compiler)
}

kotlin {
jvmToolchain(17)
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand Down
7 changes: 0 additions & 7 deletions app-shared/src/commonMain/kotlin/CommonSenseApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ fun CommonSenseApp(
modifier = modifier,
topBar = {
CenterAlignedTopAppBar(
// colors = TopAppBarColors(
// containerColor =
// navigationIconContentColor =
// titleContentColor =
// actionIconContentColor =
// scrolledContainerColor =
// ),
navigationIcon = {
val stack = navController.backList.collectAsState()
if (stack.value.isNotEmpty()) {
Expand Down
28 changes: 0 additions & 28 deletions core/entities/src/commonMain/kotlin/Graph.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.pointyware.commonsense.core.entities

/**
* A Field is a part of a Record that defines a property of a Concept.
*/
data class Field(
val name: String,
val type: Type
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.pointyware.commonsense.core.entities

/**
* A form of Schema that is used to define the structure of a Concept.
*
* Each Concept belongs to a Class and has a set of Properties.
*/
data class Record(
val title: String,
val properties: Set<Field> = emptySet()
): Type {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
package org.pointyware.commonsense.core.entities

@RequiresOptIn(
message = "This API is experimental and may change in the future.",
level = RequiresOptIn.Level.WARNING
)
annotation class ExperimentalType

/**
* Describes the range of types that values can take on in the Common Sense system.
*
* Theoretical types conform to a type-hierarchy that is based on set membership.
*
* [Type.Int] is the only non-experimental type.
*/
sealed interface Type {
// region Theoretical Types

/**
* A number is an object used for counting, measuring, or labeling.
*
* [Number definitions](https://www.oed.com/dictionary/number_n)
*/
@ExperimentalType
interface Number: Type {

}

/**
* A complex number is a value composed of a real part and an imaginary part.
*/
@ExperimentalType
interface Complex: Number {

}

/**
* An imaginary number is a value that can be represented as a real number multiplied by the square root of -1.
*/
@ExperimentalType
interface Imaginary: Complex {

}

/**
* A real number is a value that can be represented on a number line.
*/
@ExperimentalType
interface Real: Complex {

}

@ExperimentalType
interface Natural: Real {

}

@ExperimentalType
interface Integer: Natural {

}

/**
* A rational number is a value that can be represented as a fraction of two integers.
*/
@ExperimentalType
interface Rational: Real {

}

/**
* An irrational number is a value that cannot be represented as a fraction of two integers.
*/
@ExperimentalType
interface Irrational: Real {

}

/**
* A transcendental number is a value that cannot be represented as a fraction of two integers.
*/
@ExperimentalType
interface Transcendental: Real {

}

// endregion

// region Computing Types

/**
* A singular value that represents the absence of any other value. Derived from the Latin
* word "nullus" meaning "none", associated with the concept of zero<sup>(1)</sup>.
* When used in combination with other types, it represents the absence of a value of that
* type. When used in combination with numbers, it - somewhat confusingly - does not represent zero.
*
* <sup>(1)</sup> - [null etymology](https://www.etymonline.com/word/null)
*/
@ExperimentalType
data object Null: Type

/**
* A boolean is a value that can be either true or false.
*/
@ExperimentalType
data object Boolean: Type

/**
* An integer is a value that can be represented as a whole number.
*/
data object Int: Type // Add min, max constraints or define as further type?

/**
* A floating point number is composed of a sign bit, mantissa, and an exponent.
*/
@ExperimentalType
data object Float: Type // Add min, max constraints or define as further type?

// Collections
/**
* A collection is a group of objects that are treated as a single entity.
*/
@ExperimentalType
data object Collection: Type

// Homogenous Collections
/**
* A sequence is an ordered collection of objects.
*/
@ExperimentalType
data object Sequence: Type

/**
* An array is a fixed-size collection of objects.
*/
@ExperimentalType
data object Array: Type // Add size min, max constraints or define as further type?

/**
* A string is a special case sequence of characters.
*/
@ExperimentalType
data object String: Type // Add pattern constraints or define as further type?

/**
* A set is collection of unique objects.
*/
@ExperimentalType
data object Set: Type

/**
* A bag is a special case of a set where each element can appear more than once.
*/
@ExperimentalType
data object Bag: Type

/**
* A map is a special case of a set where each element is a key-value pair.
*/
@ExperimentalType
data object Map: Type

// Heterogeneous Collections

/**
* An object is a collection of properties, similar to key-value pairs, with associated
* behaviors that can be invoked.
*
* In the Common Sense system, an object is a collection of properties that are defined by a
* type template.
*
* - See concepts: Struct, Record, Class, Object vs Instance
* @see Record
*/
@ExperimentalType
data object Object: Type

/**
* An interface is a collection of properties that define a contract for objects that implement
* the interface.
*/
@ExperimentalType
data object Interface: Type

// endregion
}
5 changes: 4 additions & 1 deletion core/local/src/commonMain/kotlin/db/SqlDriverExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ var SqlDriver.version: Long
get() = executeQuery(
identifier = null,
sql = "PRAGMA user_version;",
mapper = { query -> QueryResult.Value(query.getLong(0) ?: 0L) },
mapper = { query ->
query.next() // Android Driver does not prime the cursor
QueryResult.Value(query.getLong(0) ?: 0L)
},
parameters = 0,
binders = null,
).value
Expand Down

0 comments on commit dfdf81c

Please sign in to comment.