View THBinary.hs
{-# OPTIONS_GHC -Wall -Wno-orphans #-}
module THBinary where
import Data.Binary
import Language.Haskell.TH.Syntax
instance Binary OccName
instance Binary ModName
View takehome-fp-interview.markdown

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:

View fact.c
/* GHC_PACKAGES base ghc-prim integer-simple
#include "Stg.h"
const char Main_zdtrModule4_bytes[] = "main";
StgWord Main_zdtrModule3_closure[]__attribute__((aligned(8)))= {
(W_)&ghczmprim_GHCziTypes_TrNameS_con_info, (W_)&Main_zdtrModule4_bytes
View fact.cmm-raw.txt
[ []
, [ CmmData
(Section CString (CLabel "$trModule4_bytes"))
(CLabel "$trModule4_bytes") [ CmmString [ 109 , 97 , 105 , 110 ] ])
, [ CmmData
(Section Data (CLabel "$trModule3_closure"))
(CLabel "$trModule3_closure")
View frontend.txt
Glasgow Haskell Compiler, Version 8.3.20171108, stage 2 booted by GHC version 8.0.2
Using binary package database: /opt/ghc/head/lib/ghc-8.3.20171108/package.conf.d/package.cache
Using binary package database: /tmp/asterius/.stack-work/install/x86_64-linux/ghc-8.3/8.3.20171108/pkgdb/package.cache
package flags []
loading package database /opt/ghc/head/lib/ghc-8.3.20171108/package.conf.d
loading package database /tmp/asterius/.stack-work/install/x86_64-linux/ghc-8.3/8.3.20171108/pkgdb
wired-in package ghc-prim mapped to ghc-prim-
wired-in package integer-gmp mapped to integer-gmp-
wired-in package base mapped to base-
wired-in package rts mapped to rts
View TypeNats.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
import Data.Type.Equality
data Nat
= Zero
| Succ Nat
View State.hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module State where
View Dockerfile
# docker build --build-arg http_proxy= --build-arg https_proxy= .
FROM ubuntu:zesty
RUN apt update
RUN apt install -y software-properties-common
RUN add-apt-repository -y ppa:git-core/candidate
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
RUN apt update
RUN apt upgrade -y
trait INDArrayDumping extends INDArrayWeights {
val dumpingPathPrefix: String
private var currentDumped: Int = 0
override type INDArrayWeight <: INDArrayWeightApi with Weight
trait INDArrayWeightApi extends super.INDArrayWeightApi {
this: INDArrayWeight =>
trait CNNs extends INDArrayLayers with ImplicitsSingleton with Training with Operators {
trait ImplicitsApi
extends super[INDArrayLayers].ImplicitsApi
with super[Training].ImplicitsApi
with super[Operators].ImplicitsApi
type Implicits <: ImplicitsApi
private def toArray(tuple2: (Int, Int)): Array[Int] = {