Created
April 20, 2017 22:03
-
-
Save jindraivanek/5d01f337ae55b7fef1ad8e490970ccd8 to your computer and use it in GitHub Desktop.
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 ShowTrait = | |
[<Trait>] | |
type Show<'T> = | |
abstract member show: 'T -> string | |
[<Witness>] | |
type ShowInt = | |
interface Show<int> with | |
member __.show(x) = x.ToString() | |
[<Witness>] | |
type ShowFloat = | |
interface Show<float> with | |
member __.show(x) = x.ToString() | |
[<Witness>] | |
type ShowSeq<'U, 'T, 'V when 'T :> Show<'U> and 'V :> seq<'U>> = | |
interface Show<'V> with | |
member __.show(xs) = xs |> Seq.map Show.show |> String.concat "; " | |
let show x = Show.show x | |
open ShowTrait | |
for i in [1..1000] do | |
//sprintf "%A" [1..100] | |
sprintf "%s" <| show [1..100] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment