Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phadej/operational-sum
Operational for sum
https://github.com/phadej/operational-sum
Last synced: 29 days ago
JSON representation
Operational for sum
- Host: GitHub
- URL: https://github.com/phadej/operational-sum
- Owner: phadej
- License: bsd-3-clause
- Created: 2016-04-26T07:26:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-04-26T07:30:32.000Z (over 8 years ago)
- Last Synced: 2024-11-07T03:48:49.203Z (3 months ago)
- Language: Haskell
- Size: 4.88 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# operational-sum
```hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleContexts #-}
module Main (main) whereimport Control.Monad.Operational.Sum
data Foo a where Foo :: Foo ()
data Bar a where Bar :: Bar ()foo :: IsElem Foo xs => ProgramSum xs ()
foo = singletonSum Foobar :: IsElem Bar xs => ProgramSum xs ()
bar = singletonSum Barexample :: (IsElem Foo xs, IsElem Bar xs) => ProgramSum xs ()
example = foo >> barinterpreters :: NP (Interpreter IO) '[Foo, Bar]
interpreters = Interpreter f :* Interpreter b :* Nil
where
f :: Foo a -> IO a
f Foo = putStrLn "foo"b :: Bar a -> IO a
b Bar = putStrLn "bar"main :: IO ()
main = interpretSumWithMonad interpreters example
```