Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/justinwoo/purescript-dango

A fun library for sized lists in PureScript 0.12 using Symbols
https://github.com/justinwoo/purescript-dango

purescript sized type-level

Last synced: 29 days ago
JSON representation

A fun library for sized lists in PureScript 0.12 using Symbols

Awesome Lists containing this project

README

        

# PureScript-Dango

A fun library for sized lists in PureScript 0.12 using Symbols

![](https://i.imgur.com/zAAgsSN.jpg)

## Usage

```hs
main :: Effect Unit
main = do
log "Empty"
let (empty :: D.SizedList "" Int) = D.empty
logShow empty

log "Singleton"
let
-- inferred:
-- (b :: SizedList "." Int)
singleton
= D.singleton 1
logShow singleton

log "toList of singleton"
let list = D.toList singleton
logShow list

log "toList of singleton"
let nonEmptyList = D.toList singleton
logShow nonEmptyList

log "head of singleton"
let head = D.head singleton
logShow head

-- correct compile error:
-- let head' = D.head empty

log "tail of singleton"
let
-- inferred
-- (tail :: SizedList "" Int)
tail
= D.tail singleton
logShow tail

-- correct compile error:
-- let tail' = D.tail empty

log "append two singletons"
let
-- inferred
-- (append :: SizedList ".." Int)
append
= D.append singleton singleton
logShow append

log "Finished"
```