Created
April 26, 2021 14:37
-
-
Save velveteer/c321f5debe116949ca19318850b87e2d to your computer and use it in GitHub Desktop.
GHC Simplifier Bug
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 Lib where | |
data Wrapped a = | |
Exists a | DoesNotExist | |
data RecordUpdate = | |
RecordUpdate | |
{ rua :: Wrapped Int | |
, rub :: Wrapped Int | |
, ruc :: Wrapped Int | |
, rud :: Wrapped Int | |
, rue :: Wrapped Int | |
, ruf :: Wrapped Int | |
, rug :: Wrapped Int | |
, ruh :: Wrapped Int | |
, rui :: Wrapped Int | |
, ruj :: Wrapped Int | |
, ruk :: Wrapped Int | |
, rul :: Wrapped Int | |
, rum :: Wrapped Int | |
, run :: Wrapped Int | |
, ruo :: Wrapped Int | |
} | |
data RecordTest = | |
RecordTest | |
{ ra :: Int | |
, rb :: Int | |
, rc :: Int | |
, rd :: Int | |
, re :: Int | |
, rf :: Int | |
, rg :: Int | |
, rh :: Int | |
, ri :: Int | |
, rj :: Int | |
, rk :: Int | |
, rl :: Int | |
, rm :: Int | |
, rn :: Int | |
, ro :: Int | |
} | |
setA val rec = rec { ra = val } | |
setB val rec = rec { rb = val } | |
setC val rec = rec { rc = val } | |
setD val rec = rec { rd = val } | |
setE val rec = rec { re = val } | |
setF val rec = rec { rf = val } | |
setG val rec = rec { rg = val } | |
setH val rec = rec { rh = val } | |
setI val rec = rec { ri = val } | |
setJ val rec = rec { rj = val } | |
setK val rec = rec { rk = val } | |
setL val rec = rec { rl = val } | |
setM val rec = rec { rm = val } | |
setN val rec = rec { rn = val } | |
setO val rec = rec { ro = val } | |
applyWrapped :: (val -> rec -> rec) -> Wrapped val -> rec -> rec | |
applyWrapped func wrapped rec = | |
mapWrap rec (flip func rec) wrapped | |
mapWrap :: b -> (a -> b) -> Wrapped a -> b | |
mapWrap n _ DoesNotExist = n | |
mapWrap _ f (Exists x) = f x | |
applyRecordUpdate :: RecordUpdate -> RecordTest -> RecordTest | |
applyRecordUpdate update oldRecord | |
= applyWrapped setA (rua update) | |
. applyWrapped setB (rub update) | |
. applyWrapped setC (ruc update) | |
. applyWrapped setD (rud update) | |
. applyWrapped setE (rue update) | |
. applyWrapped setF (ruf update) | |
. applyWrapped setG (rug update) | |
. applyWrapped setH (ruh update) | |
. applyWrapped setI (rui update) | |
. applyWrapped setJ (ruj update) | |
. applyWrapped setK (ruk update) | |
. applyWrapped setL (rul update) | |
. applyWrapped setM (rum update) | |
. applyWrapped setN (run update) | |
. applyWrapped setO (ruo update) | |
$ oldRecord |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment