Order coffee with haskell!
The name sounds like a disease
-- A voice inside my head
Warning
This probably shouldn't exist.
This library allows you to order coffee from terminal.shop using haskell. Well, kinda. Naturally, it doesn't produce a runnable program, but that doesn't mean you won't order coffee.
I intend this to be usable by people with little experience in Haskell, but if you stray from the documented path you're pretty much on your own.
Note: If you really want to spoil yourself and just find out what this does, check out the this-is-no-fun branch
Note: This way is only easy if you have nix installed.
Further note: There is no need to clone this repository.
-
Create a new directory and
cd
inside it -
nix --extra-experimental-features "nix-command flakes" develop github:voidus/terminal-coffkell#order
-
Create
Whatever.hs
with one of the examples below (the filename doesn't matter)Note that library has a safety: the COFFEETIME environment variable needs to be defined and non-empty for anything relevant to happen. For your convenience, the nix devshell automatically sets that environment variable. If you want to edit haskell files inside the devshell, you probably want to invoke your editor lik
env COFFEETIME= nvim
. -
Compile it with
ghc Whatever.hs
Note: This is downloading a lot of stuff into the container. You probably don't want to --rm
it but re-use the container for your work until you've either finished your Thesis or ordered coffee.
- Create a new directory and
cd
inside it docker run -ti --name coffkell -v $PWD:/work -w /work nixos/nix sh
- continue with
nix develop ...
from the easy way
- You can later re-use the container by calling
docker start -a coffkell
- To get rid of it, do
docker rm coffkell
- If
docker rm
complains about it still running, show no mercy anddocker stop -s 9 coffkell
- You can probably also run this as not-root somehow
Left as an exercise to the reader. Note that the library will not do anything unless the COFFEETIME variable is set. This is automatically done
Feel free to replace Dev with Prod here if you're feeling it. But note that I have only proved it compiles, not tried it. (Wrong continent sorry)
- Subscribe to the mailing list (note that this also seems to work on the dev server maybe)
{-# LANGUAGE TemplateHaskell, OverloadedRecordDot, DisambiguateRecordFields, OverloadedStrings #-}
import Yum
import Control.Monad.IO.Class
import Data.Text
$(callEndpoint Dev $ terminalCoffee.emailSubscribe "[email protected]")
- Check out the products:
{-# LANGUAGE TemplateHaskell, OverloadedRecordDot, DisambiguateRecordFields, OverloadedStrings #-}
import Yum
import Control.Monad.IO.Class
import Data.Text
$(callEndpoint Dev terminalCoffee.productList)
-
Get a token via
ssh dev.terminal.shop -t tokens
and put it in a file. I recommentmytoken
. If you choose a different name, adjust the filename in the following examples -
Make sure you have a card on file:
{-# LANGUAGE TemplateHaskell, OverloadedRecordDot, DisambiguateRecordFields, OverloadedStrings #-}
import Yum
import Control.Monad.IO.Class
import Data.Text
$(do
token <- liftIO $ tokenFromFile "mytoken"
callEndpoint Dev $ terminalCoffee.cardList token
)
Make sure to note down the ID for later.
If you don't have one yet, you can generate a link to add one:
{-# LANGUAGE TemplateHaskell, OverloadedRecordDot, DisambiguateRecordFields, OverloadedStrings #-}
import Yum
import Control.Monad.IO.Class
import Data.Text
$(do
token <- liftIO $ tokenFromFile "mytoken"
callEndpoint Dev $ terminalCoffee.cardCollect token
)
- Make sure you have a delivery address on file:
{-# LANGUAGE TemplateHaskell, OverloadedRecordDot, DisambiguateRecordFields, OverloadedStrings #-}
import Yum
import Control.Monad.IO.Class
import Data.Text
$(do
token <- liftIO $ tokenFromFile "mytoken"
callEndpoint Dev $ terminalCoffee.addressList token
)
Again, make sure to note down the ID for later.
If you don't have one yet, you can add an address like so:
{-# LANGUAGE TemplateHaskell, OverloadedRecordDot, DisambiguateRecordFields, OverloadedStrings #-}
import Yum
import Control.Monad.IO.Class
import Data.Text
$( do
token <- liftIO $ tokenFromFile "mytoken"
callEndpoint Dev $
terminalCoffee.addressCreate
token
Address
{ name = "Jeff Albertson (Comic Book Guy)"
, street1 = "123 Nerd Paradise Lane"
, street2 = "The Android's Dungeon & Baseball Card Shop"
, city = "Springfield"
, province = "NT"
, zip = "12345"
, country = "US"
, phone = "555-WORST-EVER"
}
)
- Now you're ready to order:
{-# LANGUAGE TemplateHaskell, OverloadedRecordDot, DisambiguateRecordFields, OverloadedStrings #-}
import Yum
import Control.Monad.IO.Class
import Data.Text
$( do
token <- liftIO $ tokenFromFile "mytoken"
callEndpoint Dev $
terminalCoffee.orderCreate
token
Order
{ cardID = "crd_XXXXXXXXXXXXXXXXXXXXXXXXXX"
, addressID = "shp_XXXXXXXXXXXXXXXXXXXXXXXXXX"
, variants = [("prd_01JNH7GKWYRHX45GPRZS3M7A4X", 2)]
}
)
Honestly, same.
Maybe. It shouldn't, but see the note at the top.
Unclear. I did attempt to order but things look complicated right now.
Of course. It's a paper produced in 2025 (or whatever year it is).
That said, the readme was exclusively written by me without AI assistance.