This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Monad<A> { | |
type Res<B>; | |
fn pure(item: A) -> Self; | |
fn bind<B, F: Fn(&A) -> Self::Res<B>>(&self, f: F) -> Self::Res<B>; | |
} | |
impl<A> Monad<A> for Option<A> { | |
type Res<B> = Option<B>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Functor<A> { | |
type Res<B>; | |
fn fmap<B, F: Fn(&A) -> B>(&self, f: F) -> Self::Res<B>; | |
} | |
impl<A> Functor<A> for Option<A> { | |
type Res<B> = Option<B>; | |
fn fmap<B, F: Fn(&A) -> B>(&self, f: F) -> Self::Res<B> { | |
match self { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; vrl-mode.el --- Major mode for Vector Remap Language code -*- lexical-binding: t; -*- | |
;; Version: 0.0.1 | |
;; Keywords: VRL major mode | |
;; Author: Stephen Wakely | |
;; Package-Requires: ((emacs "26.1")) | |
;; This file is not part of GNU Emacs. | |
;; This program is free software; you can redistribute it and/or modify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashMap; | |
use std::env; | |
// Alias some types | |
type Count = HashMap<String, usize>; | |
type ParseError = String; | |
/// Take a list of tuples of strings and counts and | |
/// convert them into a hash table. | |
fn make_count(tpls: Vec<(String, usize)>) -> Count { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Type level Peano numbers in PureScript. | |
module Main where | |
import Prelude hiding (zero,one,add) | |
import Effect (Effect) | |
import Effect.Console (log) | |
foreign import kind Peano |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyPrelude | |
( module Prelude | |
, (|>), (<|) | |
) where | |
import Prelude | |
infixr 0 apply as |> | |
infixl 1 applyFlipped as <| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# OPTIONS_GHC -fplugin=Polysemy.Plugin #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
-- | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | A variable | |
-- x.y[3].z[2][9] | |
variableParser :: Parser Var | |
variableParser = do | |
pos <- getSourcePos | |
var <- parseSimpleVar pos <?> "Simple var" | |
go var | |
where | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Code for calculating the levenstein distance between two strings | |
module Data.Levenstein (distance) where | |
import Prelude | |
import Data.Array as Array | |
import Data.Array ((!!)) | |
import Data.Function.Memoize (memoize2) | |
import Data.Maybe as Maybe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Lib | |
( someFunc | |
) where | |
import System.IO | |
import Data.Char | |
import Data.Text (Text) | |
import qualified Data.Text as T |
NewerOlder