Skip to content

Instantly share code, notes, and snippets.

@alexhumphreys
Last active November 27, 2020 08:00
Show Gist options
  • Save alexhumphreys/73acaa5b1375c70fff006607e5acc6ce to your computer and use it in GitHub Desktop.
Save alexhumphreys/73acaa5b1375c70fff006607e5acc6ce to your computer and use it in GitHub Desktop.
minimal example to show weirdly different generated code sizes depending on case ordering
data Value
= VLambda
| VHLam
| VPi
| VHPi String Value (Value -> Value)
| VEquivalent Value Value
| VAssert Value
| VConst
| VBool
| VBoolLit
| VInteger
| VListFold Value Value Value Value Value
| VText
| VTextLit
| VOptional Value
| VRecord Value
| VRecordLit Value
| VUnion (Maybe Value)
| VInject (Maybe Value) (Maybe Value)
| VPrimVar
someFunc : List a -> Value -> Value -> Either String Value
-- someFunc xs _ (VListFold y z w v s) = Right VBool -- $ idris2 CodeGen.idr --client ':di someFunc' | wc -c # 9037
someFunc xs VPi VLambda = Right VBool
someFunc xs VInteger VHLam = Right VBool
someFunc xs VPi VPi = Right VBool
someFunc xs VBool (VHPi y z f) = Right VBool
someFunc xs VBool (VEquivalent y z) = Right VBool
someFunc xs VPi (VAssert y) = Right VBool
someFunc xs VTextLit VConst = Right VBool
someFunc xs VPrimVar VBool = Right VBool
someFunc xs VPi VBoolLit = Right VBool
someFunc xs VPi (VOptional y) = Right VBool
someFunc xs VPrimVar (VUnion a) = Right VBool
-- someFunc xs VPi (VListFold y z w v s) = Right VBool -- $ idris2 CodeGen.idr --client ':di someFunc' | wc -c # 8977
someFunc xs _ (VListFold y z w v s) = Right VBool -- $ idris2 CodeGen.idr --client ':di someFunc' | wc -c # 34987
someFunc xs VBool VTextLit = Right VBool
someFunc xs VPi (VInject x y) = Right VBool
someFunc xs VPrimVar (VOptional y) = Right VBool
someFunc xs VText (VUnion y) = Right VBool
someFunc xs VPi VText = Right VBool
someFunc xs VText VTextLit = Right VBool
someFunc xs VBool (VOptional y) = Right VBool
someFunc xs VPi (VRecord y) = Right VBool
someFunc xs VPrimVar (VRecordLit y) = Right VBool
someFunc xs VPi (VUnion y) = Right VBool
someFunc xs x (VInject y z) = Right VBool
someFunc xs x VPrimVar = Right VBool
-- someFunc xs _ (VListFold y z w v s) = Right VBool -- $ idris2 CodeGen.idr --client ':di someFunc' | wc -c # 10423
someFunc xs _ _ = Left "whatever"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment