Skip to content

Instantly share code, notes, and snippets.

Take-home functional programming interview

This document is licensed CC0.

These are some questions to give a sense of what you know about FP. This is more of a gauge of what you know, it's not necessarily expected that a single person will breeze through all questions. For each question, give your answer if you know it, say how long it took you, and say whether it was 'trivial', 'easy', 'medium', 'hard', or 'I don't know'. Give your answers in Haskell for the questions that involve code.

Please be honest, as the interviewer may do some spot checking with similar questions. It's not going to look good if you report a question as being 'trivial' but a similar question completely stumps you.

Here's a bit more guidance on how to use these labels:

- job: homebrew_template
dependsOn: multi_build
steps:
- task: DownloadBuildArtifacts@0
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/download-build-artifacts
inputs:
buildType: current
downloadType: specific
- script: |
osxhash=`shasum -a 256 $osxpkg | cut -d " " -f 1`
.> pull https://github.com/unisonweb/base_v2:.trunk .base

  Here's what's changed in .base after the merge:
  
  Added definitions:
  
    1.    unique type ANSI.Color
    2.    ability Abort (+2 metadata)
    3.    builtin type Any
2021-05-12T01:43:07.8532430Z ##[section]Starting: Request a runner to run this job
2021-05-12T01:43:08.0378711Z Can't find any online and idle self-hosted runner in current repository that matches the required labels: 'ubuntu-18.04'
2021-05-12T01:43:08.0378831Z Can't find any online and idle self-hosted runner in current repository's account/organization that matches the required labels: 'ubuntu-18.04'
2021-05-12T01:43:08.0379037Z Found online and idle hosted runner in current repository's account/organization that matches the required labels: 'ubuntu-18.04'
2021-05-12T01:43:08.1876815Z ##[section]Finishing: Request a runner to run this job
2021-05-12T01:43:16.7080880Z Current runner version: '2.278.0'
2021-05-12T01:43:16.7108834Z ##[group]Operating System
2021-05-12T01:43:16.7109807Z Ubuntu
2021-05-12T01:43:16.7110333Z 18.04.5
2021-05-12T01:43:16.7110775Z LTS
@aryairani
aryairani / gist:3d80578fda7996908f6d5834a5e4288e
Created April 11, 2021 05:17
The output from converting a codebase that includes unisonweb/base
This file has been truncated, but you can view the full file.
arya@jrrr unison % stack exec unison -- -codebase c --old-codebase init
Initializing a new codebase in: /Users/arya/unison/c
arya@jrrr unison % stack exec unison -- -codebase c --old-codebase
I've started a codebase API server at
http://127.0.0.1:54494?eeMzm4cguksvi%2BbS3XADleeMUOmLTD64
2020-06-01 12:00:14.741795 [ThreadId 5] -
haskell-lsp:Starting up server ...
2020-06-01 12:00:14.750066 [ThreadId 5] - ---> {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":28616,"rootPath":"/Users/arya/unison/master/","rootUri":"file:///Users/arya/unison/master/","workspaceFolders":[],"capabilities":{"workspace":{"applyEdit":true,"configuration":false,"workspaceEdit":{"documentChanges":true},"workspaceFolders":false,"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false},"executeCommand":{"dynamicRegistration":false}},"textDocument":{"synchronization":{"dynamicRegistration":false,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":false,"completionItem":{"snippetSupport":true,"commitCharactersSupport":false},"contextSupport":true},"hover":{"dynamicRegistration":false},"signatureHelp":{"dynamicRegistration":false},"references":{"dynamicRegistration":false
@aryairani
aryairani / gist:a360646c8d8705f9d3e939f62b9119c2
Last active May 22, 2020 16:08
grep -v 'SQL\|key rotation\|keepalive'
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Signal/1.33.4 Chrome/80.0.3987.163 Electron/8.2.1 Safari/537.36 node/12.13.0 env/production
INFO 2020-05-21T16:57:39.374Z app ready
INFO 2020-05-21T16:57:39.375Z starting version 1.33.4
INFO 2020-05-21T16:57:39.399Z updateSchema:
Current user_version: 20;
Most recent db schema: 20;
(deprecated) schema_version: 77;
INFO 2020-05-21T16:57:39.778Z Initializing BrowserWindow config: {"show":true,"width":832,"height":550,"minWidth":680,"minHeight":550,"autoHideMenuBar":false,"backgroundColor":"#3a76f0","webPreferences":{"nodeIntegration":false,"nodeIntegrationInWorker":false,"contextIsolation":false,"preload":"/Applications/Signal.app/Contents/Resources/app.asar/preload.js","nativeWindowOpen":true,"spellcheck":true},"icon":"/Applications/Signal.app/Contents/Resources/app.asar/build/icons/png/512x512.png","x":0,"y":23}
INFO 2020-05-21T16:57:39.978Z spellcheck: user locale: en-US
@aryairani
aryairani / benchmarks.md
Created May 17, 2020 22:49
confusing benchmarks

With -O2 accidentally

changes to SlimCopy..hs MB*s
no change 329.2
State.Strict 230.9
Writer.Strict 176.3
Writer.Strict + State.Strict 176.5
Index 386.9
Index + Map.Strict 321.7
Index + State.Strict 230.6
✔ ~/unison/pt/1408-numbered [pt/1408-numbered|…770]
12:57 $ cabal v2-run unison
Up to date
_____ _
| | |___|_|___ ___ ___
| | | | |_ -| . | |
|_____|_|_|_|___|___|_|_|
Welcome to Unison!
@aryairani
aryairani / log.txt
Created April 14, 2020 20:53
playing with git 1
ndnd:tmp arya$ git init --bare repo.git
Initialized empty Git repository in /private/tmp/repo.git/
ndnd:tmp arya$ git clone repo.git 1
Cloning into '1'...
warning: You appear to have cloned an empty repository.
done.
ndnd:tmp arya$ git clone repo.git 2
Cloning into '2'...
warning: You appear to have cloned an empty repository.
done.