Sandbox: Difference between revisions

From HaskellWiki
No edit summary
(Undo revision 66720 by Atravers (talk))
Tag: Undo
 
(33 intermediate revisions by 15 users not shown)
Line 1: Line 1:
Sample page.
''Feel free to edit as you wish on this page. It is here for you to experiment with WIKI edit syntax.''


{-
==fooling around==
| Pavillon | Uge | Uge |
{{Standard class|State|module=Control.Monad.State.Lazy|module-doc=Control.Monad.State.Lazy|package=test}}
-}
 
{| border=0 align=right cellpadding=4 cellspacing=0 style="border:1px #aaa solid"
| <TT>import [http://www.haskell.org/ghc/docs/latest/html/testp/testmd.html testm]</TT>
|}
TADA! [http://google.com this is a link to google, surprisingly]
 
[[User:Siers|Siers]] Fri Jun 27 02:36:37 EEST 2014
 
==section==
[[Sandbox#secton]]<br>
[[#Links]]<br>
 
 
 
--[[User:Lars|Lars]] 11:14, 27 July 2009 (UTC)
----
<math>Insert formula here</math>[[Media:Example.ogg]][[Image:Example.jpg]]
== Headline text ==
''Italic text'''''Bold text'''
{| border="1"
|-
|Pavillon || Uge || Uge  
|}
 
Matrix:
:<math>\left[ \begin{matrix}1 & 2 \\ 3 & 4\end{matrix} \right]</math>
 
Embedded matrix:
:<math>\left[ \begin{matrix}1 & 2 \\ 3 & \left[ \begin{matrix}5 & 6 \\ 7 & 8\end{matrix}\right] \end{matrix} \right]</math>
 
== Links ==
 
An [[internal]] link. To not exists page [[abcd]]. To exists page [[Haskell]]
 
=== External ===
http://cs.pdx.edu/
:
http://cs.pdx.edu/~dick/HaskellSemantics/jpf05.pdf
:
http://cs.pdx.edu/~dick/HaskellSemantics/Haskell98.pdf
 
There is no appearance difference between dead link [http://deadlink.local dead] and live link [http://wiki.haskell.org live]
 
Text taken from http://hpaste.org/3881: this wiki's syntax highlight at least does not garble the source, unlike hpaste's highlight.
 
An [http://www.haskell.org external link] using text instead of the raw link address.
 
<haskell>
module Main where
 
import Prelude hiding (putStrLn, print)
import System.IO.UTF8
import Data.List (intersperse, find)
 
type Персонаж = String
type Персонажи = [Персонаж]
 
едоки :: Персонажи
едоки = [ "дедка", "бабка", "внучка", "жучка", "кошка", "мышка" ]
 
подходы :: [ Персонажи ]
подходы = scanl позвать [] едоки
  where позвать тянущие подмога = подмога:тянущие
 
построились :: Персонажи -> [ (Персонаж, Персонаж) ]
построились едоки = zip едоки ("репка":едоки)
 
диспозиции = map (построились.reverse) подходы
 
описать [] = "Посадил дед репку ..."
описать диспозиция =
  unwords ["Взялись:"
          , concat $ intersperse ", " $ map за диспозиция
          , ". Тянут-потянут -- " ++ result
          ]
  where
    за (кто,кого) = кто ++ " за " ++ винительный_падеж кого
    винительный_падеж ы = init ы ++ "у"
    result = case find ((=="мышка").fst) диспозиция of
                  Just _  -> "вытянули репку!"
                  Nothing -> "вытянуть не могут!"
 
main = mapM_ putStrLn $ map описать диспозиции</haskell>
 
== Section ==
=== Subsection ===
==== Subsubsection ====
 
huhu
 
===== Subsubsubsection =====
 
= tables =
== basic table ==
 
{|
|-
! Header 1
! Header 2
! Header 3
|-
| row 1, cell 1
| row 1, cell 2
| row 1, cell 3
|-
| row 2, cell 1
| row 2, cell 2
| row 2, cell 3
|}
 
=Single Quote=
 
https://github.com/ppelleti/haskell-wiki-bugs/issues/6
 
This seems to be fixed.
 
<haskell>
myLast :: [a] -> a
myLast [] = error "No end for empty lists!"
myLast [x] = x
myLast (_:xs) = myLast xs
 
myLast' = foldr1 (const id)
 
-- Prelude> const 1 2
-- 1
-- Prelude> (flip const) 1 2
-- 2
myLast'' = foldr1 (flip const)
 
myLast''' = head . reverse
 
myLast'''' = foldl1 (curry snd)
 
myLast''''' [] = error "No end for empty lists!" 
myLast''''' x = x !! (length x -1)
 
</haskell>
 
haskelll code without syntax highlight (no <code>'</code> problem)
<syntaxhighlight lang="text" line='line'>
 
-- import Prelude
import Data.List
import Data.Function
 
main :: IO ()
main = do
  let xs  = [(8,2),(3,2),(3,1),(10,2),(10,6)] :: [(Int,Int)]
  print xs
  let sortXs' = sort xs
  print sortXs'
 
</syntaxhighlight>
 
=Another syntax highlighting example=
 
<haskell>
import Control.Applicative
import Data.Bits
import Data.IORef
import Data.Word
 
ioDirA, iPolA, ioCon, gpPuA, gpioA, gpioB, olatA :: Word8
 
readReg16 :: ReadFunc -> Word8 -> IO Word16
readReg16 rf reg = word8sToWord16 <$> rf reg 2
 
data RomCode = RomA00 | RomA02
            deriving (Eq, Ord, Show, Read, Bounded, Enum)
</haskell>
 
<!-- DON'T REMOVE PAGE -->
<br>
{{Exercises|
* Why does using this template add this page to the [https://wiki.haskell.org/Category:Pages_to_be_removed Pages to be removed] category?
}}
<!-- DON'T REMOVE PAGE -->

Latest revision as of 07:03, 14 August 2024

Feel free to edit as you wish on this page. It is here for you to experiment with WIKI edit syntax.

fooling around

State class (test)
import Control.Monad.State.Lazy
import testm

TADA! this is a link to google, surprisingly

Siers Fri Jun 27 02:36:37 EEST 2014

section

Sandbox#secton
#Links


--Lars 11:14, 27 July 2009 (UTC)


InsertformulahereMedia:Example.oggFile:Example.jpg

Headline text

Italic textBold text

Pavillon Uge Uge

Matrix:

[1234]

Embedded matrix:

[123[5678]]

Links

An internal link. To not exists page abcd. To exists page Haskell

External

http://cs.pdx.edu/

http://cs.pdx.edu/~dick/HaskellSemantics/jpf05.pdf

http://cs.pdx.edu/~dick/HaskellSemantics/Haskell98.pdf

There is no appearance difference between dead link dead and live link live

Text taken from http://hpaste.org/3881: this wiki's syntax highlight at least does not garble the source, unlike hpaste's highlight.

An external link using text instead of the raw link address.

module Main where

import Prelude hiding (putStrLn, print)
import System.IO.UTF8
import Data.List (intersperse, find)

type Персонаж = String
type Персонажи = [Персонаж]

едоки :: Персонажи
едоки = [ "дедка", "бабка", "внучка", "жучка", "кошка", "мышка" ]

подходы :: [ Персонажи ]
подходы = scanl позвать [] едоки
  where позвать тянущие подмога = подмога:тянущие

построились :: Персонажи -> [ (Персонаж, Персонаж) ]
построились едоки = zip едоки ("репка":едоки)

диспозиции = map (построились.reverse) подходы

описать [] = "Посадил дед репку ..."
описать диспозиция = 
  unwords ["Взялись:"
          , concat $ intersperse ", " $ map за диспозиция
          , ". Тянут-потянут -- " ++ result
          ]
  where 
    за (кто,кого) = кто ++ " за " ++ винительный_падеж кого
    винительный_падеж ы = init ы ++ "у"
    result = case find ((=="мышка").fst) диспозиция of
                  Just _  -> "вытянули репку!"
                  Nothing -> "вытянуть не могут!"

main = mapM_ putStrLn $ map описать диспозиции

Section

Subsection

Subsubsection

huhu

Subsubsubsection

tables

basic table

Header 1 Header 2 Header 3
row 1, cell 1 row 1, cell 2 row 1, cell 3
row 2, cell 1 row 2, cell 2 row 2, cell 3

Single Quote

https://github.com/ppelleti/haskell-wiki-bugs/issues/6

This seems to be fixed.

myLast :: [a] -> a
myLast [] = error "No end for empty lists!"
myLast [x] = x
myLast (_:xs) = myLast xs

myLast' = foldr1 (const id)

-- Prelude> const 1 2
-- 1
-- Prelude> (flip const) 1 2
-- 2
myLast'' = foldr1 (flip const)

myLast''' = head . reverse

myLast'''' = foldl1 (curry snd)

myLast''''' [] = error "No end for empty lists!"  
myLast''''' x = x !! (length x -1)

haskelll code without syntax highlight (no ' problem)

-- import Prelude
import Data.List
import Data.Function

main :: IO ()
main = do
  let xs  = [(8,2),(3,2),(3,1),(10,2),(10,6)] :: [(Int,Int)]
  print xs
  let sortXs' = sort xs
  print sortXs'

Another syntax highlighting example

import Control.Applicative
import Data.Bits
import Data.IORef
import Data.Word

ioDirA, iPolA, ioCon, gpPuA, gpioA, gpioB, olatA :: Word8

readReg16 :: ReadFunc -> Word8 -> IO Word16
readReg16 rf reg = word8sToWord16 <$> rf reg 2

data RomCode = RomA00 | RomA02
             deriving (Eq, Ord, Show, Read, Bounded, Enum)


Exercises