Skip to content

Instantly share code, notes, and snippets.

View fommil's full-sized avatar
😽
having a fantastic day not writing any scala

>>= fommil

😽
having a fantastic day not writing any scala
View GitHub Profile
@amiralies
amiralies / config.lua
Created October 8, 2022 02:48
Ensime TNG nvim lspconfig
local configs = require 'lspconfig.configs'
local lspconfig = require 'lspconfig'
-- Check if the config is already defined (useful when reloading this file)
if not configs.ensime then
configs.ensime = {
default_config = {
cmd = {
'java', '-jar', os.getenv("HOME") .. '/.cache/ensime/lib/ensime-lsp.jar'
},
@quelgar
quelgar / typed_errors.md
Last active January 16, 2024 09:36
Every Argument for Static Typing Applies to Typed Errors

Every Argument for Static Typing Applies to Typed Errors

Think of all the arguments you've heard as to why static typing is desirable — every single one of those arguments applies equally well to using types to represent error conditions.

An odd thing I’ve observed about the Scala community is how many of its members believe that a) a language with a sophisticated static type system is very valuable; and b) that using types for error handling is basically a waste of time. If static types are useful—and if you like Scala, presumably you think they are—then using them to represent error conditions is also useful.

Here's a little secret of functional programming: errors aren't some special thing that operate under a different set of rules to everything else. Yes, there are a set of common patterns we group under the loose heading "error handling", but fundamentally we're just dealing with more values. Values that can have types associated with them. There's absolutely no reason why the benefits of static ty

@travisbrown
travisbrown / cease-and-desist-de-goes.md
Created July 31, 2020 13:29
Cease and desist letter from John A. De Goes

Please see this response for more context.


Dear Mr. Brown:

We represent the legal interests of our client, Mr. John Arlen De Goes, Maryland, USA.

For several years now, you have repeatedly defamed our client on the internet. Your public blog https://meta.plasm.us/posts/2019/09/01/jdg-and-the-fp-community/ specifically targets our client with the goal to publicly vilify our client. This blog can be easily found with the help of search engines like Google by just searching for the name of our client. On this blog, amongst other false statements, you falsely allege the following about our client:

@CarstenKoenig
CarstenKoenig / ScottyScriptDemo.hs
Created September 25, 2017 15:42
Demonstration of getting a scotty server running as a script - needs stack
#!/usr/bin/env stack
-- stack --resolver lts-9.5 script --package scotty
{-# LANGUAGE OverloadedStrings #-}
import Web.Scotty
import Data.Monoid (mconcat)
main = scotty 3000 $ do

Code of Conduct

Communication

Times
  • All times will be communicated in a way that is unambiguous. This communication may be a local time, with a UTC offset specified.

For example:

Getting Started in Scala

This is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere…  I hope to present the information you need without assuming anything.

Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!

One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.

Getting the JVM

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@mandubian
mandubian / gist:0fd090c0f75a46346f5e7898eeac9e28
Last active September 15, 2017 15:11
Improving compile-time for structure based on implicits resolutions

Explaining Miles's Magic

Miles Sabin recently opened a pull request fixing the infamous SI-2712. First off, this is remarkable and, if merged, will make everyone's life enormously easier. This is a bug that a lot of people hit often without even realizing it, and they just assume that either they did something wrong or the compiler is broken in some weird way. It is especially common for users of scalaz or cats.

But that's not what I wanted to write about. What I want to write about is the exact semantics of Miles's fix, because it does impose some very specific assumptions about the way that type constructors work, and understanding those assumptions is the key to getting the most of it his fix.

For starters, here is the sort of thing that SI-2712 affects:

def foo[F[_], A](fa: F[A]): String = fa.toString
@raulraja
raulraja / SearchService.scala
Created January 26, 2016 23:25
An example of refactoring nested login in the Ensime Search Service with `XorT`
import cats.data.Xor, cats.syntax.xor._, cats.data.XorT
//Some type aliases for semantic purposes
type IndexedSymbols = Iterable[(FileObject, List[FqnSymbol])]
type IndexingError = (String, Throwable)
type ProcessResult[A] = XorT[Future, IndexingError, A]