Questions tagged [type-safety]

Use this tag for reviews of code where type safety is a concern, for example code involving type conversions or casting which may result in type errors at run-time.

15 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
12
votes
0answers
151 views

Encoding the problem domain of products and prices into the typesystem in F#

I'm trying to design a model for purchasing amounts of products in F#, following the ideas for designing for correctness (source). The idea is to use the type system to capture the different legal ...
10
votes
0answers
171 views

Multi-function memoizator and multi-type container

I'm trying to write a multiple functions memoizator, which I've talked about here. The main problem is creating a container containing different and heterogenous functions. I found a working solution,...
6
votes
0answers
188 views

Value semantic type eraser

I've been using std::unique_ptr for cases where I want to store a derived-type value with type erasure, and felt that unique_ptr being nullable was an undesirable ...
4
votes
0answers
69 views

Type & Thread-safe Logger Implementation

So I had previously posted this question and asked for some feedback regarding my (now) header-only logging system and figured it would be a good time to go back to the changes I made it and see if it ...
4
votes
0answers
83 views

Existential Types and IO

In my attempts to grasp Existential Types in Haskell I decided to implement an integer-based fixed-length vector data type. I'm using ghc 7.8.3. Specifically I wanted to write a program which asks ...
4
votes
0answers
3k views

Event system using callback functions in C++

I am learning C++ and have been trying to create an event system for use in a small game. This will be the mechanism by which game entities communicate. I would be eternally grateful if someone with ...
3
votes
0answers
131 views

Deque class using typing module

I wanted to make a class for type hinting that the result of a function is a homogenous deque. ...
2
votes
0answers
33 views

Range validator for multiple types

I have an existing overloaded set of functions that I cannot change and need to be tested: ...
2
votes
0answers
47 views

SI type safe unit calculations (revised)

This is the continuation of the questions raised in this thread I did include the improvements that were mentioned but still feel like, I do more copies than I need to. Also I am unsure about the ...
2
votes
0answers
45 views

Add 5 strong types to an object as properties

This is a small object that allows you to pass an obj and a property name using its helper functions to create a typed var that won't save a value to the property if it isn't the right type. This ...
2
votes
0answers
86 views

Delegating which module's functions to use based on user input

My main concern with this code is this problem - given that this program could generate a prompt string from Bash, Zsh, Fish, etc., I would like to make this code easily extendable so people can add ...
1
vote
0answers
65 views

Redux-like implementation in TypeScript

I need to write a custom reducer utility. It should take a dictionary of reducers and a publish subject to return a state, with a dispatch method to dispatch ...
1
vote
0answers
33 views

Type conversion between Node, Const_node, and their views

Each node is a location within a layer. A Location may be a pointer or an index. A Layer is a container. There are 4 types of ...
1
vote
0answers
60 views

Type System for Layers and Nodes

Overview The following is a type system of layers (A, B, C, ...
1
vote
0answers
51 views

Extensible XML parser

Context My aim is to write an RSS parser that can handle extensions in a generic and type-safe way. I already have a working RSS parser, the missing part is the extensions handling, which is the ...