Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Use unicode math glyphs instead of square brackets #12

Closed
ohir opened this issue Jun 15, 2018 · 2 comments
Closed

Use unicode math glyphs instead of square brackets #12

ohir opened this issue Jun 15, 2018 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@ohir
Copy link

ohir commented Jun 15, 2018

Square brackets cause too much of cognitive overload. Angle brackets are used everywhere but
are ugly. Though math angle brackets are both readable and lean (IMO).

Go from the inset uses unicode sources. Why not to use other characters for the "generic type" block?
Mac/Linux and vim users have no problem with adding anything under bracket keys (with alt or meta mod). On windows keys can be mapped within IDEs.

Examples with a few runes from the math unicode range follows:

// Eg. unicode     unicode name

// ⟨T⟩ 27e8 27e9   math angle brackets
// ∘T∘ 2218        ring op
// ∫T∫ 222b        integral
// ⟅T⟆ 27c5 27c6   bag left/right

/////////////////////////////////////
// with : ⟨T⟩
type BoxTstruct {
  v T
}

func (b BoxT⟩) Val() T {
  return b.v
}

func (b BoxT⟩) MapU⟩ (f func(T) U) BoxU⟩ {
  return BoxU⟩{
    v: f(b.v),
  }
}

x := Boxstring⟩{ v: "foo" }
x.Val()

y := Boxint⟩ { v: 42 }
z := y.Mapstring⟩(strconv.Itoa)

/////////////////////////////////////
// with : ∘T∘
type BoxTstruct {
  v T
}

func (b BoxT∘) Val() T {
  return b.v
}

func (b BoxT∘) MapU∘ (f func(T) U) BoxU∘ {
  return BoxU∘{
    v: f(b.v),
  }
}

x := Boxstring∘{ v: "foo" }
x.Val()

y := Boxint∘ { v: 42 }
z := y.Mapstring∘(strconv.Itoa)


/////////////////////////////////////
// with : ∫T∫
type BoxTstruct {
  v T
}

func (b BoxT∫) Val() T {
  return b.v
}

func (b BoxT∫) MapU∫ (f func(T) U) BoxU∫ {
  return BoxU∫{
    v: f(b.v),
  }
}

x := Boxstring∫{ v: "foo" }
x.Val()

y := Boxint∫ { v: 42 }
z := y.Mapstring∫(strconv.Itoa)

/////////////////////////////////////
// with : ⟅T⟆
type BoxTstruct {
  v T
}

func (b BoxT⟆) Val() T {
  return b.v
}

func (b BoxT⟆) MapU⟆ (f func(T) U) BoxU⟆ {
  return BoxU⟆{
    v: f(b.v),
  }
}

x := Boxstring⟆{ v: "foo" }
x.Val()

y := Boxint⟆ { v: 42 }
z := y.Mapstring⟆(strconv.Itoa)
@NullVoxPopuli
Copy link

NullVoxPopuli commented Jun 15, 2018

the math angle brackets look almost like parenthesis.

(T) vs ⟨T⟩ vs <T>

A picture, in case you have a weird font:
image

@albrow
Copy link
Owner

albrow commented Jun 15, 2018

Let's move all discussion about type parameter and type argument syntax to #10. Closing this as a duplicate.

@albrow albrow closed this as completed Jun 15, 2018
@albrow albrow added the duplicate This issue or pull request already exists label Jun 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants