Energy prices as command prompt ASCII table -- Haskell version

The website jeroen.nl returns current and daily energy prices, but it would be nice to view this information from the command line. Haskell version.

Introduction

Earlier I created photonsphere.org/post/2025-03-15-command-line-energy-prices for this but when I moved from NixOS to Debian (stable), as described in photonsphere.org/post/2025-04-26-debian-declarative-install-script it no longer compiles.

Setbacks

My Elixir program to view energy prices from the command line does not compile -- presumably because Debian stable has an older BEAM version.

 1$ make build
 2mix escript.build
 3
 410:40:19.811 [error] Task #PID<0.211.0> started from #PID<0.96.0> terminating
 5** (FunctionClauseError) no function clause matching in Hex.Solver.Constraint.Hex.Solver.Constraints.Empty.__impl__/1
 6    (hex 2.1.1) Hex.Solver.Constraint.Hex.Solver.Constraints.Empty.__impl__(:target)
 7    (elixir 1.14.0) lib/protocol.ex:672: Protocol.each_struct_clause_for/3
 8    (elixir 1.14.0) lib/protocol.ex:650: anonymous fn/4 in Protocol.change_struct_impl_for/4
 9    (elixir 1.14.0) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
10    (elixir 1.14.0) lib/protocol.ex:650: Protocol.change_struct_impl_for/4
11    (elixir 1.14.0) lib/protocol.ex:612: Protocol.change_debug_info/3
12    (elixir 1.14.0) lib/protocol.ex:563: Protocol.consolidate/2
13    (mix 1.14.0) lib/mix/tasks/compile.protocols.ex:140: Mix.Tasks.Compile.Protocols.consolidate/4
14Function: #Function<9.61781368/0 in Mix.Tasks.Compile.Protocols.consolidate/6>
15    Args: []
16** (EXIT from #PID<0.96.0>) an exception was raised:
17    ** (FunctionClauseError) no function clause matching in Hex.Solver.Constraint.Hex.Solver.Constraints.Empty.__impl__/1
18        (hex 2.1.1) Hex.Solver.Constraint.Hex.Solver.Constraints.Empty.__impl__(:target)
19        (elixir 1.14.0) lib/protocol.ex:672: Protocol.each_struct_clause_for/3
20        (elixir 1.14.0) lib/protocol.ex:650: anonymous fn/4 in Protocol.change_struct_impl_for/4
21        (elixir 1.14.0) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
22        (elixir 1.14.0) lib/protocol.ex:650: Protocol.change_struct_impl_for/4
23        (elixir 1.14.0) lib/protocol.ex:612: Protocol.change_debug_info/3
24        (elixir 1.14.0) lib/protocol.ex:563: Protocol.consolidate/2
25        (mix 1.14.0) lib/mix/tasks/compile.protocols.ex:140: Mix.Tasks.Compile.Protocols.consolidate/4
26
27make: *** [Makefile:29: build] Error 1

When confronted with a setback like this I tend to always look for the easiest solution. Hence I recoded the whole thing in Haskell ;-)

hdynprice

The Elixir program retrieves the content of the energy prices website and parses the data and displays an ASCII table and summary and is on CodeBerg: photonsphere/dynprice.

The Haskell version uses Megaparsec to parse HTML and JavaScript/JSON sections to retrieve the desired information. I could have used regular expressions like in the Elixir version, but, when confronted with a problem I tend to aways look for the easiest solution ;-) Plus parsers like these are well supported in Haskell. The software is on CodeBerg: photonsphere/hdynprice 1.

Usage

 1$ hdynprice 
 2https://jeroen.nl/dynamische-energie/stroom/prijzen
 3
 4Tijd	Totaal	Inkoop per kWh
 500:00	0.265	0.094
 601:00	0.259	0.089
 702:00	0.259	0.089
 803:00	0.263	0.092
 904:00	0.267	0.095
1005:00	0.269	0.097
1106:00	0.274	0.102
1207:00	0.269	0.097
1308:00	0.255	0.086
1409:00	0.168	0.014
1510:00	0.152	0.000
1611:00	0.151	-0.000
1712:00	0.150	-0.001
1813:00	0.148	-0.003
1914:00	0.148	-0.003
2015:00	0.151	-0.000
2116:00	0.151	0.000
2217:00	0.184	0.027
2318:00	0.224	0.060
2419:00	0.241	0.074
2520:00	0.256	0.086
2621:00	0.255	0.085
2722:00	0.264	0.093
2823:00	0.256	0.086
29
30Dynamische stroomprijzen voor vandaag
31De actuele dynamische inkoop prijs voor stroom is op dit moment  0.060100  euro per kWh (18:41).
32Hoogste prijs vandaag:  0.101640  euro per kWh (tussen 6:00 en 7:00).
33Laagste prijs vandaag:  -0.003040  euro per kWh (tussen 13:00 en 14:00).

