Yampa 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
Yampa 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
Yampa 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 Readme
开发语言 Java
操作系统 Android
软件类型 开源软件
开源组织
地区 不详
投 递 者 首席测试
适用人群 未知
收录时间 2021-11-26

软件简介

Yampa

Build Status Version on Hackage Flattr this

Domain-specific language embedded in Haskell for programming hybrid (mixed discrete-time and continuous-time) systems. Yampa is based on the concepts of Functional Reactive Programming (FRP) and is structured using arrow combinators.

Installation

Yampa is available on hackage: http://hackage.haskell.org/package/Yampa.

$ cabal update
$ cabal install --lib Yampa

Examples

Getting Yampa to run is trivial. FRP is about values that change over time. In Yampa, a system is defined by a signal function (SF), which determines how the varying input and the varying output relate. For example:

{-# LANGUAGE Arrows #-}
import FRP.Yampa

signalFunction :: SF Double Double
signalFunction = proc x -> do
  y <- integral -< x
  t <- time     -< ()
  returnA -< y / t

This signal function says that the output signal is the integral y of the input signal x, divided by the time t. The above syntax uses a Haskell extension called Arrows. If you are unhappy using arrow syntax, you can also write that code using applicative style and/or arrow combinators:

signalFunction1 :: SF Double Double
signalFunction1 = (/) <$> integral <*> time

signalFunction2 :: SF Double Double
signalFunction2 = (integral &&& time) >>^ (/)

All three are equivalent, and it's a matter of which one you like best. To run this example, we need to provide the inputs, the times, and consume the output:

firstSample :: IO Double   -- sample at time zero
firstSample =
  return 1.0  -- time == 0, input == 1.0

nextSamples :: Bool -> IO (Double, Maybe Double)
nextSamples _ =
  return (0.1, Just 1.0) -- time delta == 0.1s, input == 1.0

output :: Bool -> Double -> IO Bool
output _ x = do
  print x     -- print the output
  return False -- just continue forever

This is a trivial example, since the integral of the constant function 1.0 over time, divided by the time, is always 1.0! Nevertheless, we are now ready to run!

ghci> reactimate firstSample nextSamples output signalFunction
1.0
1.0
1.0
1.0
1.0
1.0
...

There is a directory with examples, which includes two basic SDL examples and one with using a Nintendo Wii Remote. You can install them with:

$ cabal update
$ cabal install Yampa -fexamples

There are many programs written in Yampa:

  • Haskanoid: a game that uses SDL multimedia, wiimote and kinect. It's cross platform and works in desktop, mobile, and web (compiled with GHCJS).
  • Space invaders.
  • Frag: a 3D first person shooting game.
  • Peoplemon: a role playing game.
  • Yampa-2048: an implementation of the game 2048 using Yampa and Gloss.
  • MandelbrotYampa: a "hello world" using SDL2, Yampa and OpenGL.
  • Haskelloids: a reproduction of the Atari 1979 classic "Asteroids"

A more comprehensive list can be obtained using the reverse dependency finder (http://packdeps.haskellers.com/reverse/Yampa), but only programs uploaded to hackage are listed.

Haskanoid Video Peoplemon by Alex Stuart Space Invaders
Haskanoid, SDL cross-platform arkanoid. Peoplemon, a role playing game Yampa2048, a gloss board game

Use in production

Keera Studios uses Yampa to create Haskell games available on Google Play for Android and iTunes for iOS:

Magic Cookies!

Magic Cookies! Video
Copyright © 2015 - 2020 Keera Studios Ltd. All Rights Reserved.
  

Enpuzzled

Enpuzzled Video
Copyright © - 2017 - Keera Studios Ltd - All Rights Reserved.
  

Keera, Keera Studios, Magic Cookies, the Magic Cookies logo, the Magic Cookies splash screen, Enpuzzled, the Enpuzzled splash screen, and the Enpuzzled logo are trademarks of Keera Studios Ltd. Google Play and the Google Play logo are trademarks of Google LLC. Apple, the Apple logo, iPhone, and iPad are trademarks of Apple Inc., registered in the U.S. and other countries and regions. App Store is a service mark of Apple Inc.

Backends

Yampa is backend agnostic, you can ultimately connect it to any backend you want. Existing backends include:

Testing

Yampa comes with a sophisticated testing library that allows you to use QuickCheck to test your games, and use a time-travel debugger. These features are described in the paper Testing and Debugging Functional Reactive Programming.

You can find the additional projects at:

Documentation and tutorials

The API of Yampa is thoroughly documented on hackage. Documentation is also available in the Haskell wiki page for Yampa.

Papers and technical reports

Related projects

  • yampa-sdl2: Yampa and SDL2 made easy.
  • Haskell-OpenGL-Tutorial same as here: Visually attractive mandelbrot implementation.
  • graphui: Attempt to implement Graphui.
  • hamball: 3D, LAN FPS game of hamster balls flying around and shooting lasers written in Haskell.
  • yampa-glfw: GLFW backend.
  • Spaceinvaders: Re-write of the classic space invaders.
  • Haskanoid: Arkanoid clone in SDL with wiimote and kinect support that works on windows, linux, Mac, Android, and Web.
  • Magic Cookies!: iOS/Android haskell puzzle game.
  • Enpuzzled: iOS/Android haskell puzzle game.
  • Pang-a-lambda: 2D arcade game inspired by the classic super-pang.
  • yampa-canvas: Backend to blank-canvas / HTML5 Canvas.
  • yampa-gloss: Gloss backend.
  • diagrams example: Demonstration of Yampa with Diagrams.
  • Keera Hails: Backend for reactive framework with GTK, WX, Qt, Android, iOS and HTML support.
  • YampaSynth: Software synthesizer.
  • Frag: 3D first person shooter.
  • cuboid: 3D puzzle game with GLUT.
  • Haskelloids: Reproduction of the Atari 1979 classic "Asteroids".
  • YFrob: Yampa-based library for programming robots.
  • YampaShooter: Top-down team based networked tank game.
  • LaneWars: Top-down MOBA game with online multiplayer.
  • Functional Reactive Virtual Reality: a fork of Yampa with extensions for VR.
  • Dunai: An FRP implementation inspired by Yampa that extends SFs with a monad.
  • Bearriver: API-compatible Yampa replacement built on top of dunai using Monadic Stream Functions.
  • The Bearriver Arcade: A couple of arcade games made using bearriver.

Help and collaboration

You can collaborate at least in three ways:

  • File an issue (https://github.com/ivanperez-keera/Yampa/issues).
  • Write documentation (send a link and/or a pull request).
  • Research: we are constantly trying to improve Yampa. We'd be glad to have collaborators. If you are working on this, please, let us know.

Authors

  • Henrik Nilsson
  • Antony Courtney

Maintainer

  • Ivan Perez
展开阅读全文

代码

评论

点击引领话题📣 发布并加入讨论🔥
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
0 评论
0 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部