aripiprazole / ekko

📘 | Writing Haskell in Kotlin article's project
https://whik.devgabi.me
The Unlicense
7 stars 0 forks source link

create type class syntax #10

Open aripiprazole opened 2 years ago

aripiprazole commented 2 years ago

Create the type class, and constraint syntax:


class Monad m =
  pure : Ɐ a. a -> m a
  (>>=) : Ɐ a b. m a -> (a -> m b) -> m b 

And the constraint syntax:


instance Monad (List Int) = ...

using : List String
using = [1, 2, 3] >>= (+ 1)