Last active
November 30, 2023 09:48
-
-
Save ForNeVeR/135addb5c95faaba80e8a122dcaf7392 to your computer and use it in GitHub Desktop.
Revisions
-
ForNeVeR revised this gist
Aug 1, 2020 . 1 changed file with 3 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,15 +4,11 @@ let mutable debug = true type T = T with static member inline ($) (T, arg: unit) = () static member inline ($) (T, arg: int) = 0 // mandatory second terminal case; is unused in runtime but is required for the code to compile static member inline ($) (T, func: ^a -> ^b): ^a -> ^b = fun (_: 'a) -> T $ Unchecked.defaultof<'b> let inline negate(): 'a = T $ Unchecked.defaultof<'a> let inline debugLog format = @@ -25,7 +21,7 @@ let inline debugLog format = [<EntryPoint>] let main _ = debug <- false debugLog "This: %s" "foo" debugLog "That: %d - %d = %d" 2 2 4 debugLog "Invisible! %s" "haha" -
ForNeVeR revised this gist
Aug 1, 2020 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,10 +12,10 @@ type T with fun (_: 'a) -> zombify Unchecked.defaultof<'b> let inline negate(): 'a = // printfn "%A" <| typeof<'a> T $ Unchecked.defaultof<'a> let inline debugLog format = if debug then Printf.kprintf ( printfn "%A: %s" DateTime.Now @@ -25,10 +25,10 @@ let debugLog format = [<EntryPoint>] let main _ = debug <- true debugLog "This: %s" "foo" debugLog "That: %d - %d = %d" 2 2 4 debugLog "Invisible! %s" "haha" debug <- true debugLog "Visible" 0 -
ForNeVeR created this gist
Aug 1, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ open System let mutable debug = true type T = T with static member inline ($) (T, arg: unit) = () static member inline ($) (T, arg: int) = 0 let inline zombify a : 'r = T $ a type T with static member inline ($) (T, func: ^a -> ^b): ^a -> ^b = fun (_: 'a) -> zombify Unchecked.defaultof<'b> let inline negate(): 'a = printfn "%A" <| typeof<'a> T $ Unchecked.defaultof<'a> let debugLog format = if debug then Printf.kprintf ( printfn "%A: %s" DateTime.Now ) format else negate() [<EntryPoint>] let main _ = debug <- false // debugLog "This: %s" "foo" debugLog "That: %d - %d = %d" 2 2 4 // debugLog "Invisible! %s" "haha" // debug <- true // debugLog "Visible" 0