-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
117 additions
and
37 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ node_modules/ | |
bower_components/ | ||
tmp/ | ||
output/ | ||
.psc-ide-port |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module Control.Applicative.Free.Gen where | ||
|
||
import Prelude | ||
|
||
import Control.Applicative.Free as F | ||
import Control.Monad.Gen (class MonadGen, oneOf) | ||
import Control.Monad.Rec.Class (class MonadRec) | ||
import Data.NonEmpty (NonEmpty(..)) | ||
|
||
genFree :: forall m f a | ||
. MonadGen m | ||
=> MonadRec m | ||
=> m (f Unit) | ||
-> m a | ||
-> m (a -> a) | ||
-> m (F.FreeAp f a) | ||
genFree genF genA genA2A = oneOf $ NonEmpty | ||
( genA <#> pure) | ||
[ do | ||
fUnit <- genF | ||
a <- genA | ||
pure $ | ||
pure (const a) <*> F.liftFreeAp fUnit | ||
, do | ||
fUnit <- genF | ||
a <- genA | ||
a2a <- genA2A | ||
pure $ | ||
(pure (const a) <*> F.liftFreeAp fUnit) <#> a2a | ||
, do | ||
fUnit <- genF | ||
a <- genA | ||
a2a <- genA2A | ||
pure $ | ||
F.liftFreeAp fUnit <#> const a <#> a2a | ||
, do | ||
a <- genA | ||
a2a <- genA2A | ||
pure $ pure a <#> a2a | ||
] |
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
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