Last active
September 18, 2020 01:25
-
-
Save MarcelineVQ/e3695adaa386f378803d577ec0d0b2d2 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
`( [| ( x , y ) |] ) | |
IAlternative | |
(UniqueDefault | |
(IApp | |
(IApp | |
(IVar (UN "<*>")) | |
(IApp | |
(IApp | |
(IVar (UN "<*>")) | |
(IApp | |
(IVar (UN "pure")) | |
(IVar (NS (MkNS ["Builtin"]) (UN "MkPair"))))) | |
(IVar (UN "x")))) | |
(IVar (UN "y")))) | |
[IApp | |
(IApp | |
(IVar (UN "<*>")) | |
(IApp | |
(IApp | |
(IVar (UN "<*>")) | |
(IApp | |
(IVar (UN "pure")) | |
(IVar (NS (MkNS ["Builtin"]) (UN "Pair"))))) | |
(IVar (UN "x")))) | |
(IVar (UN "y")) | |
,IApp | |
(IApp | |
(IVar (UN "<*>")) | |
(IApp | |
(IApp | |
(IVar (UN "<*>")) | |
(IApp | |
(IVar (UN "pure")) | |
(IVar (NS (MkNS ["Builtin"]) (UN "MkPair"))))) | |
(IVar (UN "x")))) | |
(IVar (UN "y"))] |
export
record Core t where
constructor MkCore
runCore : IO (Either String t)
pure : a -> Core a
pure x = MkCore (pure (pure x))
export
(<*>) : Core (a -> b) -> Core a -> Core b
(<*>) (MkCore f) (MkCore a) = MkCore [| f `Prelude.(<*>)` a |]
addm : Maybe Int -> Maybe Int -> Maybe Int
addm x y = [| x + y |]
pairingGood : Applicative f => f (Maybe a, Maybe b)
pairingGood = [| MkPair [| Nothing |] [| Nothing |] |]
pairingAmbig : Applicative f => f (Maybe a, Maybe b)
pairingAmbig = [| ( [| Nothing |] , [| Nothing |] ) |]
pairing : Applicative f => f a -> f b -> f (a,b)
pairing x y = %runElab check (IApp fc
(IApp fc
(IVar fc (UN "<*>"))
(IApp fc
(IApp fc
(IVar fc (UN "<*>"))
(IApp fc
(IVar fc (UN "pure"))
(IAlternative fc (UniqueDefault (IVar fc (NS (MkNS ["Builtin"]) (UN "MkPair"))))
[(IVar fc (NS (MkNS ["Builtin"]) (UN "MkPair"))), (IVar fc (NS (MkNS ["Builtin"]) (UN "Pair")))])))
(IVar fc (UN "x"))))
(IVar fc (UN "y")))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.