Skip to content

Instantly share code, notes, and snippets.

@ck3g
ck3g / example.ex
Created February 14, 2019 16:14
How to read from STDIN in Elixir (for HackerRank)
defmodule Solution do
#Enter your code here. Read input from STDIN. Print output to STDOUT
end
array_length = IO.read(:stdio, :line)
array = IO.read(:stdio, :line)
array_length
|> String.trim
|> String.to_integer
@dadhi
dadhi / FreeIOMonad.cs
Last active October 9, 2022 03:05
Example of Free IO monad in pure C# with separated re-usable monad implementation
/*
Modified from the original https://gist.github.com/louthy/524fbe8965d3a2aae1b576cdd8e971e4
- removed dependency on [language-ext](https://github.com/louthy/language-ext)
- separated monadic boilerplate, so you may concentrate on describing the operations and interpretation of the program
- removed `IO<A>.Faulted` to simplify the examples. It can be added back in straightforward manner.
Useful links:
- [John DeGoes: Beyond Free Monads - λC Winter Retreat 2017](https://www.youtube.com/watch?v=A-lmrvsUi2Y)
- [Free and tagless compared - how not to commit to a monad too early](https://softwaremill.com/free-tagless-compared-how-not-to-commit-to-monad-too-early)