Last active
November 29, 2017 08:14
-
-
Save arowM/836d478bda8cac261e1e5cab200a5ab0 to your computer and use it in GitHub Desktop.
Revisions
-
arowM revised this gist
Nov 29, 2017 . 1 changed file with 1 addition and 1 deletion.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 @@ -28,7 +28,7 @@ default (Default a) = {-| ``` instance Default Int where default :: Int default = 0 ``` -
arowM revised this gist
Nov 29, 2017 . 1 changed file with 11 additions and 0 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,6 +12,10 @@ import Task exposing (Task) {-| Phantom type to define default value of type `a`. ``` class Default a where default :: a ``` -} type Default a = Default a @@ -22,6 +26,13 @@ default (Default a) = a {-| ``` instance (Default Int) where default :: Int default = 0 ``` -} int : Default Int int = Default 0 -
arowM revised this gist
Nov 29, 2017 . 1 changed file with 0 additions and 2 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 @@ -38,8 +38,6 @@ maybe (Default a) = {-| A Stub. stubTask int (Task.succeed 10) --> 0 -
arowM created this gist
Nov 29, 2017 .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,57 @@ module Default exposing ( Default , default , int , string , maybe , stubTask ) import Task exposing (Task) {-| Phantom type to define default value of type `a`. -} type Default a = Default a default : Default a -> a default (Default a) = a int : Default Int int = Default 0 string : Default String string = Default "" maybe : Default a -> Default (Maybe a) maybe (Default a) = Default <| Just a {-| A Stub. import Task stubTask int (Task.succeed 10) --> 0 stubTask string (Task.succeed "foo") --> "" stubTask (maybe string) (Task.succeed <| Nothing) --> Just "" stubTask (maybe (maybe int)) (Task.succeed <| Just (Just 3)) --> Just (Just 0) -} stubTask : Default a -> Task error a -> a stubTask def _ = default def