Skip to content

Instantly share code, notes, and snippets.

View haskellcamargo's full-sized avatar
🪲
Everything is terrible

Marcelo Camargo haskellcamargo

🪲
Everything is terrible
View GitHub Profile
@marcoonroad
marcoonroad / rectypes.eff.ml
Last active September 26, 2020 16:29
Example of fold/unfold operations...
(* type-level recursion with fold/unfold *)
(* $ eff --effects -l rectypes.eff *)
(* there's an unique isomorphism between fold and unfold such that:
fold :: ...1 Unfix (...2 Fix (func) ...3) ...4 <=> ...1 Fix (func) ...4 :: unfold
where func = \fix -> ...2 fix ...3
so, conceptually:
@marcoonroad
marcoonroad / ext-type-sys.hs
Last active January 21, 2016 01:30
Extended type system...
{-# LANGUAGE GADTs, TypeFamilies, DataKinds, PolyKinds, KindSignatures, TypeOperators, RankNTypes, UndecidableInstances, AllowAmbiguousTypes, ExistentialQuantification, StandaloneDeriving, UnicodeSyntax, Arrows, MultiParamTypeClasses, ScopedTypeVariables #-}
data Kind = Self
| Kind `To` Kind
data SingleKind :: Kind -> * where
SingleSelf :: SingleKind Self
SingleTo :: SingleKind a -> SingleKind b -> SingleKind (a `To` b)
instance Show (SingleKind (k :: Kind)) where
{-# LANGUAGE DataKinds, KindSignatures, TypeOperators, GADTs, TypeFamilies, UndecidableInstances #-}
{- about invariants -}
data NatPos = One | Succ NatPos
data SingleNatPos :: NatPos -> * where
SingleOne :: SingleNatPos One
SingleSucc :: SingleNatPos natpos -> SingleNatPos (Succ natpos)
type family (m :: NatPos) |+| (n :: NatPos) :: NatPos where
@beci
beci / gcc 5 on ubuntu 14.04
Created October 15, 2015 07:18
use gcc 5.x on ubuntu 14.04
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
{-# LANGUAGE UnicodeSyntax #-}
module Proof where
import System.Console.ANSI
import Prelude.Unicode
import Control.Monad.Unicode
{-
Calculations and mathematical proofs of circular computations.
@author Marcelo Camargo
-}
#Creates a named function using the script block.
function Add-Function(
[string]$name,
[Parameter(ValueFromPipeline=$true)]
[ScriptBlock]$block)
{
New-Item -Path "Function:" -Name "global:$name" -Value $block
}
@pedropazello
pedropazello / haskell.md
Last active July 26, 2020 00:20
Haskell: Primeiros passos e bookmarks.
@polbins
polbins / README.md
Last active February 29, 2024 09:58
Simple RecyclerView Divider

Simple RecyclerView Divider

Simple Horizontal Divider Item Decoration for RecyclerView

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(
            getApplicationContext()
    	));

NOTE: Add item decoration prior to setting the adapter

@logicmason
logicmason / yc.js
Last active June 18, 2021 01:46
Y combinator in JavaScript and factorial function example (recursion with all anonymous functions)
var Y = function(proc) {
return (function(x) {
return proc(function(y) { return (x(x))(y);});
})(function(x) {
return proc(function(y) { return (x(x))(y);});
});
};
var factgen = function(fact) {
return function(n) {
@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active January 19, 2024 08:52
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;