With the verbose option -- note the vertically printed read from bottom to top column names :)

 1$ hdynprice --verbose
 2https://jeroen.nl/dynamische-energie/stroom/prijzen
 3
 4 	   	   	  )	   	   	  
 5 	   	   	  w	   	   	  
 6 	   	   	  t	   	   	  
 7 	   	   	  b	   	   	  
 8 	   	   	   	   	   	  
 9 	   	   	  l	   	   	  
10 	   	   	  c	   	   	  
11 	   	   	  x	   	   	  
12 	   	   	  e	   	   	  
13 	   	   	  (	   	   	  
14 	   	   	   	   	   	  
15 	   	   	  h	   	   	  
16 	   	   	  W	   	   	  
17 	   	   	  k	   	   	  
18 	   	   	   	   	   	  
19 	   	   	  r	   	   	  
20 	   	   	  e	   	   	  
21 	   	   	  p	   	   	  
22 	   	   	   	   	   	  
23 	   	   	  g	  )	   	  
24 	   	   	  n	  w	   	  
25 	   	   	  i	  t	   	  
26 	   	   	  d	  b	   	  
27 	   	   	  e	   	   	  
28 	   	   	  o	  l	   	  
29 	   	   	  g	  c	   	  
30 	   	   	  r	  x	   	  
31 	   	   	  e	  e	   	  
32 	   	   	  v	  (	   	  
33 	   	   	  p	   	   	  
34 	   	   	  o	  g	  )	  
35 	   	   	  o	  n	  %	  
36 	   	  h	  k	  i	  1	  
37 	   	  W	  n	  t	  2	  
38 	   	  k	  i	  s	  (	  
39 	   	   	   	  a	   	  
40 	   	  r	  e	  l	  W	  
41 	   	  e	  d	  e	  T	  
42 	   	  p	  l	  b	  B	  
43 	   	   	  e	  e	   	  
44 	  l	  p	  d	  i	  l	  
45 	  a	  o	  d	  g	  a	  
46d	  a	  o	  i	  r	  a	  
47j	  t	  k	  m	  e	  t	  
48i	  o	  n	  e	  n	  o	  
49T	  T	  I	  G	  E	  T	  
5000:00	0.265	0.094	0.024	0.102	0.046
5101:00	0.259	0.089	0.024	0.102	0.045
5202:00	0.259	0.089	0.024	0.102	0.045
5303:00	0.263	0.092	0.024	0.102	0.046
5404:00	0.267	0.095	0.024	0.102	0.046
5505:00	0.269	0.097	0.024	0.102	0.047
5606:00	0.274	0.102	0.024	0.102	0.048
5707:00	0.269	0.097	0.024	0.102	0.047
5808:00	0.255	0.086	0.024	0.102	0.044
5909:00	0.168	0.014	0.024	0.102	0.029
6010:00	0.152	0.000	0.024	0.102	0.026
6111:00	0.151	-0.000	0.024	0.102	0.026
6212:00	0.150	-0.001	0.024	0.102	0.026
6313:00	0.148	-0.003	0.024	0.102	0.026
6414:00	0.148	-0.003	0.024	0.102	0.026
6515:00	0.151	-0.000	0.024	0.102	0.026
6616:00	0.151	0.000	0.024	0.102	0.026
6717:00	0.184	0.027	0.024	0.102	0.032
6818:00	0.224	0.060	0.024	0.102	0.039
6919:00	0.241	0.074	0.024	0.102	0.042
7020:00	0.256	0.086	0.024	0.102	0.044
7121:00	0.255	0.085	0.024	0.102	0.044
7222:00	0.264	0.093	0.024	0.102	0.046
7323:00	0.256	0.086	0.024	0.102	0.044
74
75Dynamische stroomprijzen voor vandaag
76De actuele dynamische inkoop prijs voor stroom is op dit moment  0.060100  euro per kWh (18:42).
77Hoogste prijs vandaag:  0.101640  euro per kWh (tussen 6:00 en 7:00).
78Laagste prijs vandaag:  -0.003040  euro per kWh (tussen 13:00 en 14:00).

  1. Naming inspired by hledger -- https://hledger.org ↩︎

Posts in this Series