- Function definition, application.
- Pattern matching
- Recursion
- map, fold
- Functions as values
- data declarations
- Parametric polymorphism
| case class Foo(a: Int) { | |
| def map(f : Int => Int) = Foo(f(a)) | |
| def flatMap(f : Int => Bar): Bar = f(a) | |
| } | |
| case class Bar(a: Int) { | |
| def map(f : Int => Int) = Bar(f(a)) | |
| def flatMap(f : Int => Bar): Bar = f(a) | |
| } |
| -- Apply the callback that is the rest of the lines of code | |
| (>>=) : Int -> (Int -> Int) -> Int | |
| (>>=) x f = f x | |
| i : Int | |
| i = do | |
| x <- 1 | |
| y <- 2 | |
| x + y |
| module Main(main, a) where | |
| a = "foo" | |
| main = putStrLn a |
| {-# LANGUAGE OverloadedStrings #-} | |
| import Data.Aeson | |
| thing = object [ "foo" .= "bar" ] |
| module Main where | |
| import System.Taffybar | |
| import System.Taffybar.Information.CPU | |
| import System.Taffybar.Information.Memory | |
| import System.Taffybar.SimpleConfig | |
| import System.Taffybar.Widget | |
| import System.Taffybar.Widget.Workspaces | |
| import System.Taffybar.Widget.Battery | |
| import System.Taffybar.Widget.SNITray |
| {-# LANGUAGE FlexibleContexts, FlexibleInstances, UndecidableInstances #-} | |
| import Data.Has | |
| data Foo = Foo deriving Show | |
| data Bar = Bar deriving Show | |
| class HasFoo r where | |
| foo :: r -> Foo | |
| instance HasFoo Foo where | |
| foo = id |
| #include <stdio.h> | |
| #include <fcntl.h> | |
| #include <unistd.h> | |
| #include <string.h> | |
| #include <errno.h> | |
| #include <stdlib.h> | |
| #include <sys/epoll.h> | |
| #include <sys/types.h> | |
| int main(int argc, char** argv) { |
| {-# LANGUAGE MultiParamTypeClasses, TypeOperators #-} | |
| import Data.Maybe (maybeToList) | |
| class (~>) m n where | |
| nt :: m x -> n x | |
| instance (~>) Maybe [] where | |
| nt = maybeToList |
| # $Id$ | |
| # Maintainer: Daniel Martí <[email protected]> | |
| _hkgname=hint | |
| pkgname=haskell-hint | |
| pkgver=0.7.0 | |
| pkgrel=1 | |
| pkgdesc="Runtime Haskell interpreter (GHC API wrapper)" | |
| url="https://github.com/mvdan/$_hkgname" | |
| license=('BSD') |