Skip to content

Instantly share code, notes, and snippets.

View vijayanant's full-sized avatar

Vijay Anant vijayanant

View GitHub Profile
@vijayanant
vijayanant / TraitSum.rs
Created March 1, 2025 11:02
Rust - Traits
trait Summable {
fn zero() -> Self;
fn add(&self, other: &Self) -> Self;
}
impl Summable for i32 {
fn zero() -> Self {
0
}
fn add(&self, other: &Self) -> Self {
@vijayanant
vijayanant / carncdr.py
Created June 4, 2021 15:47
Simple Python problem #1 --- pair, car, and cdr
# Problem Statement
# cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair.
# For example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4.
# Given the below implementation for cons( ), please implement car & cdr
def cons(a, b):
def pair(f):
return f(a, b)
return pair
@vijayanant
vijayanant / gadt1.hs
Created April 8, 2020 03:45
GADT Code Samples
data Point = Pt Int Int
data Expr a = Number Integer | Boolean Bool
@vijayanant
vijayanant / Git Branching and Releasing for Happy Developers.md
Last active July 29, 2019 14:22
Git Branching and Releasing for Happy Developers

Git Branching and Realeasing

AIM

To make below listed activites simple (from SCM point of view)

  • Adding new features
  • Fixing bugs
  • Preparing for release
  • Deploying to production
  • Applying hotfixes
  • Versioning
@vijayanant
vijayanant / TypeFamilies.hs
Created November 30, 2018 17:40
Type Families - WIP
{-# LANGUAGE TypeFamilies
, DataKinds
, PolyKinds
, TypeInType
, TypeOperators
, UndecidableInstances
, RankNTypes
#-}
@vijayanant
vijayanant / README.md
Created November 27, 2018 03:17 — forked from m-ammar/README.md
haskell-resources
@vijayanant
vijayanant / HigherRankedTypes.hs
Last active March 6, 2025 12:32
Rank N Types in Haskell
{-# LANGUAGE RankNTypes #-}
module RankN where
-- Rank 0:
-- add1 is momomorphic
add1 :: Int -> Int
add1 x = x + 1
-- Rank 1

Keybase proof

I hereby claim:

  • I am vijayanant on github.
  • I am vijayanant (https://keybase.io/vijayanant) on keybase.
  • I have a public key ASATAASxUzx1ZqEy4JGeIrlA1oyzEk6jSPdtXtZPglZs_Qo

To claim this, I am signing this object:

@vijayanant
vijayanant / Applicatives.hs
Last active January 17, 2020 13:54
Choose Wisely
-- 1 + 2
-- (+) 1 2
-- + (Just 1) (Just 2)
-- Monadic desugared
(Just 1) >>= (\x -> (Just 2) >>= \y -> return (x+y))
-- Monadic sugar