Skip to content

Instantly share code, notes, and snippets.

View juanbono's full-sized avatar
:shipit:

Juan Bono juanbono

:shipit:
View GitHub Profile
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Foldable (for_)
import Data.Traversable (for)
import Control.Monad.IO.Class
-- build-depends: base, haskeline, optparse-applicative
-- -- for example parser
@juanbono
juanbono / monads.ml
Created December 11, 2017 03:43 — forked from lindig/monads.ml
module type Monad = sig
type 'a t
val return: 'a -> 'a t
val bind: 'a t -> ('a -> 'b t) -> 'b t
end
@juanbono
juanbono / existential_types_haskell.md
Created November 29, 2017 18:12 — forked from CMCDragonkai/existential_types_haskell.md
Existential Types in Haskell

Existential Types in Haskell

I had always been confused by Haskell's implementation of existential types. Until now!

Existential types is the algebraic data type (ADT) equivalent to OOP's data encapsulation. It's a way of hiding a type within a type. Hiding it in such a way that any consumer of the data type won't have any knowledge on the internal property

@juanbono
juanbono / dht11.txt
Created October 3, 2017 04:44
Utilizar DHT11 en mi RPI (sensor de humedad y temperatura)
# Para utilizar el dht11 penseé inicialmente que era necesario WiringPi (no se mucho del tema jajaja).
# Pero tras buscar un poco vi que adafruit tiene una libreria propia (con bindings en Python) y tambien
# existe otra hecha por abyz.co.uk, que se llama pigpio:
http://abyz.co.uk/rpi/pigpio/examples.html#C code
# Aca hay un enlace a SO que esta muy completo:
https://raspberrypi.stackexchange.com/questions/54968/not-able-to-get-sensor-readings-on-am2302
# Para saber como conectar las cosas, busque un video en youtube, como estos:
https://www.youtube.com/watch?v=IHTnU1T8ETk
#!/usr/bin/env stack
{- stack script
--resolver lts-9.1
--package turtle
--package foldl
--package system-filepath
--package bytestring
--package containers
-}
-- script used to mirror Hackage: https://github.com/AleXoundOS/haskell-stack-mirror-script/issues
@juanbono
juanbono / check-files.hs
Last active August 30, 2017 12:40
Haskell script that checks the number of files in a specified directory.
#!/usr/bin/env stack
{- stack script
--resolver lts-9.1
--package turtle
--package foldl
--package system-filepath
--package bytestring
--package text
--package containers
-}
@juanbono
juanbono / trolling_haskell
Created May 1, 2017 07:29 — forked from quchen/trolling_haskell
Trolling #haskell
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now

Refactoring with type classes and optics

Often when writing programs and functions, one starts off with concrete types that solve the problem at hand. At some later time, due to emerging requirements or observed patterns, or just to improve code readability and reusability, we refactor to make our code more polymorphic. The importance of not breaking your API typically ranges from nice to have (e.g. minimises rework but not essential) to paramount (e.g. in a popular, foundational library).

@juanbono
juanbono / avl.ml
Created January 10, 2017 19:30 — forked from matthieubulte/avl.ml
(* Good morning everyone, I'm currently learning ocaml for one of my CS class and needed to implement
an avl tree using ocaml. I thought that it would be interesting to go a step further and try
to verify the balance property of the avl tree using the type system. Here's the resulting code
annotated for people new to the ideas of type level programming :)
*)
(* the property we are going to try to verify is that at each node of our tree, the height difference between
the left and the right sub-trees is at most of 1. *)