Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Implementations for Basic Operations #18

Closed
cyberixae opened this issue Jan 4, 2020 · 4 comments
Closed

Implementations for Basic Operations #18

cyberixae opened this issue Jan 4, 2020 · 4 comments
Labels
wontfix This will not be worked on

Comments

@cyberixae
Copy link

cyberixae commented Jan 4, 2020

Is there a specific reason why the package doesn't provide implementations for basic operations? Are there any plans for adding them in the future? I ended up writing some implementations for these types since I needed to work with tuples. Perhaps the types could be contributed to fp-ts Tuple module if they had an implementation? See gcanti/fp-ts#1074

@KSXGitHub
Copy link
Member

What do you mean by "Basic Operation"?

@cyberixae
Copy link
Author

cyberixae commented Jan 4, 2020

I mean the package has a type Concat but it does not provide a function concat to perform the concatenation according to that type. Maybe there are several different ways to do concatenation but it would be nice to have the straight forward implementation out of the box. Because that lets you avoid type casts in your code.

@cyberixae
Copy link
Author

Here is an example implementation for the constructor function concat that constructs a Concat.

import { Concat } from 'typescript-tuple';

// This should be available in the library

type Tuple = Array<any>;
export const concat = <A extends Tuple, B extends Tuple>(a: A, b: B): Concat<A, B> => (a.concat(b) as unknown) as Concat<A, B>;

// To let you do this

type Foo123 = ['foo', 123];
type Bar456 = ['bar', 456];
const foo123: Foo123 = ['foo', 123];
const bar456: Bar456 = ['bar', 456];

const foo123bar456: Concat<Foo123, Bar456> = concat(foo123, bar456);`

@KSXGitHub
Copy link
Member

I see. I only intended to provide type generics when I create this library. I am not sure if runtime functions belong here.

@KSXGitHub KSXGitHub added the wontfix This will not be worked on label Aug 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants