Created
October 27, 2017 18:56
-
-
Save msmorgan/e2069f1507a200d51dd611f95f18efa2 to your computer and use it in GitHub Desktop.
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 characters
||| Utilities functions for contitionally delaying values. | |
module Control.Delayed | |
%default total | |
||| Type-level function for a conditionally infinite type. | |
public export | |
inf : Bool -> Type -> Type | |
inf True a = Inf a | |
inf False a = a |
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 characters
module Main | |
import Data.MonadLike | |
testFinite : MonadLike True Int | |
testFinite = do pureC False Z | |
pureC True 5 | |
testInfinite : MonadLike True Int | |
testInfinite = do pureC True Z | |
testInfinite | |
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 characters
module Mod.Used | |
import Control.Delayed | |
%default total | |
export | |
data MonadLike : Bool -> Type -> Type where | |
Pure : a -> MonadLike c a | |
Bind : MonadLike c1 a -> | |
(a -> MonadLike c2 b) -> | |
MonadLike (c1 || c2) b | |
InfBind : MonadLike True a -> | |
Inf (a -> MonadLike c2 b) -> | |
MonadLike True b | |
export | |
pureC : (c : Bool) -> a -> MonadLike c a | |
pureC c = Pure | |
export | |
(>>=) : MonadLike c1 a -> inf c1 (a -> MonadLike c2 b) -> MonadLike (c1 || c2) b | |
(>>=) {c1 = True} = InfBind | |
(>>=) {c1 = False} = Bind | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment